interpolate_attitude Subroutine

private subroutine interpolate_attitude(traj, t, status, index, attitude, ok)

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.

Arguments

Type IntentOptional 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)


Calls

proc~~interpolate_attitude~~CallsGraph proc~interpolate_attitude interpolate_attitude proc~attitude~3 Trajectory%attitude proc~interpolate_attitude->proc~attitude~3 proc~num_attitudes Trajectory%num_attitudes proc~interpolate_attitude->proc~num_attitudes proc~quat_slerp quat_slerp proc~interpolate_attitude->proc~quat_slerp

Called by

proc~~interpolate_attitude~~CalledByGraph proc~interpolate_attitude interpolate_attitude proc~state_at TrajectoryFollower%state_at proc~state_at->proc~interpolate_attitude proc~followed_pose followed_pose proc~followed_pose->proc~state_at proc~world_matrix_at ReferenceFrame%world_matrix_at proc~followed_pose->proc~world_matrix_at proc~update~2 TrajectoryFollower%update proc~update~2->proc~state_at proc~local_matrix_at ReferenceFrame%local_matrix_at proc~local_matrix_at->proc~followed_pose proc~update ReferenceFrame%update proc~update->proc~followed_pose proc~update->proc~update~2 proc~drawable_update DrawableTrajectory%drawable_update proc~drawable_update->proc~update proc~fm_update FrameManager%fm_update proc~fm_update->proc~update proc~sphere_update Sphere%sphere_update proc~sphere_update->proc~update proc~terrain_update TerrainBody%terrain_update proc~terrain_update->proc~update proc~world_matrix_at->proc~local_matrix_at proc~world_matrix_at->proc~world_matrix_at proc~data_to_shown data_to_shown proc~data_to_shown->proc~world_matrix_at proc~to_shown to_shown proc~to_shown->proc~data_to_shown proc~art_point_between art_point_between proc~art_point_between->proc~to_shown proc~to_shown_at to_shown_at proc~to_shown_at->proc~to_shown proc~art_point art_point proc~art_point->proc~to_shown_at proc~art_points art_points proc~art_points->proc~to_shown_at proc~intermediates_by_time intermediates_by_time proc~intermediates_by_time->proc~art_point_between proc~marker_point marker_point proc~marker_point->proc~to_shown_at proc~marker_point->proc~art_point proc~update_ribbon_tail RibbonArtist%update_ribbon_tail proc~update_ribbon_tail->proc~art_point_between proc~update_ribbon_tail->proc~art_point proc~update_tail CurveArtist%update_tail proc~update_tail->proc~art_point_between proc~update_tail->proc~art_point proc~write_segments write_segments proc~write_segments->proc~to_shown_at proc~add_intermediates add_intermediates proc~add_intermediates->proc~intermediates_by_time proc~intermediates_by_data intermediates_by_data proc~add_intermediates->proc~intermediates_by_data proc~intermediates_by_distance intermediates_by_distance proc~add_intermediates->proc~intermediates_by_distance proc~curve_pick curve_pick proc~curve_pick->proc~art_point proc~intermediates_by_data->proc~art_point proc~intermediates_by_distance->proc~art_point proc~marker_update MarkerArtist%marker_update proc~marker_update->proc~marker_point proc~marker_update->proc~add_intermediates proc~update_bounds update_bounds proc~marker_update->proc~update_bounds proc~segment_update SegmentArtist%segment_update proc~segment_update->proc~write_segments proc~update_bounds->proc~art_points proc~write_curve CurveArtist%write_curve proc~write_curve->proc~art_points proc~write_ribbon RibbonArtist%write_ribbon proc~write_ribbon->proc~art_points proc~drawable_pick DrawableTrajectory%drawable_pick proc~drawable_pick->proc~curve_pick

Source Code

    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