Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在Matrix3D中使用偏移量进行转换_C#_Wpf_Matrix_3d - Fatal编程技术网

C# 在Matrix3D中使用偏移量进行转换

C# 在Matrix3D中使用偏移量进行转换,c#,wpf,matrix,3d,C#,Wpf,Matrix,3d,我有一个应用程序,我想缩放、旋转和平移一些3D点 我习惯于看到3x3旋转矩阵,并将平移存储在单独的值数组中。但是.NETMatrix3D结构()是4x4,有一行“偏移量”——OffsetX、OffsetY、OffsetZ,它们显然用于翻译。但它们究竟打算如何应用呢 假设我有一个向量3D,X,Y,Z的值,比如说72,24,4。说我的Matrix 3D .707 0 -.707 0 0 1 0 0 .707 0 .707 0 100 100

我有一个应用程序,我想缩放、旋转和平移一些3D点

我习惯于看到3x3旋转矩阵,并将平移存储在单独的值数组中。但是.NETMatrix3D结构()是4x4,有一行“偏移量”——OffsetX、OffsetY、OffsetZ,它们显然用于翻译。但它们究竟打算如何应用呢

假设我有一个向量3D,X,Y,Z的值,比如说72,24,4。说我的Matrix 3D

.707   0   -.707   0
0      1     0     0
.707   0   .707    0
100   100    0     1
i、 因此OffsetX和OffsetY的值是100

Matrix3D是否有任何方法或运算符可以将其作为我的观点的翻译?Transform()似乎不起作用。如果我的代码有

Vector3D v = new Vector3D(72, 24, 0);
Vector3D vectorResult = new Vector3D();
vectorResult = MyMatrix.Transform(v);
vectorResult的值为8.484,24,-8.484,如果偏移量为0,则其值相同


显然,我可以为每个轴分别手动应用平移,但我认为,因为它是结构的一部分,所以可能会有某种方法或操作符,在其中给它一个点,并应用整个矩阵,包括平移。有吗

4x4矩阵表示使用齐次坐标的三维空间变换。在此表示中,将
w
分量添加到向量。此组件根据向量应表示的内容而有所不同。用矩阵变换向量是简单的乘法:

transformed = vector * matrix
(其中两个向量都是行向量)

w
组件仅由矩阵的最后一行(存储翻译的部分)考虑。因此,如果要变换点,该组件必须为1。如果要变换方向,则该组件必须为0(因为平移方向向量时方向向量不会改变)

这种差异在WPF中用两种不同的结构表示。
Vector3D
表示一个方向(带有
w
组件0),而
Point3D
表示一个点(带有
w
组件1)。因此,如果您将
v
a
Point3D
,一切都应该按照您的预期工作