Main Content

addParametricCubic

Add new parametric cubic segment to horizontal curve of segmented road

Since R2025a

    Description

    addParametricCubic(segmentedCurve,startTangentLength,endPosition,endTangent) creates a new parametric cubic segment and adds it to the end of the horizontal curve of the segmented road specified by segmentedCurve. A parametric cubic segment is a smooth, curved road segment whose path is defined using parametric cubic equations. The parametric cubic equation enables precise control over these attributes of the road segment:

    • The start and end points.

    • The direction (tangent) at each end.

    • The smoothness and curvature along the path.

    example

    Examples

    collapse all

    Create a roadrunner object, specifying the path to an existing project. For example, this code shows the path to a project, on a Windows® machine, located at "C:\RR\MyProject". This code assumes that RoadRunner is installed in the default location, and returns an object, rrApp, that provides functions for performing basic tasks such as opening, closing, and saving scenes and projects.

    rrApp = roadrunner(ProjectFolder="C:\RR\MyProject");

    Note

    If you are opening RoadRunner from MATLAB® for the first time, or if you have changed the RoadRunner installation location since you last opened it from MATLAB, you can use the roadrunnerSetup function to specify new default project and installation folders to use when opening RoadRunner. You can save these folders between MATLAB sessions by selecting the Across MATLAB sessions option from the corresponding drop down.

    Create a new scene in RoadRunner by using the newScene function, specifying the roadrunner object rrApp.

    newScene(rrApp)
    

    Create a RoadRunner authoring API object, rrAPI, that references the object for the current RoadRunner instance rrApp. The rrApi object enables you to programmatically author scenes, such as by adding and modifying road and lane components, using MATLAB.

    rrApi = roadrunnerAPI(rrApp);
    
    Extract the object for your scene from the Scene property of the authoring API object rrApi. The extracted Scene object enables you to specify the scene in which to add scene components, such as roads and lanes.
    scn = rrApi.Scene;

    Specify the control points of the starting point forward direction of a road as positions along the X- and the Y- axes of the RoadRunner local coordinate system. Then, use the addSegmentedRoad function to add a segmented curve type road to the scene.

    startPoint = [-100 0];
    startRoadDirection = [1 0];
    rrRoad = addSegmentedRoad(scn,startPoint,startRoadDirection);

    Extract the horizontal curve of the segmented road. Then, use the addParametricCubic function to create a parametric cubic segment and add it to the horizontal curve. Specify the length of the starting tangent, the end position of the segment, and the end tangent.

    segmentedCurve = rrRoad.HorizontalCurve;
    startTangentLength = 30;
    endPosition = [20 30];
    endTangent = [23 -45];
    addParametricCubic(segmentedCurve,startTangentLength,endPosition,endTangent);

    Input Arguments

    collapse all

    Horizontal curve of a segmented road, specified as a SegmentedRoadCurve object.

    Tangent length at the start of the new parametric cubic segment, specified as a numeric scalar. Units are in meters.

    startTangentLength controls how sharply or gently the curve begins. A longer tangent means the curve travels farther in that direction before bending. A shorter tangent creates a tighter, more immediate curve.

    Data Types: double

    Position of the control point for the end of the parametric cubic segment, specified as a two-element vector. The first and second elements of endPosition specify the coordinates on the X- and Y- axes, respectively, where the curve ends in RoadRunner local coordinate system.

    Data Types: double

    End tangent of the new parametric segment, specified as a two-element vector.

    The endTangent represents the direction and rate of change of the curve at the end point. The direction defines the outward end of the road.

    Data Types: double

    Version History

    Introduced in R2025a