gpt4 book ai didi

c# - System.Numerics 平面是否向后?

转载 作者:行者123 更新时间:2023-11-30 17:37:59 25 4
gpt4 key购买 nike

我正在使用 System.Numerics 编写一些几何代码,我似乎在 Plane.CreateFromVertices 方法的实现中遇到了一个错误。 Plane.D 的评论说:

The plane's distance from the origin along its normal vector.

但是,如果我用 Y = 0.5 处的三个顶点调用它,我会得到平面:

N = (0, 1, 0)
D = -0.5

D 是负数!因此,据我所知,评论是错误的,应该标记为 D:

The distance of the origin from the plane along the normal vector

或者Plane.CreateFromVertices是错误的,D应该是正数。

我是正确的(在这种情况下我应该去写一个错误报告),还是我误解了这里的某些东西(在这种情况下,是什么以及为什么?)。

最佳答案

你是对的。该文档具有误导性。例如,我比较了两个不同的数学库。 System.Numerics 和 Accord.Math

    public void RightHandRulePlane_Accord()
{
{
var plane = System.Numerics.Plane.CreateFromVertices
(
new System.Numerics.Vector3( 0, 0.5f, 0 )
, new System.Numerics.Vector3( 1, 0.5f, 0 )
, new System.Numerics.Vector3( 0, 0.5f, 1 ) );

Console.WriteLine( plane.ToString() );

plane = System.Numerics.Plane.CreateFromVertices
(
new System.Numerics.Vector3( 0, 0.5f, 1 )
, new System.Numerics.Vector3( 1, 0.5f, 0 )
, new System.Numerics.Vector3( 0, 0.5f, 0 )
);

Console.WriteLine( plane.ToString() );

}
{
var plane = Accord.Math.Plane.FromPoints
(
new Accord.Math.Point3( 0, 0.5f, 0 )
, new Accord.Math.Point3( 1, 0.5f, 0 )
, new Accord.Math.Point3( 0, 0.5f, 1 ) );

Console.WriteLine( plane.ToString() );

plane = Accord.Math.Plane.FromPoints
(
new Accord.Math.Point3( 0, 0.5f, 1 )
, new Accord.Math.Point3( 1, 0.5f, 0 )
, new Accord.Math.Point3( 0, 0.5f, 0 )
);

Console.WriteLine( plane.ToString() );
}
}

输出是

{Normal:<0, -1, 0> D:0.5}
{Normal:<0, 1, 0> D:-0.5}
0x -1y 0z +0.5 = 0
0x +1y 0z -0.5 = 0

带符号的值+0.5是等式中的常数项

ax + by + cz + d = 0

您是正确的,您可能应该将其理解为平面法线方向上从平面原点到坐标系原点的距离。

关于c# - System.Numerics 平面是否向后?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37195648/

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