three.js: from plane-orthogonal vector to plane rotation matrix

后端 未结 2 943
终归单人心
终归单人心 2021-01-06 03:37

I want to set the rotation of a plane. This requires three numbers denoting the rotation in radians in the x, y and z axes.

I don\'t have these numbers, but, I have

2条回答
  •  温柔的废话
    2021-01-06 04:10

    Any rotation in three dimensions can be represented by three angles. Your method sounds like Euler angles, have a look here: http://en.wikipedia.org/wiki/Euler_angles

    When you want to construct a rotation matrix for a rotation around 3 angles at once, you have to construct 3 matrices first, each of which performs rotation around one axis by a given angle. Then you have to multiply the 3 matrices (in the correct order) to get your final rotation matrix.

    If you know how to rotate the vector (1 0 0) to match your final vector, you just need to figure out the angles around the respective axes. Mind the order of the rotations. You may start with any other vector, too. You just need to know the angles.

    A matrix which rotates around a given axis by a given angle can be found here: http://en.wikipedia.org/wiki/Rotation_matrix (see "Basic rotations" under "In three dimensions").

    Under "General rotations" you'll find the method I just described to you (multiplying 3 matrices to get one matrix for the entire rotation).

提交回复
热议问题