本文介绍了发现沿该行的两个平面的交点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想绘制由在三维两个平面的交叉点形成的线,但我无法理解数学,这已经说明的和这里

I am trying to draw the line formed by the intersections of two planes in 3D, but I am having trouble understanding the math, which has been explained here and here.

我试图找出自己,但我得到了一个解决方案最接近的是一个矢量沿同一方向的交线指点下,通过使用平面的法向量的积。我不知道如何找上了交线的一个点,任何一点会做。我认为,这种方法是死路一条。下面是这种尝试的截图:

I tried to figure it out myself, but the closest that I got to a solution was a vector pointing along the same direction as the intersection line, by using the cross product of the normals of the planes. I have no idea how to find a point on the intersection line, any point would do. I think that this method is a dead end. Here is a screenshot of this attempt:

我试图用在this的问题,但它原来的解释,一个死链接以及公式并没有为我工作(它具有不对称的括号,这是我试图纠正下文)。

I tried to use the solution mentioned in this question, but it has a dead link to the original explanation, and the equation didn't work for me (it has unbalanced parentheses, which I tried to correct below).

var planeA = new THREE.Plane((new THREE.Vector3(0, 0, 1)).normalize(), 100);
var planeB = new THREE.Plane((new THREE.Vector3(1, 1, 1)).normalize(), -100);

var x1 = planeA.normal.x,
    y1 = planeA.normal.y,
    z1 = planeA.normal.z,
    d1 = planeA.constant;

var x2 = planeB.normal.x,
    y2 = planeB.normal.y,
    z2 = planeB.normal.z,
    d2 = planeB.constant;

var point1 = new THREE.Vector3();
point1.x = 0;
point1.z = (y2 / y1) * (d1 - d2) / (z2 - z1 * y2 / y1);
point1.y = (-z1 * point1.z - d1) / y1;

var point2 = new THREE.Vector3();
point2.x = 1;
point2.z = (y2 / y1) * (x1 * point2.x + d1) - (x2 * point2.x - d2) / (z2 - z1 * y2 / y1);
point2.y = (-z1 * point2.z - x1 * point2.x - d1) / y1;

console.log(point1, point2);

输出:

THREE.Vector3 {x: -1, y: NaN, z: NaN, …}
THREE.Vector3 {x: 1, y: Infinity, z: -Infinity, …}

期望的输出:

expected output:

  • 沿路口,其中x = 0点,
  • 在同一行的另一点,其中x = 1

如果有人可以点我的,这是如何工作的一个很好的解释,还是平面的平面相交算法的一个例子,我将不胜感激。

If someone could point me to a good explanation of how this is supposed to work, or an example of a plane-plane intersection algorithm, I would be grateful.

推荐答案

回想一下,重新present我们需要描述其方向并可以通过该线变为一个点的矢量线。这就是所谓的参数化形式:

Prerequisites


Recall that to represent a line we need a vector describing its direction and a point through which this line goes. This is called parameterized form:

line_point(t) = t * (point_2 - point_1) + point_1

其中, _1 point_2 的任意点,通过该行云,和 T 是一个标量,它的参数化我们的产品线。现在,我们可以找到任何一点 line_point(T)。如果我们把任意行 T 成以上的方程。

where point_1 and point_2 are arbitrary points through which the line goes, and t is a scalar which parameterizes our line. Now we can find any point line_point(t) on the line if we put arbitrary t into the equation above.

注意:术语(point_2 - _1)是什么,但一个矢量描述我们这行的方向,术语 _1 是什么,但一个点,通过它我们行云(当然 point_2 )也将被罚款使用了。

NOTE: The term (point_2 - point_1) is nothing, but a vector describing the direction of our line, and the term point_1 is nothing, but a point through which our line goes (of course point_2) would also be fine to use too.

  1. 找到方向方向通过取交线的面法线,即方向=交(normal_1交叉的产品,normal_2)

  1. Find the direction direction of the intersection line by takingcross product of plane normals, i.e. direction = cross(normal_1,normal_2).

取任何平面,例如第一之一,并找到的任何两个不同点这架飞机上: _1 point_2 。如果我们假设平面方程是形式 A1 * X + B1 * Y + C1 * Z + D1 = 0 ,然后找2不同点,我们可以做到以下几点:

Take any plane, for example the first one, and find any 2 distinct pointson this plane: point_1 and point_2. If we assume that the plane equationis of the form a1 * x + b1 * y + c1 * z + d1 = 0, then to find 2distinct points we could do the following:

y1 = 1
z1 = 0
x1 = -(b1 + d1) / a1

y2 = 0
z2 = 1
x2 = -(c1 + d1) / a1

其中, _1 =(X1,Y1,Z1) point_2 =(X2,Y2,Z2)

现在,我们有2个点,我们可以构建在参数再$ P $行躺在在这第一架飞机psentation line_point(T)= T *(point_2 - _1)+ _1 ,其中 line_point(T)介绍了在这条线上的任何位置, T 只是一个输入标(经常被称为参数)。

Now that we have 2 points, we can construct the parameterizedrepresentation of the line lying on this first plane:line_point(t) = t * (point_2 - point_1) + point_1, where line_point(t)describes any point on this line, and t is just an input scalar(frequently called parameter).

找到交点 intersection_point line_point(T)第二平面 A2 * X + B * Y + C2 * Z + D2 = 0 使用标准线平面相交算法(注意代数形式部分,因为这是所有你需要实现线面路口,如果你还没有这样做的话)。

Find the intersection point intersection_point of the lineline_point(t) and the second plane a2 * x + b2 * y + c2 * z + d2 = 0 by usingthe standard line-plane intersection algorithm (pay attention to theAlgebraic form section as this is all you need to implement line-planeintersection, if you haven't done so already).

我们的交线,现在发现,可以在构造参数表像往常一样: intersection_line_point(S)= S *方向+ intersection_point ,其中 intersection_line_point(S)说明在此交汇线的任何位置,取值参数

Our intersection line is now found and can be constructed inparameterized form as usual: intersection_line_point(s) = s *direction + intersection_point, where intersection_line_point(s)describes any point on this intersection line, and s is parameter.

注意:我没看过这个算法的任何地方,我只是从我的头基于我线性代数的知识,顶部设计了它。这并不意味着它不工作,但也可能是可能的,该算法可以进一步优化。

NOTE: I didn't read this algorithm anywhere, I've just devised it from the top of my head based on my knowledge of linear algebra. That doesn't mean that it doesn't work, but it might be possible that this algorithm can be optimized further.

在2法向量 normal_1 normal_2 几乎是共线的问题会非常的。几何这意味着2飞机是几乎平行,彼此确定与在交线的接受precision 变成不可能 finite- precision算术浮点运算在这种情况下。

When 2 normal vectors normal_1 and normal_2 are almost collinear this problem gets extremely ill-conditioned. Geometrically it means that the 2 planes are almost parallel to each other and determining the intersection line with acceptable precision becomes impossible in finite-precision arithmetic which is floating-point arithmetic in this case.

这篇关于发现沿该行的两个平面的交点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 12:48