Calculate rotations to look at a 3D point?

前端 未结 4 1776
生来不讨喜
生来不讨喜 2020-12-07 17:55

I need to calculate the 2 angles (yaw and pitch) for a 3D object to face an arbitrary 3D point. These rotations are known as \"Euler\" rotations simply because after the fir

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-07 18:50

    This series of rotations will give you what you're asking for:

    1. About X: 0
    2. About Y: atan2(z, x)
    3. About Z: atan2(y, sqrt(x*x + z*z))

    I cannot tell you what these are in terms of "roll", "pitch" and "yaw" unless you first define how you are using these terms. You are not using them in the standard way.

    EDIT:
    All right, then try this:

    1. About X: -atan2(y, z)
    2. About Y: atan2(x, sqrt(y*y + z*z))
    3. About Z: 0

提交回复
热议问题