Skip to main content
gamedev.net
🔒 Locked

Ray Rectangle Intersection

Started by Galapaegos 1 reply 4.1k views
Original Post
Galapaegos
Galapaegos
Hey guys, For a class we are writing a raytracer, and we are currently trying to extend the different objects we can intersect from only spheres to cubes and rectangles. Were not quite sure how to approach this problem. We were told some theory about "slabs", but it isn''t very helpful. Does anyone have any suggestions on how to implement this kind of intersection? Thanks for the help! -brad
-brad
LinaInverse2010
LinaInverse2010
I don't think your suppose to ask questions for classes here, since it would probably be better to figure it out yourself. But here is a hint to do it a simple way, use plane intersections. From there it is really easy to do a rectangle intersection, and a cube one is basically the same, just with more planes.

Of course, there are also hundreds of resources on the web for ray intersections tests. Check this site out too: www.magic-software.com

LinaInverse

[edited by - LinaInverse2010 on November 20, 2003 9:29:59 AM]
oliii
oliii
I published an algo (well, two) for segment rectangle in 2D. For 3D, it''s te same principle, but with an extra axis.

Basically, clip the ray with 2 parallel planes of th rectangle/cube, and clip what''s left with the other planes.

Or you can use the separating axis theorem.

Segment rectangle intersection
Everything is better with Metal.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.