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.
| Type | Intent | Optional | 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) |
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