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

后端 未结 4 1952
暗喜
暗喜 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 17:04

    To finish answering your question, once you have the unit normal vector of your triangle you can work out the angle using a dot product.

    The dot product of two unit vectors is equal to the cosine of the angle between them, so if you calculate the arccos of the dot product of your unit normal vector and your unit Up vector you will get the slope angle of your triangle (angle away from horizontal).

    Also, note that OpenGL conventionally uses a right-handed coordinate system, so if you are using that then your triangle vertices will have a counter-clockwise ordering.

提交回复
热议问题