我正在使用System.Numerics编写一些几何代码,我似乎在Plane.CreateFromVertices
方法的实现中遇到了一个错误。对Plane.D
的评论说:
平面与原点之间的距离。
然而,如果我在Y = 0.5时用三个顶点调用它,我得到了平面:
N = (0, 1, 0)
D = -0.5
D是否定的!所以,据我所知,评论是错误的,D应该标记为:
原点与平面沿法线向量的距离
或Plane.CreateFromVertices
错误,D应为正。
我是否正确(在这种情况下我会写一个错误报告),或者我在这里误解了什么(在哪种情况下,为什么以及为什么?)。
答案 0 :(得分:1)
你是对的。该文件具有误导性。例如,我比较了两个不同的数学库。 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
你是正确的,你可能应该把它看作平面原点到平面法线方向的坐标系原点的距离。