Slerp of the attitude at time t; the first/last attitude outside the time
range. status and index: the trajectory's time_index for t.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(Trajectory), | intent(in) | :: | traj |
the trajectory |
||
| real(kind=wp), | intent(in) | :: | t |
the time (s) |
||
| integer, | intent(in) | :: | status |
traj%time_index's result and index for t |
||
| integer, | intent(in) | :: | index |
traj%time_index's result and index for t |
||
| real(kind=wp), | intent(inout) | :: | attitude(4) |
quaternion [x, y, z, w] |
||
| logical, | intent(out) | :: | ok |
false if there is no attitude (attitude unchanged) |
subroutine interpolate_attitude(traj, t, status, index, attitude, ok) type(Trajectory), intent(in) :: traj !! the trajectory real(wp), intent(in) :: t !! the time (s) integer, intent(in) :: status, index !! traj%time_index's result and index for t real(wp), intent(inout) :: attitude(4) !! quaternion [x, y, z, w] logical, intent(out) :: ok !! false if there is no attitude (attitude unchanged) integer :: n, i real(wp) :: frac ok = .false. n = traj%num_attitudes() if (n == 0) return i = index if (status == TIME_NOT_FOUND) return if (status == TIME_OUT_OF_RANGE) then i = merge(1, n, i < 1) attitude = traj%attitude(i) else if (i > n) then attitude = traj%attitude(n) else attitude = traj%attitude(i) if (i + 1 <= n) then if (traj%time(i + 1) /= traj%time(i)) then frac = (t - traj%time(i)) / (traj%time(i + 1) - traj%time(i)) attitude = quat_slerp(frac, attitude, traj%attitude(i + 1)) end if end if end if ok = .true. end subroutine interpolate_attitude