Archived

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

TheJakub

Ray-Plane

Recommended Posts

I just started lookin at collision detection algorithms a few days ago and I was wondering if I could get some help with it. I pretty much think i understand ray-plane detection. But, where exactly does the ray come from in the first place. It would be nice if someone could give me a nice explanation, it would be much appreciated.

Share this post


Link to post
Share on other sites
depends. For ray-tracing, the rays originate from the camera viewpoint. For collision detection, they are the position of a particle when you fired a ray (like the muzzle position of your gun when firing a bullet). Rays are usually starting from a position, as you say, and can have a maximum length. They can be defined by two end points, like a segment in 3D space.

Theoretically, a ray can be totally infinite, and have no start position. It''s just an equation. Like planes, that extend to infinity. They can be totally abstract. Although A ray with no frame of reference seems to be unpractical.

the equation for solving a ray-plane intersection is

t = ((APointOnPlane - APointOnRay) * PlaneNormal) / (RayDirection * PlaneNormal).

so, the point on ray and the point on plane can be anything (on the plane and the ray, respectively, of course). ''t'' will tell you how far the plane is from PointOnRay along the RayDirection, and the point of intersection is then

PointOnPlaneAndRay = APointOnRay + RayDirection * t

so you do need a frame of reference at some stage. Note that, for the equations above, RayDirection does not need to be a unit vector (of magnitude = 1.0f), but it''s more practical to use a unit length vector most of the time.

Share this post


Link to post
Share on other sites
I think you should post such threads in the math/physics section.
BTW that''s really trivial 3D maths. Read what''s already available in Gamedev before asking such simple questions. They have so many tutorials for beginners.

Share this post


Link to post
Share on other sites
Thanks oliii for the answer. You were of much help. And yeah, it would have worked in a Math/Physics forum, but it also works in "Game Programming" because collision detection is a game programming topic. Math wasn''t ever my strongest area. I''m pretty much average in that department. I use more of the artistic side of my brain;-)

Share this post


Link to post
Share on other sites