【问题标题】:Are System.Numerics Planes backwards?System.Numerics 平面是否向后?
【发布时间】:2016-05-12 19:16:05
【问题描述】:

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

平面沿其法线向量到原点的距离。

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

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

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

原点到平面沿法线向量的距离

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

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

【问题讨论】:

  • 你是左撇子吗? :D
  • 我是否是左撇子对我的阅读理解没有太大影响:P
  • @leppie 是在做一个卑鄙的人 ;) 关于right hand rule 的玩笑,请参阅我的回答了解更多信息。

标签: c# geometry system.numerics


【解决方案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

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

【讨论】:

  • 我要问的是定义的措辞。你说:The D value should be distance in the direction of the normal from the origin 所以我把它读作 starting 在原点,沿着法线到飞机有多远。但是您显示的输出与此相反,即它是从平面开始到 原点的距离。我只是读错了吗?
  • 其实你有一个好点,是正确的。我已经用另一个库中的一个实验更新了我的答案,该实验澄清了正在发生的事情。
猜你喜欢
  • 1970-01-01
  • 2011-07-08
  • 2015-05-28
  • 2014-11-13
  • 1970-01-01
  • 1970-01-01
  • 2011-12-01
  • 1970-01-01
  • 2010-12-10
相关资源
最近更新 更多