Reputation: 4192
I am playing around with graphics, specifically the intersection and union of primitive shapes.
Given the following:
Elipse2D e1 = new Elipse2D.Double(120, 80, 80, 80);
Elipse2D e2 = new Elipse2D.Double(180, 80, 80, 80);
Area a1 = new Area(e1);
a1.add(new Area(e2));
gfx.draw(a1); // gfx is a Graphics2D object
This gives a very nice shape that looks like a 1st-person eye-view from binoculars in some 90's action movie.
However, I was wondering if it was possible to draw a line between the two intersection points so that is looks almost like two cells busy dividing. After doing this with two circles, is this possible with multiple circles, perhaps?
I know this can be done by finding the intersection points between the two circles and drawing the lines manually, however, I do not want to reinvent the wheel.
Any suggestions?
Upvotes: 0
Views: 366
Reputation:
Given the parameterization of these Ellipse2D
, the equations can be written as:
x(r) = X + W (cos(r) + 1)/2
y(r) = Y + H (sin(r) + 1)/2
x(s) = X + W' (cos(s) + 1)/2
y(s) = Y + H (sin(s) + 1)/2
The y
equations allow to conclude that the angles r
and s
have the same sine and are supplementary (equal angles would not satisfy the x
equations), so that cos(s)=-cos(r)
.
After elimination, we have (W'+W) cos(r) = W'-W
. In the given case, cos(r)=1/5
and r=78.463°
.
Upvotes: 1