Jump to content
• Advertisement

# Ray - cone intersection

This topic is 4901 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

Hi, I'm trying to come up with a technique for determining whether a ray intersects a cone. The cone is truncated, i.e. one of the ends does not necessarily have a radius of zero, and the cone is not based at the origin. I'm having real trouble with this at the moment because I've been unable to locate any really useful resources on the net and there aren't any similar topics on this forum. The best thing I've found so far is the following:- www.bmsc.washington.edu/people/merritt/graphics/quadrics.html Which doesn't go into much detail. Can anyone please help?

#### Share this post

##### Share on other sites
Advertisement
Do I sense volumetric spot lighting coming? :D

#### Share this post

##### Share on other sites
One reference on the topic can be found here.

This particular algorithm intersects a linear component with an infinite cone represented by an origin, a unit-length axis, and the angle between the axis and the cone wall. You end up with a quadratic that you can solve using the usual methods to find the points of intersection.

For your purposes you may have to adapt this algorithm a little. Ignoring the truncated aspect for the moment, you may be representing your cone with a length from tip to base and a radius at the base, rather than with an interior angle. If so, you can replace the cos(theta)2 terms in the quadratic with:

length2/(radius2+length2)

For a capped (not infinite) cone, you have to catch the cases where the ray passes through the cap and find those intersection points as well. Additionally there are a few degenerate cases that must be handled, such as the ray lying in or running parallel to the cone wall.

Truncating the top of the cone adds further complexity. One solution would be to find the point along the cone axis where the radius of the infinite cone equals the smaller of your two cone radii. This then becomes another clipping plane for the ray, and another endcap with which you must intersect.

At the moment I happen to be working on code for intersection of a linear component and a cone (capped, but not truncated). I'm not done with it yet, otherwise I'd post the code for you. But since I'm also working on this problem, I'll be glad to offer further help if you get stuck.

(Also, it looks like you're interested in a boolean-only test. If you don't need the actual points of intersection, the code can be simplified somewhat.)

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
Rutin
17
4. 4
5. 5
• Advertisement

• 14
• 9
• 10
• 12
• 17
• ### Forum Statistics

• Total Topics
632906
• Total Posts
3009155
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!