Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Getting polygon (triangle) edge normals in 3D space - perpendicular to surface normal

Threaded View

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2012
    Posts
    2

    Question Getting polygon (triangle) edge normals in 3D space - perpendicular to surface normal

    Hello all
    So I have a triangle with the following points: p0, p1, p2 in 3D space and I'm testing it against a collision with a AABB (cube).

    So far this is the code that I have, but my collision detection (SAT) implementation fails. The failure happens when the triangle projection "overlaps" on the surface normal only, so I'm assuming that the edge normals are not correct since they don't end the test as not intersecting. So I'm guessing I'm having concept/math issues.
    Code :
            // subtract the two to get the edge vector
            edge1.sub( p1, p0 );
            edge2.sub( p2, p0 );
            edge3.sub( p2, p1 );
     
            // 1 Surface normal
            Vector3d normal = new Vector3d();
            normal.cross( p0, p1 );
            normal.normalize();
            axes[ 0 ] = normal;
     
            // 3 Edge normals
            Vector3d normal1 = new Vector3d();
            normal1.cross( edge1, edge2 );
            normal1.normalize();
            axes[ 1 ] = normal1;
     
            Vector3d normal2 = new Vector3d();
            normal2.cross( edge1, edge3 );
            normal2.normalize();
            axes[ 2 ] = normal2;
     
            Vector3d normal3 = new Vector3d();
            normal3.cross( edge3, edge2 );
            normal3.normalize();
            axes[ 3 ] = normal3;

    I'm not sure if the edge normals are actually perpendicular to the surface normal. Am I wrong in my implementation, if so, what can I do to fix it (need to understand this )? Thank you all!

    p.s. The projection of the triangle on the edge normal axis results in the min = max, for all edge normals.
    Last edited by knownasilya; 09-11-2012 at 12:41 PM. Reason: added p.s.

Posting Permissions

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