Unity矩阵乘法的区别

Unity世界坐标系的旋转规则是ZXY,自身坐标系的旋转规则是YXZ,可以理解为:

LocalToWorldMatrix:Rot(y) * Rot(x) * Rot(z) * P(localPosition)

 

 

WorldToLocalMatrix: Inverse of LocalToWorldMatrix

P(-localPosition) * Rot(-z) * Rot(-x) * Rot(-y)

 

Quaternion.Euler(Vector3(x, y, z)): Reture a rotation in Rot(z) * Rot(x) * Rot(y)

 

Transform has three similar methods: TransformPoint, TransformDirection and TransformVector. The difference comes to which aspects of the transform are used or not used.

TransformPoint: considering position, rotation and scale, used to get the world position.

TransformDirection: considering rotation only, used to transform a direction

TransformVector: considering rotaion and scale only, similar to TransformDirection but with magnitude taking scale into consideration.

 

Matrix4x4 has three similar methods: MultiplyPoint, MultiplyVector, MultiplyPoint3x4. The difference:

MultiplyPoint: transform a position.

MultiplyPoint3x4:  This function is a faster version of MultiplyPoint; but it can only handle regular 3D transformations. MultiplyPoint is slower, but can handle projective transformations as well.

MultiplyVector: transform a direction, only the rotation part is taken into consideration.

你可能感兴趣的:(Unity矩阵乘法的区别)