I need to define a 3D transformation and apply it to a point p ={1000, 0, 0}.
For example, say one needs to apply a Pi/2 rotation around the z axis. I defined the transformation using a MatrixTransform3D. From the code below:
EXPECTED OUTPUT: trPoint = {0, 1000, 0}
ACTUAL OUTPUT: trPoint = {0, -1000, 0}.
QUESTION : Perhaps the Transform3D.Transform method applies the inverse transform instead?
private void testTransformationMat() {
Point3D p = new Point3D(1000, 0, 0);
double angle = System.Math.PI / 2;
double cos = System.Math.Cos(angle);
double sin = System.Math.Sin(angle);
Matrix3D mat_z = new Matrix3D(cos, -sin, 0, 0,sin, cos, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
Transform3D tr = new MatrixTransform3D(mat_z);
Point3D trPoint = tr.Transform(p);
Debug.WriteLine(trPoint);
}
EDIT: To get things straight, as far as I've always known, a homogeneous transformation is applied multiplying a 4x4 matrix with a 4x1 vector. For a +45deg rotation around the z axis, under right-hand convention, we obtain:
0.707 -0.707 0 0 1000 707
0.707 0.707 0 0 X 0 = 707
0 0 1 0 0 0
0 0 0 1 1 0
If we invert the matrix, the multiplication returns a negative y component which is not coherent with a +45deg rotation around Z.
0.707 0.707 0 0 1000 707
-0.707 0.707 0 0 X 0 = -707
0 0 1 0 0 0
0 0 0 1 1 0
From 3-D Transformations Overview
Note:Windows Presentation Foundation (WPF) 3-D is a right-handed system, which means that a positive angle value for a rotation results in a counter-clockwise rotation about the axis.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.