我正在使用System.Numerics编写一些几何代码,我似乎在Plane.CreateFromVertices方法的实现中遇到了一个bug。关于Plane.D的评论说:
飞机与原点沿法向量的距离。
然而,如果在Y= 0.5处有三个顶点,我就会得到这个平面:
N = (0, 1, 0)
D = -0.5D是负的!因此,据我所知,这一评论要么是错误的,要么是D应该贴上标签:
原点沿法向量与平面的距离
或者Plane.CreateFromVertices是错的,D应该是正的。
我是正确的(在这种情况下,我要去写错误报告),还是我在这里误解了什么(在这种情况下,什么以及为什么?)
发布于 2017-07-13 06:04:02
你是对的。这些文件有误导性。例如,我比较了两个不同的数学库。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你是对的,因为你可能应该把它读成平面原点到坐标系原点的距离,在平面法线方向上。
https://stackoverflow.com/questions/37195648
复制相似问题