Ray/Plane Intersection Point

Member
Posts: 153
Joined: 2004.12
Post: #1
How can i find the point of intersection between a ray and a plane?

There was a long silence...
'I claim them all,' said the Savage at last.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
Quote this message in a reply
Member
Posts: 153
Joined: 2004.12
Post: #3
Let me rephrase: The current algorithm that i am using is inaccurate (or the way i implemented it is inaccurate). I assume that most of you calculate this somehow in your games. Would anybody be so kind as to post the algorithm that you use, or describe the mathematical steps that it follows.

OSC's response, although cute, is totally useless to me, but more importantly totally useless to whoever might read this thread later.

There was a long silence...
'I claim them all,' said the Savage at last.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
My response is appropriate to the question. If you've done as much as you say, you should put some of that information in the question to avoid responses like that.

Why don't you post some code, or your current algorithm?
Quote this message in a reply
Member
Posts: 153
Joined: 2004.12
Post: #5
That response was appropriate to the question.

I have two points, bPoint (before the transformation) and aPoint (after the transformation) Im testing to see if my transformation is valid (doesnt collide)
I calculate the distance to the plane for both points. "if the distances are opposite in there signed values." (one is positive and one is negative or vica versa) I continue to check the exact point on the plane that the ray intersects.

Code:
//nx = plane normal x, ny = plane normal y, nz = plane normal z
//distance2 = distance from aPoint to plane

//find ray direction
float rdx = [aPoint x] - [bPoint x];
float rdy = [aPoint y] - [bPoint y];
float rdz = [aPoint z] - [bPoint z];

//a = N.RayDirection
float a = (nx * rdx) + (ny * rdy) + (nz * rdz);

//IntersectinoPoint = aPoint - RayDirection * (distanceToPlane(aPoint)/a)
float ix = ([aPoint x] - rdx) * (distance2 / a);
float iy = ([aPoint y] - rdy) * (distance2 / a);
float iz = ([aPoint z] - rdz) * (distance2 / a);

There was a long silence...
'I claim them all,' said the Savage at last.
Quote this message in a reply
Nibbie
Posts: 2
Joined: 2006.10
Post: #6
I'm sure that I'll later regret this, but here goes.

Let r(t) = p + v*t be the equation of your ray. Let n be the plane normal and q be a point on the plane. Then any point x on the plane satisfies the equation

n . (q - x) = 0.

So substitute the ray equation r(t) in for x and solve for t:

n . (q - r(t)) = 0
n . (q - p - v*t) = 0
n . (q - p) = (n . v) * t
t = [ n . (q - p) ] / (n . v)


Then plug t back into the ray equation to find your point of intersection.
Quote this message in a reply
Member
Posts: 153
Joined: 2004.12
Post: #7
So for clarification in pseudo code:

T = [planeNormal.(pointOnPlane - rayOrigin)]/planeNormal.rayDirection;
pointInPlane = rayOrigin + (rayDirection * T);

Edit: Well that seems to be working, thanks a lot for the helpful response.

There was a long silence...
'I claim them all,' said the Savage at last.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Ray-Triangle Intersection mikey 2 4,369 Aug 15, 2010 05:11 AM
Last Post: mikey
  Triangle Intersection Tests merrill541 1 3,000 Feb 6, 2009 12:13 PM
Last Post: scgames
  2D Polygon intersection testing unknown 6 7,865 Aug 15, 2006 04:17 PM
Last Post: unknown
  Box to Plane Intersection With Quaternions KiroNeem 6 5,264 Jun 25, 2006 05:44 PM
Last Post: KiroNeem
  Algorithm for moving between two points on a plane... WhatMeWorry 4 4,781 Aug 23, 2005 11:36 AM
Last Post: unknown