6.9 Trajectories
Instances of Trajectory
are used to define an intended path for Entity
motion in precise mathematical terms. The motion path may be specified using different mathematical shapes:

Polyline
: A concatenation of simple line segments across a set of vertices. 
Clothoid
: Euler spiral, meaning a curve with linearly increasing curvature. 
Clothoid spline
: Multisegment curve consisting of multiple Euler spiral segments. 
NonUniform Rational BSplines (
NURBS
) of arbitrary order.
Instances of Trajectory
may be specified using just the threepositional dimensions along the X, Y, and Z axes (see Section 6.3, "Coordinate systems" for coordinate system definitions). Alternatively, instances of Trajectory
may also be specified using the threepositional dimensions and the threerotational dimensions (heading, pitch and roll) for six total dimensions. In the second case, the path not only specifies the movement of the entity along the path, but also the orientation of the corresponding entity during that movement.
When a Trajectory
is specified relative to the position of a moving entity, its absolute position cannot be calculated before the scenario runtime. In this case, the trajectory must be calculated during the scenario runtime when the corresponding FollowTrajectoryAction
is triggered.
Additionally, an instance of Trajectory
may be specified with or without a time dimension, allowing for the combined or separate specification of the entities longitudinal domain: A trajectory incorporating the time dimension completely specifies the motion of the entity, including its speed. A trajectory without the time dimension does not specify the speed along the path. This approach allows for the separate control of speed.
A Trajectory
provides a mathematically precise definition of a motion path.
The corresponding entities behavior, however, depends on the actions employing the trajectory: Either an Entity
follows this path exactly, or it uses the path as a guidance for the controller to follow the trajectory as best as the entities rules of motion allow.
Polyline trajectories may be used to represent a sampled version of any arbitrary curve shape. When using polyline trajectories, it is advised to use a sufficiently high number of points.
Clothoid and clothoid spline trajectories can be used to ensure a constant change of curvature along the curve shape. This can be useful to ensure that a trajectory is driveable. Circular arc and straight line segments can be expressed as special cases of clothoids by setting the curvature to a constant value and zero respectively. For clothoid spline trajectories it is possible to define the connecting points between the segments. This may be used to reset numerical errors, which might occur in very large trajectories. If the intermediate positions are not provided, the end position of the last segment will be used. Clothoid spline trajectories shall always be gapless between any two segments. However, it is permitted to intentionally model discontinuities in the tangent and curvature between the segments. This may be used to directly connect a circular arc and a line segment or create a sharp kink to induce a strong jerk in an entities' motion.
By using NURBS trajectories, most relevant trajectory curves may be expressed either directly or with arbitrary approximation: NURBS curves form a strict superset of the curves expressible as Bézier curves, piecewise Bézier curves, or nonrational BSplines, which can be mapped to corresponding NURBS curves. Because NURBS curves directly support the expression of conic sections (such as circles and ellipses), approximation of clothoids using arc spline approaches is feasible. Note that although NURBS are able to approximate most relevant types of curves, it is nontrivial to understand if a certain type of curve has been approximated using a NURBS when reading a scenario file using NURBS. Therefore, conversion of other curve types to NURBS should only be used if later editing of the trajectory in the file, based on the initial curve type, is not required.
Another useful property of NURBS is that they allow continuity up to a given derivative: A NURBS curve of degree k, meaning order k+1, is infinitely continuously differentiable in the interior of each knot span and kM1 times continuously differentiable at a knot. M is the multiplicity of the knot, meaning the number of consecutive knot vector elements with the same value.
Commonly used NURBS curves are curves of quadratic (order = 3) and cubic (order = 4) degree.
Curves of higher order are usually only required if continuity in higher derivatives needs to be ensured.
The effort for evaluating curves increases with rising orders.
Therefore, it is recommended to restrict instances of Trajectory
to lower orders.
The following sections describe edge cases in the definition of trajectories.
6.9.1 Entity is not at the start of trajectory, timeReference is not set
Starting conditions:

When the
FollowTrajectoryAction
starts, the entity is not at the beginning of the trajectory. 
Time references are not set.
Expected behavior:

If the
followingMode
isposition
, the entity teleports to the beginning of the trajectory. 
If the
followingMode
isfollow
, the controller attempts to steer as close to the trajectory as possible. Because thetimeReference
is not defined, the controller steers towards the point that bring the entity in line with the trajectory as soon as feasible. Considering the current position, orientation, and performance limitations of the entity, this is possibly not the start point of the trajectory, and maybe not even the geometrically closest point, as shown in Figure 19.
6.9.2 Entity is not at the start of trajectory, timeReference is set (in the future)
Starting conditions:

When the
FollowTrajectoryAction
starts, the entity is not at the beginning of the trajectory. 
The time reference is set at beginning of the trajectory (t_{1}), the time reference is later than the current time (t < t_{1}).
Expected behavior:

If the
followingMode
isposition
, the action starts, but the entity keeps moving as before until t_{1} is reached. At t = t_{1}, the entity teleports to the start of the trajectory, and continues along the trajectory. 
If the
followingMode
isfollow
, the entity immediately starts steering towards the trajectory, with the aim to be at the trajectory start at t = t_{1}.
6.9.3 Entity is not at the start of trajectory, timeReference is set (in the past)
Starting conditions:

When the
FollowTrajectoryAction
starts, the entity is not at the beginning of the trajectory. 
The time reference is set at beginning of the trajectory (t_{1}), the time reference is earlier than the current time (t > t_{1}).
Expected behavior:

If the
followingMode
isposition
, the entity behaves as if the trajectory starts at the position interpolated between the most recent time reference and the earliest future time reference. The entity teleports to that position and continues along the trajectory. 
If the
followingMode
isfollow
, the entity starts steering towards the trajectory, aiming to hit the first referenced point in the future and taking into consideration the performance limitations.
6.9.4 Entity is at an ambiguous point near the trajectory
Starting conditions:

The entity is located in vicinity to more than one waypoint or segment connecting the waypoints.
Expected behavior:

The entity joins at the first possible segment, according to the userdefined orientation of the trajectory and respecting time references, if given. See section on Section 6.8, "Routes" and previous points in this section.
6.9.5 Trajectoryrelative positions
Trajectoryrelative positions may be defined using TrajectoryPosition
, which define a position relative (and potentially offset) to the path of the trajectory. See Figure 21 for an example position along a linestringdefined trajectory.