%% Connect Two Roads Using Heading Angles
% Create a driving scenario containing two curved roads to connect. Specify the heading angles of each road center to fine-tune the shape of the road at the connecting region.
% Create an empty driving scenario.

scenario = drivingScenario;

% Add two roads to the driving scenario by defining their road centers and road heading angles.

% Add the first road
roadCenters = [-7 20; 0 0; 30 0; 30 -20; 10 -30];
roadHeadings = [-90; 0; NaN; NaN; -90];
laneMark = laneMarking('Solid');
laneSpecification = lanespec(2,Marking=laneMark);
road(scenario,roadCenters,'Lanes',laneSpecification, ...
    'Heading',roadHeadings,'Name','Road 1');

%Add the second road
roadCenters = [10 -30; 30 -40; 30 -60; 0 -60; -7 -80];
roadHeadings = [-90; NaN; NaN; 180; -90];
laneMark = laneMarking('Dashed');
laneSpecification = lanespec(2,Marking=laneMark);
road(scenario,roadCenters,'Lanes',laneSpecification, ...
    'Heading',roadHeadings,'Name','Road 2');

% Plot the scenario.

plot(scenario,'RoadCenters','on')

% Copyright 2020 The MathWorks, Inc.