三维矢量的平面方程

blu*_*959 3 python math linear-algebra

我想找到一个给出3分的3D平面方程.应用十字产品后,我得到了正常的计算结果.但是已知平面的方程是正常乘以另一个向量,我被教导为P.OP. 我将主参考点替换为OP,我希望P为(x,y,z)形式.所以我可以得到像,例如,

OP = (1, 2, 3)
Run Code Online (Sandbox Code Playgroud)

我希望得到类似的东西:

(x-1)
(y-2)
(z-3)
Run Code Online (Sandbox Code Playgroud)

我可以知道吗?下面是我的参考代码(注:plane_point_1_x(),plane_point_1_y(),plane_point_1_z()所要求的各点的用户输入的所有功能).

"""
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
Run Code Online (Sandbox Code Playgroud)

以上所有都是我做的,但由于某种原因它没有用.我认为问题在于x,y,z部分.

Mik*_*e T 5

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

p1 = (1, 2, 3)
p2 = (4, 6, 9)
p3 = (12, 11, 9)
Run Code Online (Sandbox Code Playgroud)

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

x1, y1, z1 = p1
x2, y2, z2 = p2
x3, y3, z3 = p3
Run Code Online (Sandbox Code Playgroud)

从这些点确定两个向量:

v1 = [x3 - x1, y3 - y1, z3 - z1]
v2 = [x2 - x1, y2 - y1, z2 - z1]
Run Code Online (Sandbox Code Playgroud)

确定两个向量的叉积:

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]]
Run Code Online (Sandbox Code Playgroud)

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

a, b, c = cp
d = a * x1 + b * y1 + c * z1
Run Code Online (Sandbox Code Playgroud)

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

x = 4
y = 5
z = (d - a * x - b * y) / float(c)  # z = 6.176470588235294
Run Code Online (Sandbox Code Playgroud)


Mas*_*ler 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)
Run Code Online (Sandbox Code Playgroud)

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