The "distance" from time t to the time range [t0, tf]: > 0 outside it (to the nearer end), 0 at its ends, < 0 inside; huge() without times. (OpenFrames' getTimeDistance.)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(in) | :: | self | |||
| real(kind=wp), | intent(in) | :: | t |
the time |
pure real(wp) function time_distance(self, t) class(Trajectory), intent(in) :: self real(wp), intent(in) :: t !! the time real(wp) :: t0, tf if (self%n_times == 0) then time_distance = huge(1.0_wp) return end if t0 = min(self%t(1), self%t(self%n_times)) tf = max(self%t(1), self%t(self%n_times)) if (t <= t0) then time_distance = t0 - t else if (t >= tf) then time_distance = t - tf else time_distance = (t - t0) * (t - tf) end if end function time_distance