I read all about it on Google and in my book.
I'm just confirming that this works(tests seem to return plausible results) but I need mathematical opinion:
I have to check P0.Normal != 0.0 or I will get the impossible (Div by 0) which is impossible and thus no intersection can take place if you divide by zero. I used common sense to work this out myself.
p0 = ray's initial point
ray = vector
0.0 <= alphaScaleFactor <= 1.0
-(p0.Normal / ray.Normal) = alphaScaleFactor
Intersection = p0 + alphaScaleFactor * ray
Also what is the stupid variable that randomly pops up which is known as C or D?
I read that it was the displacement of the plane from the 'origin'.
I never used the variable it.
WHAT ORIGIN?
The ray's origin or the world coordinate origin(this is what I assumed)?
I'm just confirming that this works(tests seem to return plausible results) but I need mathematical opinion:
I have to check P0.Normal != 0.0 or I will get the impossible (Div by 0) which is impossible and thus no intersection can take place if you divide by zero. I used common sense to work this out myself.
p0 = ray's initial point
ray = vector
0.0 <= alphaScaleFactor <= 1.0
-(p0.Normal / ray.Normal) = alphaScaleFactor
Intersection = p0 + alphaScaleFactor * ray
Also what is the stupid variable that randomly pops up which is known as C or D?
I read that it was the displacement of the plane from the 'origin'.
I never used the variable it.
WHAT ORIGIN?
The ray's origin or the world coordinate origin(this is what I assumed)?
Code:
public Vector3f intersects(Vector3f point, Vector3f rayDirection, Vector3f intersectionData) {
float pointDOTnormal = 0.0f;
float directionDOTnormal = Vector3f.dot(rayDirection, normal);
float alphaScale = 0.0f;
if(directionDOTnormal == 0.0f)
return null;
pointDOTnormal = Vector3f.dot(normal, rayDirection);
alphaScale = -(pointDOTnormal / directionDOTnormal);
intersectionData.x = point.x + alphaScale * rayDirection.x;
intersectionData.y = point.y + alphaScale * rayDirection.y;
intersectionData.z = point.z + alphaScale * rayDirection.z;
if(pointDOTnormal > 0.0) {
normal.x = -normal.x;
normal.y = -normal.y;
normal.z = -normal.z;
}
return intersectionData;
}