trajectory
Create actor or vehicle trajectory in driving scenario
Syntax
Description
The trajectory function creates a trajectory based on
            either the speed values or arrival times of an actor at each waypoint. By default, the
            function creates a trajectory for a vehicle whose steering location is at its rear axle.
            To create a trajectory for a vehicle whose steering location is at its front axle, use
            the  ReferenceSteerPosition name-value argument.
Trajectory from Actor Speed Information
trajectory(
                    creates a trajectory for an actor or vehicle, ac,waypoints)ac, from a
                    set of waypoints. 
Note
The trajectory function generates trajectories that have
                            discontinuities in acceleration between waypoints, resulting in high
                            amounts of jerk. To generate a smooth, jerk-limited trajectory, use the
                                smoothTrajectory function instead.
trajectory(___,
                    specifies options using one or more name-value arguments in addition to any
                    combination of arguments from the previous syntaxes. For example,
                        Name=Value)Course=course specifies the course angle
                        course, which defines the steering direction of the actor
                    or vehicle at each waypoint.
Trajectory from Actor Arrival Times
Since R2024b
trajectory(
                    creates a trajectory for an actor or vehicle, ac,waypoints,TimeOfArrival=timeOfArrival)ac, from a
                    set of waypoints, waypoints, using the arrival time of the
                    actor at each waypoint timeOfArrival.
trajectory(
                    specifies options using one or more name-value arguments. For example,
                        ac,waypoints,TimeOfArrival=timeOfArrival,Name=Value)MotionDirection=motionDirection specifies the direction
                        motionDirection for the actor to move at each
                    waypoint.
Examples
Input Arguments
Name-Value Arguments
Tips
- To get the position of the vehicle with reference to a specific vehicle body location, use the - getReferencePositionfunction.
- If a driving scenario contains a front-axle trajectory for at least one vehicle, you can get the front-axle position from the - FrontAxlePositionfield of the- ActorPosesstructure returned by the- recordfunction.
- If a driving scenario contains a front-axle trajectory, to plot both the rear-axle and front-axle trajectories, specify the - ShowRearAxlename-value argument of the- plotfunction as- "on".
Algorithms
The trajectory function creates a trajectory for an actor to
            follow in a scenario. A trajectory consists of the path followed by an object and its
            speed along the path. You specify the path using N two-dimensional or
            three-dimensional waypoints. Each of the N – 1 segments between
            waypoints defines a curve whose curvature varies linearly with distance along the
            segment. The function fits a piecewise clothoid curve to the
                (x, y) coordinates of the waypoints by
            matching the curvature on both sides of the waypoint. For a nonclosed curve, the
            curvature at the first and last waypoint is zero. If the first and last waypoints
            coincide, then the curvatures before and after the endpoints are matched. The
                z-coordinates of the trajectory are interpolated using a
            shape-preserving piecewise cubic curve.
The generated trajectory results in a piecewise constant-acceleration profile for each
            segment between waypoints. These segments have acceleration discontinuities between
            them. To avoid discontinuities in acceleration, use the smoothTrajectory function to generate trajectories instead.





