我需要定义一个3D变换并将其应用到点p = {1000,0,0}。
例如,假设需要围绕z轴应用Pi / 2旋转。我使用MatrixTransform3D定义了转换。从下面的代码:
预期输出:trPoint = {0,1000,0}
ACTUAL OUTPUT:trPoint = {0,-1000,0}。
问题:也许Transform3D.Transform方法会应用逆变换?
// We create a variable of type Workbook and load the excel for reading the fields.
HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream("LIST.xls"));
// Getting the working sheet
HSSFSheet sheet = workbook.getSheetAt(0);
// Getting the working row
HSSFRow row = sheet.getRow(0);
// Store the numeric value on Int var
int d = (int) row.getCell(0).getNumericCellValue();
// Printing the result
System.out.println(d0);
// Close the current workbook
workbook.close();
编辑: 为了直截了当,就我所知,应用均匀变换将4x4矩阵与4x1向量相乘。对于围绕z轴的+ 45度旋转,在右手惯例下,我们得到:
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);
}
如果我们反转矩阵,则乘法返回负y分量,该分量与围绕Z的+ 45度旋转不相关。
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
答案 0 :(得分:0)
来自3-D Transformations Overview
注意:Windows Presentation Foundation(WPF)3-D是右撇子 系统,这意味着产生旋转的正角度值 绕轴逆时针旋转。