wpf 旋转 3D 坐标
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14446794/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Rotating a 3D coordinate
提问by akuhero
I need to rotate a single coordinate in WPF - C#.
我需要在 WPF-C# 中旋转单个坐标。
The values x, y,zstored in GeometryModel3D[]points.
x, y,z存储在GeometryModel3D[]点中的值。
For example, coordinate(x, y, z) rotate at speficic-axis.
例如,坐标(x,y,z)在特定轴上旋转。
[UPDATE] Rotation transformation using quaternion. The problem are I don't get the new vector value and when I view the pointcloud, It seem drag away in Meshlab.
[更新] 使用四元数的旋转变换。问题是我没有得到新的向量值,当我查看点云时,它似乎在 Meshlab 中被拖走了。
Matrix3D m = Matrix3D.Identity;
Quaternion q = new Quaternion(new Vector3D(320 / 2, y, maxDepth - minDepth), 90);
m.Rotate(q);
Vector3D myVectorToRotate = new Vector3D(((TranslateTransform3D)points[i].Transform).OffsetX, ((TranslateTransform3D)points[i].Transform).OffsetY, ((TranslateTransform3D)points[i].Transform).OffsetZ);
m.Transform(myVectorToRotate);
pointcloud.Add(new Point3D(myVectorToRotate.X,myVectorToRotate.Y,myVectorToRotate.Z));
I'm still can't get the correct value transformation.
我仍然无法获得正确的价值转换。
I want to apply rotation transformation for 2nd point cloud scanned from kinect. Since the 1st scan data don't involved rotation, the code for capture data and usage is like below:
我想对从 kinect 扫描的第二个点云应用旋转变换。由于第一次扫描数据不涉及旋转,捕获数据和使用的代码如下:
for (int y = 0; y < 240; y += resolution)
{
for (int x = 0; x < 320; x += resolution)
{
if (((TranslateTransform3D)points[i].Transform).OffsetZ >= minDepth
&& ((TranslateTransform3D)points[i].Transform).OffsetZ <= maxDepth)
{
pointcloud.Add(new Point3D(((TranslateTransform3D)points[i].Transform).OffsetX, ((TranslateTransform3D)points[i].Transform).OffsetY, ((TranslateTransform3D)points[i].Transform).OffsetZ));
}
i++;
}
}
回答by Matthias
Create any kind of matrix. For example a rotation matrixand then use the static method Vector.Multiply(...)See also this postand the MSDN general transformationoverview.
创建任何类型的矩阵。例如一个旋转矩阵,然后使用静态方法Vector.Multiply(...)另见这篇文章和MSDN 通用转换概述。
Examples for Vector3D:
Vector3D 的示例:
- 3D transformation WPF
Vector3D v = new Vector3D(1.0, -1.0, 2.0); ... AxisAngleRotation3D axisAngle = new AxisAngleRotation3D(axis, angle); RotateTransform3D myRotateTransform = new RotateTransform3D(axisAngle, centerVector); v.Multiply(myRotateTransform);

