A trajectory (see the module documentation).
| 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 |
The Trajectory constructor: Trajectory(...) makes one (see new_trajectory for its
arguments).
A trajectory with dof (2 or 3, default 3) degrees of freedom and
nopt (default 0) optional vectors per position.
| Type | Intent | Optional | 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) |
Add a point: a time with an optional position, attitude and color ([r, g, b] or [r, g, b, a]).
| Type | Intent | Optional | 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) |
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.
| Type | Intent | Optional | 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) |
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.
| Type | Intent | Optional | 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 |
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.
| Type | Intent | Optional | 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 |
Add a point: a time with an optional position, attitude and color ([r, g, b] or [r, g, b, a]).
| Type | Intent | Optional | 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) |
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.
| Type | Intent | Optional | 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) |
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.
| Type | Intent | Optional | 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 |
Add a time at the end of the time list.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(inout) | :: | self | |||
| real(kind=wp), | intent(in) | :: | t |
the time |
Attitude i (quaternion [x, y, z, w]).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(in) | :: | self | |||
| integer, | intent(in) | :: | i |
the attitude (1 to num_attitudes) |
Pointer to the attitudes (4, num_attitudes), without copying.
| Type | Intent | Optional | 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) |
Remove all points (keeping the memory).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(inout) | :: | self |
Color i ([r, g, b, a]).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(in) | :: | self | |||
| integer, | intent(in) | :: | i |
the color (1 to num_colors) |
Pointer to the colors (4, num_colors; single precision, as drawn), without copying.
| Type | Intent | Optional | 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) |
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).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(inout) | :: | self |
Degrees of freedom (2 or 3) of positions and optionals.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(in) | :: | self |
Number of times the data were cleared (by clear, set_dof or set_num_optionals): while it is unchanged, data were only appended.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(in) | :: | self |
True if the trajectory has no times.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(in) | :: | self |
Number of attitudes (at most num_times).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(in) | :: | self |
Number of colors (at most num_times).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(in) | :: | self |
Number of optional vectors per position.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(in) | :: | self |
Number of points available with these sources: the number of times, limited by the positions or attitudes they use; huge() if all are zero.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(in) | :: | self | |||
| type(DataSource), | intent(in) | :: | sources(3) |
where the components come from |
Number of positions (at most num_times).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(in) | :: | self |
Number of times.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(in) | :: | self |
Optional vector k (1 to num_optionals) of position i.
| Type | Intent | Optional | 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) |
Point i with components from sources (OpenFrames' getPoint). No checks:
use verify_data and num_points first.
| Type | Intent | Optional | 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 |
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).
| Type | Intent | Optional | 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 |
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).
| Type | Intent | Optional | 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 |
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.
| Type | Intent | Optional | 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) |
Position i (z = 0 for a 2-DOF trajectory).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(in) | :: | self | |||
| integer, | intent(in) | :: | i |
the position (1 to num_positions) |
Pointer to the positions (3, num_positions), without copying.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(in), | target | :: | self | ||
| real(kind=wp), | intent(out), | dimension(:,:), pointer | :: | p |
(3, num_positions): positions (null if none) |
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).
| Type | Intent | Optional | 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) |
Number of changes so far (any added, set or cleared data).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(in) | :: | self |
Set the degrees of freedom (2 or 3) of positions and optionals; clears the trajectory.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(inout) | :: | self | |||
| integer, | intent(in) | :: | dof |
degrees of freedom (2 or 3) |
Set the number of optional vectors per position; clears the trajectory.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(inout) | :: | self | |||
| integer, | intent(in) | :: | nopt |
optional vectors per position (>= 0) |
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.
| Type | Intent | Optional | 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 |
The memory the trajectory's data take (bytes), used or not: its storage's capacity (see reserve, compact).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(in) | :: | self |
Time i.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(in) | :: | self | |||
| integer, | intent(in) | :: | i |
the time (1 to num_times) |
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 |
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.
| Type | Intent | Optional | 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 |
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.
| Type | Intent | Optional | 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) |
The first and last times, ordered (t0 <= tf); false if there are no times.
| Type | Intent | Optional | 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) |
Pointer to the times (num_times), without copying.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(in), | target | :: | self | ||
| real(kind=wp), | intent(out), | dimension(:), pointer | :: | t |
(num_times): times (null if none) |
True if the trajectory has the data the sources refer to (elements and optionals in range).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Trajectory), | intent(in) | :: | self | |||
| type(DataSource), | intent(in) | :: | sources(3) |
where the components come from |
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