Trajectory Derived Type

type, public :: Trajectory

A trajectory (see the module documentation).


Inherited by

type~~trajectory~~InheritedByGraph type~trajectory Trajectory type~pickhit PickHit type~pickhit->type~trajectory trajectory type~referenceframe ReferenceFrame type~pickhit->type~referenceframe frame type~trajectoryartist TrajectoryArtist type~trajectoryartist->type~trajectory traj type~trajectoryartist->type~referenceframe shown_in, data_frame, seen_data_frame type~trajectorypath TrajectoryPath type~trajectorypath->type~trajectory trajectory type~trajectorypointer TrajectoryPointer type~trajectorypointer->type~trajectory p type~artistpointer ArtistPointer type~artistpointer->type~trajectoryartist p type~chainartist ChainArtist type~chainartist->type~trajectoryartist type~markerartist MarkerArtist type~markerartist->type~trajectoryartist type~segmentartist SegmentArtist type~segmentartist->type~trajectoryartist type~trajectoryfollower TrajectoryFollower type~trajectoryfollower->type~trajectorypointer trajs type~curveartist CurveArtist type~curveartist->type~chainartist type~drawabletrajectory DrawableTrajectory type~drawabletrajectory->type~artistpointer artists type~drawabletrajectory->type~referenceframe data_frame_ type~drawabletrajectory->type~referenceframe type~referenceframe->type~trajectoryfollower follower_ type~referenceframe->type~referenceframe follow_frame_ type~framepointer FramePointer type~referenceframe->type~framepointer children, parents type~ribbonartist RibbonArtist type~ribbonartist->type~chainartist type~coordinateaxes CoordinateAxes type~coordinateaxes->type~referenceframe type~customlinesegments CustomLineSegments type~customlinesegments->type~referenceframe type~draghandle DragHandle type~draghandle->type~referenceframe type~framemanager FrameManager type~framemanager->type~referenceframe root type~framepointer->type~referenceframe p type~latlongrid LatLonGrid type~latlongrid->type~referenceframe type~model Model type~model->type~referenceframe type~polyhedralcone PolyhedralCone type~polyhedralcone->type~referenceframe type~polyhedron Polyhedron type~polyhedron->type~referenceframe type~radialplane RadialPlane type~radialplane->type~referenceframe type~shadowcones ShadowCones type~shadowcones->type~referenceframe body_, light_ type~shadowcones->type~referenceframe type~sphere Sphere type~sphere->type~referenceframe type~terrainbody TerrainBody type~terrainbody->type~referenceframe type~view View type~view->type~referenceframe root, frame, lookat type~cameraflight CameraFlight type~cameraflight->type~view from, to type~ellipticcone EllipticCone type~ellipticcone->type~polyhedralcone type~rectangularcone RectangularCone type~rectangularcone->type~polyhedralcone type~timehandle TimeHandle type~timehandle->type~draghandle type~vectorhandle VectorHandle type~vectorhandle->type~draghandle type~viewpointer ViewPointer type~viewpointer->type~view p type~windowproxy WindowProxy type~windowproxy->type~draghandle hovered_handle, dragged_handle type~windowproxy->type~framemanager scene type~windowproxy->type~view default_view, shown type~windowproxy->type~cameraflight flight type~windowproxy->type~viewpointer views

Components

Type Visibility Attributes Name Initial
real(kind=wp), private, allocatable :: att(:,:)

(4, capacity): quaternions [x, y, z, w]

real(kind=c_float), private, allocatable :: col(:,:)

(4, capacity): colors [r, g, b, a] (as drawn)

integer, private :: dof_ = 3

degrees of freedom of positions and optionals (2 or 3)

integer, private :: generation_ = 0

incremented when the data are cleared

integer, private :: n_att = 0

number of attitudes (<= n_times)

integer, private :: n_col = 0

number of colors (<= n_times)

integer, private :: n_pos = 0

number of positions (<= n_times)

integer, private :: n_times = 0

number of times

integer, private :: nopt_ = 0

optionals per position

real(kind=wp), private, allocatable :: posopt(:,:,:)

(3, 0:nopt, capacity): position, then optionals

integer, private :: revision_ = 0

incremented on every change

real(kind=wp), private, allocatable :: t(:)

(capacity): times


Constructor

public interface Trajectory

The Trajectory constructor: Trajectory(...) makes one (see new_trajectory for its arguments).

  • private function new_trajectory(dof, nopt) result(traj)

    A trajectory with dof (2 or 3, default 3) degrees of freedom and nopt (default 0) optional vectors per position.

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in), optional :: dof

    degrees of freedom (2 or 3, default 3)

    integer, intent(in), optional :: nopt

    optional vectors per position (default 0)

    Return Value type(Trajectory)


Type-Bound Procedures

generic, public :: add => add_point, add_points

  • private subroutine add_point(self, t, pos, att, color)

    Add a point: a time with an optional position, attitude and color ([r, g, b] or [r, g, b, a]).

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(inout) :: self
    real(kind=wp), intent(in) :: t

    time

    real(kind=wp), intent(in), optional :: pos(:)

    position (first dof elements used)

    real(kind=wp), intent(in), optional :: att(4)

    attitude quaternion [x, y, z, w]

    real(kind=wp), intent(in), optional :: color(:)

    [r, g, b] or [r, g, b, a] (0 to 1)

  • private subroutine add_points(self, t, pos, att, color)

    Add points in bulk: times t(n), with optional positions pos(dof, n), attitudes att(4, n) and colors color(3 or 4, n). Times, positions, attitudes and colors must all have been complete before (as many of each as times) for the given ones to line up with t.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(inout) :: self
    real(kind=wp), intent(in) :: t(:)

    (n): times

    real(kind=wp), intent(in), optional :: pos(:,:)

    (dof, n): positions

    real(kind=wp), intent(in), optional :: att(:,:)

    (4, n): attitude quaternions [x, y, z, w]

    real(kind=wp), intent(in), optional :: color(:,:)

    (3 or 4, n): colors [r, g, b(, a)] (0 to 1)

procedure, public :: add_attitude

  • private subroutine add_attitude(self, q, ok)

    Add an attitude quaternion [x, y, z, w] for the next time that has none. ok is false if every time already has an attitude.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(inout) :: self
    real(kind=wp), intent(in) :: q(4)

    quaternion [x, y, z, w]

    logical, intent(out), optional :: ok

    false if not added

procedure, public :: add_color

  • private subroutine add_color(self, color, ok)

    Add a color ([r, g, b], alpha 1, or [r, g, b, a], 0 to 1) for the next time that has none. ok is false if every time already has a color.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(inout) :: self
    real(kind=wp), intent(in) :: color(:)

    [r, g, b] or [r, g, b, a] (0 to 1)

    logical, intent(out), optional :: ok

    false if not added

procedure, private :: add_point

  • private subroutine add_point(self, t, pos, att, color)

    Add a point: a time with an optional position, attitude and color ([r, g, b] or [r, g, b, a]).

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(inout) :: self
    real(kind=wp), intent(in) :: t

    time

    real(kind=wp), intent(in), optional :: pos(:)

    position (first dof elements used)

    real(kind=wp), intent(in), optional :: att(4)

    attitude quaternion [x, y, z, w]

    real(kind=wp), intent(in), optional :: color(:)

    [r, g, b] or [r, g, b, a] (0 to 1)

procedure, private :: add_points

  • private subroutine add_points(self, t, pos, att, color)

    Add points in bulk: times t(n), with optional positions pos(dof, n), attitudes att(4, n) and colors color(3 or 4, n). Times, positions, attitudes and colors must all have been complete before (as many of each as times) for the given ones to line up with t.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(inout) :: self
    real(kind=wp), intent(in) :: t(:)

    (n): times

    real(kind=wp), intent(in), optional :: pos(:,:)

    (dof, n): positions

    real(kind=wp), intent(in), optional :: att(:,:)

    (4, n): attitude quaternions [x, y, z, w]

    real(kind=wp), intent(in), optional :: color(:,:)

    (3 or 4, n): colors [r, g, b(, a)] (0 to 1)

procedure, public :: add_position

  • private subroutine add_position(self, pos, ok)

    Add a position (the first dof elements of pos are used) for the next time that has none. ok is false if every time already has a position.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(inout) :: self
    real(kind=wp), intent(in) :: pos(:)

    position (first dof elements used)

    logical, intent(out), optional :: ok

    false if not added

procedure, public :: add_time

  • private subroutine add_time(self, t)

    Add a time at the end of the time list.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(inout) :: self
    real(kind=wp), intent(in) :: t

    the time

procedure, public :: attitude

  • private pure function attitude(self, i) result(q)

    Attitude i (quaternion [x, y, z, w]).

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self
    integer, intent(in) :: i

    the attitude (1 to num_attitudes)

    Return Value real(kind=wp), (4)

procedure, public :: attitudes

  • private subroutine attitudes(self, q)

    Pointer to the attitudes (4, num_attitudes), without copying.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in), target :: self
    real(kind=wp), intent(out), dimension(:,:), pointer :: q

    (4, num_attitudes): quaternions [x, y, z, w] (null if none)

procedure, public :: clear

  • private subroutine clear(self)

    Remove all points (keeping the memory).

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(inout) :: self

procedure, public :: color

  • private pure function color(self, i) result(c)

    Color i ([r, g, b, a]).

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self
    integer, intent(in) :: i

    the color (1 to num_colors)

    Return Value real(kind=wp), (4)

procedure, public :: colors

  • private subroutine colors(self, c)

    Pointer to the colors (4, num_colors; single precision, as drawn), without copying.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in), target :: self
    real(kind=c_float), intent(out), dimension(:,:), pointer :: c

    (4, num_colors): colors [r, g, b, a] (null if none)

procedure, public :: compact

  • private subroutine compact(self)

    Free the storage not used: each array is reallocated to the points it holds (one copy, an array at a time), and arrays holding none are deallocated. For a trajectory that is complete: growing doubles the storage, so up to about half of it can be unused. The data and what is drawn of them don't change; pointers from times, positions, ... must be fetched again. Points can still be added (storage grows again).

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(inout) :: self

procedure, public :: dof

  • private pure function dof(self)

    Degrees of freedom (2 or 3) of positions and optionals.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self

    Return Value integer

procedure, public :: generation

  • private pure function generation(self)

    Number of times the data were cleared (by clear, set_dof or set_num_optionals): while it is unchanged, data were only appended.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self

    Return Value integer

procedure, public :: is_empty

  • private pure function is_empty(self)

    True if the trajectory has no times.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self

    Return Value logical

procedure, public :: num_attitudes

  • private pure function num_attitudes(self)

    Number of attitudes (at most num_times).

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self

    Return Value integer

procedure, public :: num_colors

  • private pure function num_colors(self)

    Number of colors (at most num_times).

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self

    Return Value integer

procedure, public :: num_optionals

  • private pure function num_optionals(self)

    Number of optional vectors per position.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self

    Return Value integer

procedure, public :: num_points

  • private pure function num_points(self, sources)

    Number of points available with these sources: the number of times, limited by the positions or attitudes they use; huge() if all are zero.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self
    type(DataSource), intent(in) :: sources(3)

    where the components come from

    Return Value integer

procedure, public :: num_positions

  • private pure function num_positions(self)

    Number of positions (at most num_times).

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self

    Return Value integer

procedure, public :: num_times

  • private pure function num_times(self)

    Number of times.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self

    Return Value integer

procedure, public :: optional

  • private pure function optional(self, i, k) result(v)

    Optional vector k (1 to num_optionals) of position i.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self
    integer, intent(in) :: i

    the position (1 to num_positions); the optional (1 to num_optionals)

    integer, intent(in) :: k

    the position (1 to num_positions); the optional (1 to num_optionals)

    Return Value real(kind=wp), (3)

procedure, public :: point

  • private pure function point(self, i, sources) result(v)

    Point i with components from sources (OpenFrames' getPoint). No checks: use verify_data and num_points first.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self
    integer, intent(in) :: i

    the point (1 to num_points(sources))

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

    where the components come from

    Return Value real(kind=wp), (3)

procedure, public :: point_at

  • private function point_at(self, t, sources, ok) result(v)

    The point at time t (components from sources; default: the position's), linear in time between the points about it; outside the times, the first or last point. ok (optional) false, and v 0, if there is no point (or the search for the time failed).

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self
    real(kind=wp), intent(in) :: t

    the time

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

    where the components come from (default: the position)

    logical, intent(out), optional :: ok

    a point was found

    Return Value real(kind=wp), (3)

procedure, public :: point_between

  • private pure function point_between(self, k, k2, t, sources) result(v)

    The point at time t between points k and k2 (components from sources): linear in time, within the two (time_fraction). Point k if k2 isn't a point (beyond the ends, or more times than data).

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self
    integer, intent(in) :: k

    a point (1 to num_points(sources))

    integer, intent(in) :: k2

    the other point (e.g. k + 1)

    real(kind=wp), intent(in) :: t

    the time

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

    where the components come from

    Return Value real(kind=wp), (3)

procedure, public :: points

  • private pure subroutine points(self, i1, i2, sources, v, stride)

    Points i1, i1 + stride, ... (up to i2) with components from sources, into v(3, :) (as many columns as points; point for a range, a whole array slice per component). No checks: use verify_data and num_points first.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self
    integer, intent(in) :: i1

    first and last points (1 to num_points(sources))

    integer, intent(in) :: i2

    first and last points (1 to num_points(sources))

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

    where the components come from

    real(kind=wp), intent(out) :: v(:,:)

    (3, number of points)

    integer, intent(in), optional :: stride

    step between points (default 1)

procedure, public :: position

  • private pure function position(self, i) result(p)

    Position i (z = 0 for a 2-DOF trajectory).

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self
    integer, intent(in) :: i

    the position (1 to num_positions)

    Return Value real(kind=wp), (3)

procedure, public :: positions

  • private subroutine positions(self, p)

    Pointer to the positions (3, num_positions), without copying.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in), target :: self
    real(kind=wp), intent(out), dimension(:,:), pointer :: p

    (3, num_positions): positions (null if none)

procedure, public :: reserve

  • private subroutine reserve(self, n, positions, attitudes, colors)

    Reserve memory for n points: times, positions (with their optionals) unless positions is false, and attitudes and colors only if attitudes / colors is true. Optional: storage grows as needed, but reserving avoids reallocations for a known size. It never shrinks the storage (see compact).

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(inout) :: self
    integer, intent(in) :: n

    number of points

    logical, intent(in), optional :: positions

    reserve positions (default true)

    logical, intent(in), optional :: attitudes

    reserve attitudes (default false)

    logical, intent(in), optional :: colors

    reserve colors (default false)

procedure, public :: revision

  • private pure function revision(self)

    Number of changes so far (any added, set or cleared data).

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self

    Return Value integer

procedure, public :: set_dof

  • private subroutine set_dof(self, dof)

    Set the degrees of freedom (2 or 3) of positions and optionals; clears the trajectory.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(inout) :: self
    integer, intent(in) :: dof

    degrees of freedom (2 or 3)

procedure, public :: set_num_optionals

  • private subroutine set_num_optionals(self, nopt)

    Set the number of optional vectors per position; clears the trajectory.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(inout) :: self
    integer, intent(in) :: nopt

    optional vectors per position (>= 0)

procedure, public :: set_optional

  • private subroutine set_optional(self, index, v, ok)

    Set optional vector index (1 to num_optionals) of the most recently added position. ok is false if there is no position or no such optional.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(inout) :: self
    integer, intent(in) :: index

    the optional (1 to num_optionals)

    real(kind=wp), intent(in) :: v(:)

    the vector (its first dof elements are used)

    logical, intent(out), optional :: ok

    false if not set

procedure, public :: storage_bytes

  • private pure function storage_bytes(self) result(b)

    The memory the trajectory's data take (bytes), used or not: its storage's capacity (see reserve, compact).

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self

    Return Value integer(kind=int64)

procedure, public :: time

  • private pure function time(self, i)

    Time i.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self
    integer, intent(in) :: i

    the time (1 to num_times)

    Return Value real(kind=wp)

procedure, public :: time_distance

  • private pure function time_distance(self, t)

    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.)

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self
    real(kind=wp), intent(in) :: t

    the time

    Return Value real(kind=wp)

procedure, public :: time_fraction

  • private pure function time_fraction(self, k, k2, t) result(frac)

    The fraction of the way in time from point k to point k2 (any two points: e.g. k + 1, or k - 1 with times running backward) at time t, kept within 0 to 1 (0 if their times are the same). No checks: k and k2 must be times.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self
    integer, intent(in) :: k

    the points (1 to num_times)

    integer, intent(in) :: k2

    the points (1 to num_times)

    real(kind=wp), intent(in) :: t

    the time

    Return Value real(kind=wp)

procedure, public :: time_index

  • private function time_index(self, t, index) result(status)

    Find the interval of the time list containing t, by bisection (times increasing or decreasing). Returns a TIME_ code, or the number of iterations (> 0) when found, with times(index) <= t < times(index+1) for increasing times (>= and > for decreasing). See the TIME_ constants for index in the other cases.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self
    real(kind=wp), intent(in) :: t

    the time

    integer, intent(out) :: index

    the interval's first index (see the TIME_* constants)

    Return Value integer

procedure, public :: time_range

  • private function time_range(self, t0, tf)

    The first and last times, ordered (t0 <= tf); false if there are no times.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self
    real(kind=wp), intent(out) :: t0

    first and last times (t0 <= tf; 0 if no times)

    real(kind=wp), intent(out) :: tf

    first and last times (t0 <= tf; 0 if no times)

    Return Value logical

procedure, public :: times

  • private subroutine times(self, t)

    Pointer to the times (num_times), without copying.

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in), target :: self
    real(kind=wp), intent(out), dimension(:), pointer :: t

    (num_times): times (null if none)

procedure, public :: verify_data

  • private pure function verify_data(self, sources)

    True if the trajectory has the data the sources refer to (elements and optionals in range).

    Arguments

    Type IntentOptional Attributes Name
    class(Trajectory), intent(in) :: self
    type(DataSource), intent(in) :: sources(3)

    where the components come from

    Return Value logical

Source Code

    type, public :: Trajectory
        private
        integer :: dof_ = 3                                 !! degrees of freedom of positions and optionals (2 or 3)
        integer :: nopt_ = 0                                !! optionals per position
        integer :: n_times = 0                              !! number of times
        integer :: n_pos = 0                                !! number of positions (<= n_times)
        integer :: n_att = 0                                !! number of attitudes (<= n_times)
        integer :: n_col = 0                                !! number of colors (<= n_times)
        real(wp), allocatable :: t(:)                       !! (capacity): times
        real(wp), allocatable :: posopt(:,:,:)              !! (3, 0:nopt, capacity): position, then optionals
        real(wp), allocatable :: att(:,:)                   !! (4, capacity): quaternions [x, y, z, w]
        real(c_float), allocatable :: col(:,:)              !! (4, capacity): colors [r, g, b, a] (as drawn)
        integer :: revision_ = 0                            !! incremented on every change
        integer :: generation_ = 0                          !! incremented when the data are cleared
    contains
        procedure :: reserve, compact, storage_bytes
        procedure :: clear
        procedure :: set_dof, dof
        procedure :: set_num_optionals, num_optionals
        procedure :: num_times, num_positions, num_attitudes, num_colors, is_empty
        procedure :: add_time, add_position, add_attitude, add_color, set_optional
        generic :: add => add_point, add_points
        procedure, private :: add_point, add_points
        procedure :: time, position, attitude, optional, color
        procedure :: times, positions, attitudes, colors
        procedure :: time_range, time_distance, time_index
        procedure :: point, points, verify_data, num_points
        procedure :: time_fraction, point_between, point_at
        procedure :: revision, generation
    end type Trajectory