#### Archived

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

# box-cone intersection?

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

## Recommended Posts

Hi! I need to compute if a bouding box intersects a cone of a spotlight. I couldn''t find any info abou this anywhere. I need this to determine if a mesh is affected by a light(spotlight). Could you help me with this? Thanks in advance

##### Share on other sites
Be warned, I''m just spouting musings on the subject... (read: no idea what I''m talking about)

Perhaps you could do a test for the closest distance and nearest points of all the edge lines of the bounding box and the central line of the cone. Using the nearest point of the cone-centre line to each bounding box line, get the radius of the cone at that point, and check if the bounding box line is closer than that.

It might be easier to use a bounding sphere instead of a bounding box in this case... as you could check the distance from the centre of the sphere to the cone-centre line, and then get the radius of the cone and compare. I assume conversion from box to sphere would be fairly simple, just for that test...

##### Share on other sites
I don''t think there is a definitive algorithm for that. However, you can use the GJK algorithm, which works for any types of convex objects.

an example of the algo

Geometric Interpretation and Comparisons of Enhancements of GJK

##### Share on other sites
quote:
Original post by Geoff the Medio
Perhaps you could do a test for the closest distance and nearest points of all the edge lines of the bounding box and the central line of the cone. Using the nearest point of the cone-centre line to each bounding box line, get the radius of the cone at that point, and check if the bounding box line is closer than that.

Yeh that sounds like a good plan... Here is how to get the closest distance between two lines:

http://astronomy.swin.edu.au/~pbourke/geometry/lineline3d/

I just have one concern with this technique, i don''t think it is completely full-proof... the edge of the bounding box may intersect with the cone at a point that is not the closest distance between the two lines where the cone radius is larger, its hard to explain. It should be fine with a cylinder though, apart from if the cone or cylinder completely penetrates two opposite faces without intersecting with the edges.

##### Share on other sites
quote:
Original post by SpaceDude
the edge of the bounding box may intersect with the cone at a point that is not the closest distance between the two lines where the cone radius is larger, its hard to explain.

Good point...
|      /|   | /|   |/|   /|  /|| / *|/

If the right | line was angled slightly, the * would be the closest point, to the left | line, which would be the centre of the cone, but the right | line still cross the / line, so the box intersects the cone...

The bounding sphere test could have a similar problem...

Could you calculate the plane of the cone centreline and the centre point of the bounding sphere, find the line where the cone edge intersects that plane and the circle where the bounding sphere is cut by the plane and then do an intersection test between the circle and line?

##### Share on other sites
As long as you are using a bounding box for the mesh couldn''t you use a bounding frustrum for the cone?

1. 1
Rutin
41
2. 2
3. 3
4. 4
5. 5

• 16
• 18
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633360
• Total Posts
3011524
• ### Who's Online (See full list)

There are no registered users currently online

×