Results 1 to 3 of 3

Thread: Vector Math

  1. #1
    zFollette is offline ▼ dafuq did I do?
    Join Date
    Dec 2013
    Posts
    203
    Rep Power
    0

    Question 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 04:36 AM.
    1000011 1100001 1101110 100000 1111001 1101111 1110101 100000 1110010 1100101 1100001 1100100 100000 1000010 1101001 1101110 1100001 1110010 1111001 111111

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    12,998
    Blog Entries
    7
    Rep Power
    19

    Default Re: Vector Math

    Quote Originally Posted by zFollette View Post
    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
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    zFollette is offline ▼ dafuq did I do?
    Join Date
    Dec 2013
    Posts
    203
    Rep Power
    0

    Default Re: Vector Math

    Quote Originally Posted by JosAH View Post
    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.
    1000011 1100001 1101110 100000 1111001 1101111 1110101 100000 1110010 1100101 1100001 1100100 100000 1000010 1101001 1101110 1100001 1110010 1111001 111111

Similar Threads

  1. Doing Math
    By nicholas205 in forum New To Java
    Replies: 1
    Last Post: 01-28-2012, 02:18 AM
  2. math and GUI
    By urbanleg in forum AWT / Swing
    Replies: 3
    Last Post: 08-06-2011, 04:05 PM
  3. Create Math.sin without math.sin
    By vudoo in forum New To Java
    Replies: 11
    Last Post: 12-07-2010, 06:23 AM
  4. Vector<vector> loop thru
    By ocean in forum New To Java
    Replies: 11
    Last Post: 11-21-2009, 02:17 PM
  5. Replies: 1
    Last Post: 04-06-2009, 06:45 AM

Posting Permissions

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