0
votes

I am searching for an algorithm which can shows line and arc intersected or not. For line I have start and end point and for arc I have start, end and center point. I also have start and end angle of an ARC.

enter image description here

As you can see in the above image I have draw an arc and line where as both are intersected. How to calculate that intersected or not?

I found one link which can shows the intersection between line and circle Circle Line Intersection points but in my case I have line and arc. Even I also have another question what is best way to calculate the intersection between two ARC?

Any suggestion?

1
stackoverflow.com/questions/30006155/… i guess if solution exists, then they intersectuser2707389

1 Answers

0
votes

By equating the parametric equations of the line and the circle,

X = Sx + t SEx = Cx + R cos(u)
Y = Sy + t SEy = Cy + R sin(u)

which can be written

 t SEx + CSx = R cos(u)
 t SEy + CSy = R sin(u)

You eliminate u by adding the squares

(SEx² + SEy²) t² + 2 (SEx.CSx + SEy.CSy) t + CSx² + CSy² - R² = 0

Solve the quadratic equation for t and check 0<t<1 (there can be two solutions).

Then compute X and Y and from these

tan(u) = (Y - Cy) / (X - Cx)

(use atan2). Then check that u is in the valid range.


For two arcs,

C0x + R0 cos(u) = C1x + R1 cos(v)
C0y + R0 sin(u) = C1y + R1 sin(v)

or

Dx + R0 cos(u) = R1 cos(v)
Dy + R0 sin(u) = R1 sin(v)

Summing the squares,

2R.Dx cos(u) + 2R.Dy sin(u) + Dx² + Dy² + R0² = R1²

Divide by 2R√(Dx²+Dy²) to put in the form

c cos(u) + s sin(u) = e

which can be written as

cos(u-w) = e, where tan(w) = s/c

Then

u = w ± arcos(e) 

gives you the potential intersections.