[英]How do I define a hyperplane in Python given 4 points? How do I then define the intersection of 4 hyperplanes (this should be a point)?
我在 R4 及其坐標中有 4 個點:
P1:[x1, y1, z1, w1]
P2:[x2, y2, z2, w2]
P3:[x3, y3, z3, w3]
P4:[x4, y4, z4, w4]
我現在如何在 Python 中定義這些點的超平面?
還考慮到我有 4 個超平面的方程,我如何得到它們的交集(應該是一個點)?
謝謝! 哦。
超平面方程。
給定非零常數 K 和一組系數a ={a_1 ... a_n},可以將 Rn 中的超平面描述為求解方程的點集x =(x_1 .. x_n)
總和(a_n * x_n) = k
在 R4 中選擇 k=1,並且
X= ( P1;P2;P3;P4)
你可以通過做來解決你的系數a
X a = 1
a = X^-1 * 1
第 2 部分大致相同。
有4組方程
x a = k
屬於他們的點都可以解決為
x = k ' A^-1
在 numpy 上是:
import numpy as np
def hyper4(p1,p2,p3,p4):
X=np.matrix([p1,p2,p3,p4])
k=np.ones((4,1))
a=numpy.matrix.dot(np.linalg.inv(X), k)
print "equation is x * %s = 1" % a
return a
用法:
hyper4([0,0,1,1],[0,3,3,0],[0,5,2,0],[1,0,0,7])
而對於這一點
a1=hyper4(P1,P2,P3,P4)
a2=hyper4(P5,P6,P7,P8)
a3=hyper4(P9,P10,P11,P12)
a4=hyper4(P13,P14,P15,P16)
A=np.hstack([a1,a2,a3,a4])
k=np.ones((1,4))
x=numpy.matrix.dot(k, np.linalg.inv(A))
print "your point is %s" % x
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.