Archived

This topic is now archived and is closed to further replies.

Endemoniada

Ray-Arc Intersection ?

Recommended Posts

Endemoniada    430
Hi guys, I need to find out if a ray intersects an arc and if so where. Is that possible ? My arc is a perfect quarter-circle and the ray comes in from the outside (opposite the rays from the center of the circle to the edge.) Also, the two straight sides of the arc are aligned with the X and Y axes, I''m doing this in 2D as well. For the last three hours I''ve been using graph paper and one of those things the architects use to trace circles with and it looks like this will solve all my problems. Thanks for all the help in the past.

Share this post


Link to post
Share on other sites
mohamed adel    174
if the center of the circle from which the arc was cut is (a,b) and the radius of the arc is r then the arc's equation is (x-a)^2+(y-b)^2=r^2 where a<=x<=r+a ,b<=y<=b+r (asuuming that the arc is alignied in the positive x and y directions) .so find the point of intersection of the ray with the arc using the equation of the ray and the equation of the arc,if the point of intersection is (c,d)then you can use the following code to test if the ray intersects the arc or not
if (c>=a&c<=(r+a))
{
if (c>=b&c<=(r+b))
{
the point of intersection is (c,d)
}
else
{
there's no intersection
}
}
else
{
there's no intersection
}


the ray's equation can be found as follows
if the ray is passing through points (x1,y1) and (x2,y2) then the ray's equation is y-y1/x-x1=y2-y1/x2-x1

[edited by - mohamed adel on July 7, 2003 4:12:10 AM]

Share this post


Link to post
Share on other sites