Calculate normal of a single triangle in 3D space

后端 未结 1 1097
情深已故
情深已故 2021-01-05 05:43

I am in a graphics programming class and I am doing the written homework, not programming, so I hope this is appropriate for this site. I have this problem:

相关标签:
1条回答
  • 2021-01-05 06:35

    Quoting from https://www.khronos.org/opengl/wiki/Calculating_a_Surface_Normal

    A surface normal for a triangle can be calculated by taking the vector cross product of two edges of that triangle. The order of the vertices used in the calculation will affect the direction of the normal (in or out of the face w.r.t. winding).

    So for a triangle p1, p2, p3, if the vector A = p2 - p1 and the vector B = p3 - p1 then the normal N = A x B and can be calculated by:

    Nx = Ay * Bz - Az * By
    Ny = Az * Bx - Ax * Bz
    Nz = Ax * By - Ay * Bx
    
    0 讨论(0)
提交回复
热议问题