旋转向量:(将向量(0,0,1)绕y轴旋转90度,变成了(1,0,0))
float angle = Mathf.Deg2Rad*90;
Matrix4x4 matrix = new Matrix4x4(new Vector4(Mathf.Cos(angle), 0, -Mathf.Sin(angle), 0), new Vector4(0, 1, 0, 0), new Vector4(Mathf.Sin(angle), 0, Mathf.Cos(angle), 0), new Vector4(0, 0, 0, 1));
Vector3 dir = new Vector3(0,0,1);
Debug.Log(matrix.MultiplyVector(dir));
构造函数是按四个列向量来的
0.00000 0.00000 1.00000 0.00000
0.00000 1.00000 0.00000 0.00000
-1.00000 0.00000 0.00000 0.00000
0.00000 0.00000 0.00000 1.00000
以上的旋转矩阵是直接赋值
四元数q=((x,y,z)sinθ2, cosθ2)