Find the normal angle of the face of a triangle in 3D, given the co-ordinates of its vertices

后端 未结 4 1963
暗喜
暗喜 2021-02-02 16:30

As you may be able to tell from this screenshot, I am trying to make a physics engine for a platformer I am working on, but I have run into a definite problem: I need to be able

4条回答
  •  暖寄归人
    2021-02-02 16:59

    If you take the cross product of the two vectors:

    p1 - p0
    

    and

    p2 - p0
    

    where p0, p1 and p2 are three vertices of the triangle, you'll get the normal. A triangle is considered to be pointing towards you if the vertices are ordered clockwise with respect to its outward normal. This is called the left hand rule. Imagine holding your left hand with your fingers curled from p0 to p1, your thumb sticks out in the direction of the face normal:

    face pointing away from camera face pointing towards camera

提交回复
热议问题