4

I want to find a 3D plane equation given 3 points. I have got the normal calculated after applying the cross product. But the equation of a plane is known to be the normal multiply by another vector which what I am taught to be as P.OP. I substitute my main reference point as OP and i want P to be in (x, y, z) form. So that I can get something like e.g,

OP = (1, 2, 3)

I want to get something like that:

(x-1)
(y-2)
(z-3)

May I know how? Below is my reference code.(Note: plane_point_1_x(), plane_point_1_y(), plane_point_1_z() are all functions asking for the user input of the respective points)

"""
I used Point P as my reference point so I will make use of it in this section
"""

vector_pop_x = int('x') - int(plane_point_1_x())
vector_pop_y = int('y') - int(plane_point_1_y())
vector_pop_z = int('z') - int(plane_point_1_z())

print vector_pop_x, vector_pop_y, vector_pop_z

All the above is what i did, but for some reason it did not work. I think the problem lies in the x, y , z part.

4

5 回答 5

5

假设您有三个已知点,每个点都有 (x, y, z)。例如:

p1 = (1, 2, 3)
p2 = (4, 6, 9)
p3 = (12, 11, 9)

将它们制成更易于查看以进行进一步处理的符号:

x1, y1, z1 = p1
x2, y2, z2 = p2
x3, y3, z3 = p3

从点确定两个向量:

v1 = [x3 - x1, y3 - y1, z3 - z1]
v2 = [x2 - x1, y2 - y1, z2 - z1]

确定两个向量的叉积

cp = [v1[1] * v2[2] - v1[2] * v2[1],
      v1[2] * v2[0] - v1[0] * v2[2],
      v1[0] * v2[1] - v1[1] * v2[0]]

可以使用简单的方程ax + by + cz = d来描述平面。叉积的三个系数是abc,并且d可以通过代入已知点来求解,例如第一个:

a, b, c = cp
d = a * x1 + b * y1 + c * z1

现在做一些有用的事情,比如确定x =4,y =5处的z值。重新排列简单方程,并求解z

x = 4
y = 5
z = (d - a * x - b * y) / float(c)  # z = 6.176470588235294
于 2014-07-31T08:43:08.283 回答
5

如果我没记错的话,这里的一个好的解决方案包含错误输入

vector1 = [x2 - x1, y2 - y1, z2 - z1]
vector2 = [x3 - x1, y3 - y1, z3 - z1]

cross_product = [vector1[1] * vector2[2] - vector1[2] * vector2[1], -1 * (vector1[0] * vector2[2] - vector1[2] * vector2[0]), vector1[0] * vector2[1] - vector1[1] * vector2[0]]

a = cross_product[0]
b = cross_product[1]
c = cross_product[2]
d = - (cross_product[0] * x1 + cross_product[1] * y1 + cross_product[2] * z1)

尝试过以前的(作者的)版本,但必须检查它。现在,公式中有更多的缺点似乎是正确的。

于 2014-09-12T13:06:52.720 回答
4

一种好方法是:

| x1 y1 z2 1 |
| x2 y2 z2 1 |
| x3 y3 z3 1 | = 0
| x  y  z  1 |

其中垂直管道表示矩阵的行列式,并且(x1 y1 z1)(x2 y2 z2)(x3 y3 z3)是您的给定点。

于 2009-12-31T13:50:02.697 回答
3

Plane implicit Eqn:

All points P = (x, y, z) satisfying

<n, QP> = 0

where

  • n is the plane normal vector,
  • Q is some point on the plane (any will do)
  • QP is the vector from Q to P
  • <a, b> is the scalar (dot) product operator.

(Remember that QP can be computed as P - Q)

于 2009-12-31T13:39:23.797 回答
2

我希望这个答案已经存在。编码自http://www.had2know.com/academics/equation-plane-through-3-points.html

假设 3 个点 p1, p2, p3 - 由 [x1, y1, z1] 等组成。

vector1 = [x2 - x1, y2 - y1, z2 - z1]
vector2 = [x3 - x1, y3 - y1, z3 - z1]
cross_product = [vector1[1] * vector2[2] - vector1[2] * vector2[1], -1 * vector1[0] * v2[2] - vector1[2] * vector2[0], vector1[0] * vector2[1] - vector1[1] * vector2[0]]
d = cross_product[0] * x1 - cross_product[1] * y1 + cross_product[2] * z1

a = cross_product[0]
b = cross_product[1]
c = cross_product[2]
d = d
于 2014-07-02T21:00:13.893 回答