Main Content

addSpiral

Add new spiral segment to horizontal curve of segmented road

Since R2025a

    Description

    addSpiral(segmentedCurve,length,startCurvature,endCurvature) creates a new spiral segment and adds it to the end of the horizontal curve of the segmented road specified by segmentedCurve. A spiral segment is a road or a part of the road that follows a curved, spiraling path. The function creates the segment by interpolating between the specified start and end curvatures over the length of the segment. This interpolation creates a smooth transitional curve that gradually changes curvature from the start value (such as 0, for a straight line) to the end value (1/R for a circular arc of radius R).

    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 addSpiral function to create a spiral segment and add it to the horizontal curve. Specify the length of the spiral segment as 30 m, the start curvature as 1/20 m, and the end curvature as 1/15 m.

    segmentedCurve = rrRoad.HorizontalCurve;
    addArc(segmentedCurve,30,1/20,1/15)

    Input Arguments

    collapse all

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

    Length of the new spiral segment, specified as a numeric scalar. Units are in meters.

    Data Types: double

    Start curvature of the new spiral segment, specified as a numeric scalar in reciprocal meters (1/m). Curvature is defined as the reciprocal of the radius (1/radius). For example, a spiral with a 50 m radius has curvature as 1/50. Positive and negative curvature values indicate curves to the right and left, respectively.

    This represents the curvature of the path at the beginning of the spiral segment. If the spiral segment starts from a straight road, then its startCurvature is 0 because a straight line has no curvature. If the spiral starts from a curved section, then the startCurvature is 1/R, where R​ is the radius of the initial curved segment.

    Data Types: double

    End curvature of the new spiral segment, specified as a numeric scalar in reciprocal meters (1/m). Curvature is defined as the reciprocal of the radius (1/radius). For example, a spiral with a 50 m radius has curvature as 1/50. Positive and negative curvature values indicate curves to the right and left, respectively.

    This represents the curvature at the end point of the spiral segment, where the segment typically connects to a circular arc or another curve. The end curvature is the value the spiral reaches after transitioning from the start curvature.

    Data Types: double

    Version History

    Introduced in R2025a