# Vector Math

• 01-27-2014, 05:30 AM
zFollette
Vector Math
I am running into some trouble with Line-Plane intersection, my method works, provided I am perpendicular to the plane I want to intersect. This is caused be the plane equation (with my given x, y, and z coordinates, the equation is -Z - 1 = 0). So the equation is only relying on the Z value of anything inputted. Is there another way to calculate the equation of a plane that would rely on all axes? Here is my current code:

Code:

```Vector3f A = new Vector3f(0, 0, -1);         Vector3f B = new Vector3f(0, 1, -1);         Vector3f C = new Vector3f(1, 1, -1);         Vector3f v1 = new Vector3f(B.x - A.x, B.y - A.y, B.z - A.z);         Vector3f v2 = new Vector3f(C.x - A.x, C.y - A.y, C.z - A.z);         float[] i = new float[]{v1.x, v2.x};         float[] j = new float[]{v1.y, v2.y};         float[] k = new float[]{v1.z, v2.z};         float a = (j[0] * k[1]) - (j[1] * k[0]);         float b = (i[0] * k[1]) - (i[1] * k[0]);         float c = (i[0] * j[1]) - (i[1] * j[0]);         float eX = ((a * -C.x));         float eY = ((b * -C.y));         float eZ = ((c * -C.z));         Vector3f v3 = start;         Vector3f v4 = new Vector3f(end.x - v3.x, end.y - v3.y, end.z - v3.z);         float tX = v4.x, tY = v4.y, tZ = v4.z;         float x, y, z;         float rem = (((a * v3.x) + eX + (b * v3.y) + eY + (c * v3.z) + eZ));         float t = rem / (tX + tY + tZ);         x = v3.x + (tX * t);         y = v3.y + (tY * t);         z = v3.z + (tZ * t);         Vector3f v5 = new Vector3f(x, y, z);```
• 01-27-2014, 01:45 PM
JosAH
Re: Vector Math
Quote:

Originally Posted by zFollette
I am running into some trouble with Line-Plane intersection, my method works, provided I am perpendicular to the plane I want to intersect. This is caused be the plane equation (with my given x, y, and z coordinates, the equation is -Z - 1 = 0). So the equation is only relying on the Z value of anything inputted. Is there another way to calculate the equation of a plane that would rely on all axes?

I gave you the algorithm for the general case in another reply in one of your other threads; if you don't care to read, nor understand it, too bad.

kind regards,

Jos
• 01-27-2014, 11:07 PM
zFollette
Re: Vector Math
Quote:

Originally Posted by JosAH
I gave you the algorithm for the general case in another reply in one of your other threads; if you don't care to read, nor understand it, too bad.

kind regards,

Jos

Oh, I did not notice there was a full algorithm in that post, I will check it out.