MATLAB Answers

Intersection sensor Polygon and the road points (curves)

1 view (last 30 days)
Samia Nassir
Samia Nassir on 20 Mar 2019
I wrote this code with the help of my friends to get Intersections of polygons and curves.
i now want the total time and the time increase with call the function and how can i call the function in matlab.
for the intersection i used the InterX function ,can you tell me please how can i use the Polyxpoly funktion in this case ,i found in my execusion no intersections also when i want only drawing the sensor polygon i got no result
my code:
roadRadiusM = 300;
roadOriginM = [0,roadRadiusM,0];
roadSegmentM = [-60,-10];
roadRadiusN = 280;
roadOriginN = [0, roadRadiusM, 0];
roadSegmentN = [-60,-10];
tM = linspace(roadSegmentM(1),roadSegmentM(2),8);
xlimitM = roadRadiusM*cosd(tM)+roadOriginM(1);
ylimitM roadRadiusM*sind(tM)+roadOriginM(2);
plot(xlimitM, ylimitM, 'r')
tN = linspace(roadSegmentN(1),roadSegmentN(2),8);
xlimitN = roadRadiusN*cosd(tN)+roadOriginN(1);
ylimitN = roadRadiusN*sind(tN)+roadOriginN(2);
plot(xlimitN, ylimitN, 'r')
xlimit = [xlimitM, NaN, xlimitN];
ylimit = [ylimitM, NaN, ylimitN];
% two sensor
fovLengthA = 300;
fovOriginA = [-40,30,0];
fovAngleA = 12;
fovLengthB = 200;
fovOriginB = [-10,50,0];
fovAngleB = 35;
[xFoVA, yFoVA] = CircleArc(-1/2*fovAngleA, 1/2*fovAngleA, fovOriginA, fovLengthA);
[xFoVB, yFoVB] = CircleArc(-1/2*fovAngleB, 1/2*fovAngleB, fovOriginB, fovLengthB);
patch('XData', xFoVA, 'YData', yFoVA,...
'FaceColor', 'none', 'EdgeColor', 'r',...
'LineStyle', '-');
patch('XData', xFoVB, 'YData', yFoVB,...
'FaceColor', 'none', 'EdgeColor', 'g',...
'LineStyle', '-');
A = InterX([xlimit; ylimit], [xFoVA; yFoVA]);
B = InterX([xlimit; ylimit], [xFoVB; yFoVB]);


Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!