Reputation: 69
I am trying to get the x and y coordinate an outline produces by two or three intersecting circles as shown in the figure. Coordinate of the two circles are available below.
How can we do this automatically using Matlab?
I have hundreds of figures like this.
What I want is just to get the x and y coordinate of the final shape.
X Y
================
1.0000 0
0.9848 0.1736
0.9397 0.3420
0.8660 0.5000
0.7660 0.6428
0.6428 0.7660
0.5000 0.8660
0.3420 0.9397
0.1736 0.9848
0.0000 1.0000
-0.1736 0.9848
-0.3420 0.9397
-0.5000 0.8660
-0.6428 0.7660
-0.7660 0.6428
-0.8660 0.5000
-0.9397 0.3420
-0.9848 0.1736
-1.0000 0.0000
-0.9848 -0.1736
-0.9397 -0.3420
-0.8660 -0.5000
-0.7660 -0.6428
-0.6428 -0.7660
-0.5000 -0.8660
-0.3420 -0.9397
-0.1736 -0.9848
-0.0000 -1.0000
0.1736 -0.9848
0.3420 -0.9397
0.5000 -0.8660
0.6428 -0.7660
0.7660 -0.6428
0.8660 -0.5000
0.9397 -0.3420
0.9848 -0.1736
1.0000 -0.0000
The coordinate of the smaller circle:
x y
================
1.4000 0
1.3939 0.0695
1.3759 0.1368
1.3464 0.2000
1.3064 0.2571
1.2571 0.3064
1.2000 0.3464
1.1368 0.3759
1.0695 0.3939
1.0000 0.4000
0.9305 0.3939
0.8632 0.3759
0.8000 0.3464
0.7429 0.3064
0.6936 0.2571
0.6536 0.2000
0.6241 0.1368
0.6061 0.0695
0.6000 0.0000
0.6061 -0.0695
0.6241 -0.1368
0.6536 -0.2000
0.6936 -0.2571
0.7429 -0.3064
0.8000 -0.3464
0.8632 -0.3759
0.9305 -0.3939
1.0000 -0.4000
1.0695 -0.3939
1.1368 -0.3759
1.2000 -0.3464
1.2571 -0.3064
1.3064 -0.2571
1.3464 -0.2000
1.3759 -0.1368
1.3939 -0.0695
1.4000 -0.0000
Upvotes: 1
Views: 107
Reputation: 60444
If you have MATLAB R2017b or newer, use the new polyshape
type. These have a union
and intersect
methods (the question refers to "intersecting curves", but I have the feeling you are looking for the union of the two shapes). This would look like:
p1 = [
1.0000 0
0.9848 0.1736
0.9397 0.3420
0.8660 0.5000
0.7660 0.6428
% ... etc.
];
p2 = [
1.4000 0
1.3939 0.0695
1.3759 0.1368
1.3464 0.2000
1.3064 0.2571
% ... etc.
];
p1 = polyshape(p1);
p2 = polyshape(p2);
p3 = union(p1,p2);
You can plot your shapes using plot
:
plot(p1)
hold on
plot(p2)
plot(p3)
axis equal
Upvotes: 1