DevX Home Today's Headlines   Articles Archive   Tip Bank   Forums

# Thread: Line Secment Crossing Arc

1. Guest

## Line Secment Crossing Arc

I have an Arc from Angle A to Angle B of Radius R, Center at 0,0

I have a line segment P1 P2 that may or may not intersect said Arc.

It might cross once, twice, not at all or be tangent.

How can I find the coordinate of the crossing (and if it does).

Thanks

Tom  Reply With Quote

2. Douglas Abernathy Guest

## Re: Line Secment Crossing Arc

Hmmm... this questions should probably be in rec.math.homework. Whatever...

You can first determine if the line crosses the circle containing your arc,
by solving the two equations in two unknowns; the equation of the line
segment containing P1 and P2, and the equation of the circle centered at
(0,0) with radius R. Hint: solve the line equation as y=mx+b (as long as the
line is not vertical, in which case the test becomes even easier), then
substitute the value "mx + b" for "y" in the circle equation. You will have
one equation in "x" that either has no solutions (which means the line
doesn't cross the circle, hence the arc, at all), 1 solution (in which case
the line is tangent to the circle at a point, but still may not cross the
arc), or two solutions (from the quadratic equation of the circle), giving
you the two places where the line crosses the circle. For each solution x,
you can determine the angle of the circle at that point because the
coordinates (x,y) are equivalent to (R*cos(theta), R*sin(theta)). By taking
an arcsin or arccos (which, by the way, doesn't exist in VB, you will have
to make a substitution and use the atan function), you can determine if the
point (x,y) is on the arc, by comparing the angle theta with the endpoints A
and B. Piece of cake. Well, a tough piece of cake to code.

Douglas Abernathy
Mathematician at Large

<73215.427@compuserve.com> wrote in message news:38ea512b\$1@news.devx.com...
> I have an Arc from Angle A to Angle B of Radius R, Center at 0,0
>
> I have a line segment P1 P2 that may or may not intersect said Arc.
>
> It might cross once, twice, not at all or be tangent.
>
> How can I find the coordinate of the crossing (and if it does).
>
> Thanks
>
> Tom
>
>
>  Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
• 