interpolate_position Subroutine

private subroutine interpolate_position(traj, sources, t, status, index, position, ok)

Linear interpolation of the position (from sources) at time t; the first/last point 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

type(DataSource), intent(in) :: sources(3)

where the position's x, y, z come from

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) :: position(3)

the interpolated position

logical, intent(out) :: ok

false if there is no position (position unchanged)


Calls

proc~~interpolate_position~~CallsGraph proc~interpolate_position interpolate_position proc~num_points Trajectory%num_points proc~interpolate_position->proc~num_points proc~point_between Trajectory%point_between proc~interpolate_position->proc~point_between proc~point~2 Trajectory%point proc~interpolate_position->proc~point~2 proc~point_between->proc~num_points proc~point_between->proc~point~2 proc~time_fraction Trajectory%time_fraction proc~point_between->proc~time_fraction

Called by

proc~~interpolate_position~~CalledByGraph proc~interpolate_position interpolate_position proc~state_at TrajectoryFollower%state_at proc~state_at->proc~interpolate_position 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_position(traj, sources, t, status, index, position, ok)
        type(Trajectory), intent(in) :: traj        !! the trajectory
        type(DataSource), intent(in) :: sources(3)  !! where the position's x, y, z come from
        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) :: position(3)      !! the interpolated position
        logical, intent(out) :: ok                  !! false if there is no position (position unchanged)
        integer :: n, i
        ok = .false.
        n = traj%num_points(sources)
        if (n == 0) return
        if (all(sources%src == SOURCE_ZERO)) then
            position = 0.0_wp
            ok = .true.
            return
        end if
        i = index
        if (status == TIME_NOT_FOUND) return
        if (status == TIME_OUT_OF_RANGE) then
            position = traj%point(merge(1, n, i < 1), sources)
        else if (i >= n) then
            position = traj%point(n, sources)            ! (the last; or fewer points than times: the last available)
        else
            position = traj%point_between(i, i + 1, t, sources)
        end if
        ok = .true.
    end subroutine interpolate_position