【发布时间】:2015-12-09 14:45:28
【问题描述】:
令 P 为 Point3D 使得 P = {1,0,0} 。我需要定义一个围绕 Z 轴 +45deg 的旋转并将其应用于 P。在右手约定下,定义了变换 M:
M =
0.707 -0.707 0 0
0.707 0.707 0 0
0 0 1 0
0 0 0 1
数学上:
M x P =
0.707 -0.707 0 0 1 0.707
0.707 0.707 0 0 X 0 = 0.707
0 0 1 0 0 0
0 0 0 1 1 1
这是我的 C# 代码:
private void testMatrix3D() {
double angle_rad = Math.PI/4;
double cos = Math.Cos(angle_rad);
double sin = Math.Sin(angle_rad);
Matrix3D mat = new Matrix3D(cos, -sin, 0, 0, sin, cos, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
Point3D p = new Point3D(1, 0, 0);
Point3D transformedP = mat.Transform(p);
Debug.WriteLine("p = " + p);
Debug.WriteLine("mat = " + mat);
Debug.WriteLine("transformedP = " + transformedP);
}
不幸的是,结果是transformedP = {0.707, -0.707, 0} 而不是transformedP= {0.707, 0.707, 0}
我做错了什么?
【问题讨论】: