Quaternion 计算3D物体旋转角度

 在3D程序中,通常用quaternion来计算3D物体的旋转角度,与Matrix相比,quaternion更加高效,占用的储存空间更小,此外也更便于插值。在数学上,quaternion表示复数w+xi+yj+zk,其中i,j,k都是虚数单位。

 

可以把quaternion看做一个标量和一个3D向量的组合。实部w表示标量,虚部表示向量标记为V,或三个单独的分量(x,y,z)。所以quaternion可以记为[w,V]或[ w,x,y,z]。对quaternion最大的误解在于认为w表示旋转角度,V表示旋转轴,正确的理解应该是w与旋转角度有关,v与旋转轴有关。

 

unity3d里的Quaternion自带了一些方便的改变形式:

 

AngleAxis

Creates a rotation which rotates angle degrees around axis.

FromToRotation

Creates a rotation which rotates from fromDirection to toDirection.

LookRotation

Creates a rotation that looks along forward with the the head upwards along upwards

Slerp

Spherically interpolates from towards to by t.

Lerp

Interpolates from towards to by t and normalizes the result afterwards.

Inverse

Returns the Inverse of rotation.

Angle

Returns the angle in degrees between two rotations a and b.

Euler

Returns a rotation that rotates x degrees around the x axis. y degrees around the y axis. z degrees around the z axis.



本文来自:http://www.meebe.net/blog/article/unity3d/u3d_quater.html


你可能感兴趣的:(Quaternion 计算3D物体旋转角度)