# How do I test for intersection of a ray and part of a capped cone / cone frustum?

The formulas to calculate the intersection between a ray and a capped cone / cone frustum are already widely known (see http://lousodrome.net/blog/light/2017/01/03/intersection-of-a-ray-and-a-cone/ or How do I test for intersection between a ray and a cone?) However, I have to test for the intersection between a ray and part of a capped cone. That means instead of having a surface doing a full revolution, it's just one quarter of it, for example.

The aforementioned formulas can handle a capped cone, but they are not suitable to determine the "revolution intersection angle". What would be the best way to solve this problem?

My idea is to first take the standard formula to intersect with the full cone and then use the parametric representation of the cone (see https://de.wikipedia.org/wiki/Kegel_(Geometrie)#Analytische_Beschreibung parametric representation is only on the German page), solve a linear equation system and then applying the inverse trigonometric functions to get the t parameter... I'm also thinking about some inequality tricks or applying the tangent function, but had no luck so far...

• Do you mean like this? imgur.com/bfvptZ8.png – Jay Mar 8 '19 at 0:16
• @Jay Yes exactly. Just that the 90° angle is arbitrary and I'm just interested in the intersection with the lateral surface (basically no volume but just the lateral surface) – java4ever Mar 8 '19 at 0:19

## 1 Answer

I would solve this by using the following steps:
1. Determine the points of ray-cone intersection
2. Filter out the points that are in range of a segment

You already have the first part, so using that get a list of candidate points. For each point, calculate the vector from the axis of the cone to the point (call this D).

You should also have two vectors that represent the segment. These should be vectors in the plane described by the axis of the cone, and rotated at angles representing the part to collide with. Call these A and B.

Using the solution here https://stackoverflow.com/questions/13640931/how-to-determine-if-a-vector-is-between-two-other-vectors, you can use:

if (AxD * AxB >= 0 && BxD * BxA >= 0)
// D is between A and B


where x represents the cross product.

• Thanks very much for your idea, with some transformation magic for arbitary cones, this works (almost) perfect... However, this solution breaks down when the revolution angle of the cone is >180°... Currently looking for a solution – java4ever Mar 9 '19 at 23:26
• I figured out a solution for this... if the revolution angle is > 180°, just invert the "isBetween" result – java4ever Mar 9 '19 at 23:46
• Nice work. Glad you solved it. – Jay Mar 10 '19 at 0:40