gpt4 book ai didi

c# - .Net Matrix3D Transform() 究竟做了什么/为什么我得到 "- infinity"?

转载 作者:太空宇宙 更新时间:2023-11-03 23:24:54 25 4
gpt4 key购买 nike

我正在尝试对某些 3D 点进行透视变换。 (如果有帮助,我正在尝试应用描述的算法 here )。但基本上,我有一个具有以下值的 Matrix3D:

 HasInverse = true
IsAffine = false
IsIdentity = false
M11 = 1.000000000000000
M12 = 0.0
M13 = 0.0
M14 = 0.0
M21 = 0.0
M22 = 1.000000000000000
M23 = 0.0
M24 = 0.0
M31 = 0.0
M32 = 0.0
M33 = -1.0101010101010102
M34 = 0.0
M44 = 0.0
OffsetX = 100
OffsetY = -1.0101010101010102
OffsetZ = 0.0

当我将使用此矩阵的变换应用于 310,120,0 的点时。 . .

  Point3D p = new Point3D(310, 120, 0);
Point3D pointResult = new Point3D();
pointResult = (Point3D)TheMatrix.Transform(p);

...我得到 (Infinity, Infinity, -Infinity) 结果。 transform() 方法究竟做了什么,为什么我会得到那个结果? MSDN 只是说了那个方法。 . .

Transforms the specified Point3D by the Matrix3D and returns the result.

最佳答案

您的 Point3D 首先通过附加 1 转换为齐次坐标中的向量:

p_h = (310, 120, 0, 1)

然后,将转换应用为乘法:

p_h* = p_h * M
= (410, 119, 0, 0)

然后,执行 w-clip(这是透视变换所必需的)。 w 剪辑将向量除以其 w 分量(最后一个维度)。由于这是零,您会得到无限的结果。

问题是矩阵'M44。将其设置为 1,你应该没问题。至少,矩阵的最后一列应该包含一些值。如果它们都为零,您将始终得到无限的结果。

关于c# - .Net Matrix3D Transform() 究竟做了什么/为什么我得到 "- infinity"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34162444/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com