# Thread: Vector Math

1. ▼ dafuq did I do?
Join Date
Dec 2013
Posts
204
Rep Power
0

## 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:

Java 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);```
Last edited by zFollette; 01-27-2014 at 05:36 AM.

2. ## Re: Vector Math

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

3. ▼ dafuq did I do?
Join Date
Dec 2013
Posts
204
Rep Power
0

## Re: Vector Math

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.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•