# trajectory

Create actor or vehicle trajectory in driving scenario

## Syntax

## Description

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

## Examples

## Input Arguments

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

## Version History

**Introduced in R2018a**