Ray/Plane Intersection Point
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.
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.
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.
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?
Why don't you post some code, or your current algorithm?
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.
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.
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.
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.
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.
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.
Possibly Related Threads...
Thread:  Author  Replies:  Views:  Last Post  
RayTriangle Intersection  mikey  2  4,745 
Aug 15, 2010 05:11 AM Last Post: mikey 

Triangle Intersection Tests  merrill541  1  3,198 
Feb 6, 2009 12:13 PM Last Post: scgames 

2D Polygon intersection testing  unknown  6  8,496 
Aug 15, 2006 04:17 PM Last Post: unknown 

Box to Plane Intersection With Quaternions  KiroNeem  6  5,844 
Jun 25, 2006 05:44 PM Last Post: KiroNeem 

Algorithm for moving between two points on a plane...  WhatMeWorry  4  5,268 
Aug 23, 2005 11:36 AM Last Post: unknown 