Reputation: 885
I am looking for some assistance on creating an algorithm that is able to calculate a bounding box for an arc. Typically, this would be a simple problem. However, I am required to have one of the edges of the box to be the line that connects the starting point and the ending point of the arc.
I am having difficulty in developing an algorithm that is able to compute the additional two points of the rectangle.
Here is a picture of what I am attempting to calculate:
The two purple dots, I need to develop an algorithm that will determine these two locations. The green dots are the known points that can be inputs. Additionally, I do know the radius and the center of the arc.
I would need the algorithm to handle the different cases for when line AB is vertical, has a + slope, and has a - slope.
I have been considering a few directions. For example, I know that the line through point E is parallel to line AB. Since it is parallel, that means they will have the same slopes and the line from point A to the purple point is perpendicular to this line. I can then consider the intersection point of the line through E and this perpendicular line.
This method seems messy because then I would need to consider the cases for when the slope of line AB is infinite and 0. I am wondering if there is some algorithm that could account for that automatically (or not even consider the slope at all for line AB)
Upvotes: 0
Views: 239
Reputation: 36702
You claim to know points A
, B
, C
, D
, E
, and that the amplitude of the sustaining angle of the circular arc does not exceed 180° (semi circle).
Let P1
, and P2
, the two points that complement the bounding box - (in the drawing, P1
is the purple point above A
, and P2
the one above B
).
E-C = vector perpendicular to segment AB', i/e subtract C from E; its magnitude is equal to the distance EC
.
P1 = A + (E-C)
P2 = B + (E-C)
Bounding Box = Rectangle A
, P1
, P2
, B
If you need a closer fit, you can replace vector (E-C)
with vector (D-C)
to place the bounding segment P1P2
tangent to D
Upvotes: 1