An error while using polyxpoly for finding (xi,yi) of an intersecting line and circle
2 views (last 30 days)
I need to connect point 2 and point 1 and find all the intersecting points(between red line and blue line/circle), So, I used polyxpoly. My problem is why polyxpoly function generates an extra intersecting point which is not on the line or the circle (I show it in the below image)?
% line coordinates
% Circle coordinates
xcenter = 2;
ycenter = 2;
radius = 1;
circr = @(radius,rad_ang) [radius*cos(rad_ang)+xcenter; radius*sin(rad_ang)+ycenter];
N = 2000;
rad_ang = linspace(0, 2*pi, N);
xy_r = circr(radius,rad_ang);
x_circle= radius * cos(rad_ang) + xcenter;
y_circle= radius * sin(rad_ang) + ycenter;
% all points
% I want to calculate the intersection coordinates between a line contacting curret point/next point and
Pratyush Roy on 1 Oct 2020
The x co-ordinates as well as the y co-ordinates of the line and the circle should not be combined as this generates a complicated polygon and a new solution is found other than the expected ones.
As a workaround one can use the polyxpoly function twice to generate two sets of solutions which together will provide the expected solution.
Here [xi,yi] will give us the points of intersection between the line and the circle and [xj,yj] will give us the point of intersection between the two lines.
Hope this helps!