Reputation:
I want to calculate the intersect point between arc and line. I have all the data for line and arc.
For line : start and and end point.
For arc : start/end point, start/end angle, radius and center point.
I have attach here one image. In this below image I have draw one arc and line where line intersect the arc.
So now I want to find the intersect point. Please give me some algorithm or idea or if any available code.
Upvotes: 9
Views: 11142
Reputation: 289
Let's define an arc and a line:
Arc:
Line:
From that you can calculate:
The arc and the line won't intersect when al < a1 or al > a2 or, in other words, the angle of the line isn't between the angles of the arc. The equations for an intersection are as follows:
where c (0 < c <= 1)is the variable we're looking for. Specifically:
The intersection point is therefore at (x1+c * dx),(y1+c * dy)
This algorithm only works when the arc and the line have one single intersection. If the line goes through the arc two times then it won't register any intersection.
Upvotes: 4