我需要在 WPF - C# 中旋转单个坐标。
值x, y,z
存储在GeometryModel3D[]
点中。
例如,坐标(x, y, z)在特定轴上旋转。
[更新] 使用四元数进行旋转变换。问题是我没有得到新的矢量值,当我查看点云时,它似乎在 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));
我仍然无法获得正确的值转换。
我想对从 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++;
}
}
最佳答案
创建任何类型的矩阵。例如rotation matrix然后使用静态方法Vector.Multiply(...) 另请参阅this post和 MSDN general transformation概述。
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);
关于c# - 旋转 3D 坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14446794/