A frame's local-to-parent transform, as OpenFrames' FrameTransform builds it: translate(position) * rotate(attitude) * scale(scale) * translate(-pivot).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | position(3) |
origin in the parent frame |
||
| real(kind=wp), | intent(in) | :: | attitude(4) |
quaternion [x, y, z, w] |
||
| real(kind=wp), | intent(in), | optional | :: | scale(3) |
scale along each local axis (default 1) |
|
| real(kind=wp), | intent(in), | optional | :: | pivot(3) |
local point placed at |
pure function frame_matrix(position, attitude, scale, pivot) result(m) real(wp), intent(in) :: position(3) !! origin in the parent frame real(wp), intent(in) :: attitude(4) !! quaternion [x, y, z, w] real(wp), intent(in), optional :: scale(3) !! scale along each local axis (default 1) real(wp), intent(in), optional :: pivot(3) !! local point placed at `position` (default 0) real(wp) :: m(4,4) real(wp) :: r(3,3), s(3), p(3) integer :: k s = 1.0_wp p = 0.0_wp if (present(scale)) s = scale if (present(pivot)) p = pivot r = quat_to_matrix(attitude) m = 0.0_wp do k = 1, 3 m(1:3, k) = r(:, k) * s(k) end do m(1:3, 4) = position - matmul(m(1:3, 1:3), p) m(4, 4) = 1.0_wp end function frame_matrix