I am trying to create a python code that finds the intersection of three planes by creating the equations of the planes, then using cramers rule to solve the system of equations and finally getting the point of intersection if it exists.
What I have tried:
I have tried to use the def fuvction but i dont know how to bring it all together. Please help
class Plane3D:
def equation_plane(x1, y1, z1, x2, y2, z2, x3, y3, z3):
a1 = x2 - x1
b1 = y2 - y1
c1 = z2 - z1
a2 = x3 - x1
b2 = y3 - y1
c2 = z3 - z1
a = b1 * c2 - b2 * c1
b = a2 * c1 - a1 * c2
c = a1 * b2 - b1 * a2
d = (- a * x1 - b * y1 - c * z1)
print ("The equation of the plane is "),
print (a, "x +" ,b, "y +" ,c, "z +" ,d, "= 0.")
print (a)
print(b)
print(c)
print(d)
return equation_plane(x1, y1, z1, x2, y2, z2, x3, y3, z3)
def cramers (self, p1, p2,p3):
from numpy import linalg
As=[[2,-1,5,1],[3,2,2,-6],[1,3,3,-1],[5,-2,-3,3]]
Bs=[-3,-32,-47,49]
Cs=[[2,-1,5,1],[3,2,2,-6],[1,3,3,-1],[5,-2,-3,3]]
Xs=[]
for i in range(0,len(B)):
for j in range(0,len(B)):
C[j][i]=B[j]
if i>0:
C[j][i-1]=A[j][i-1]
X.append(round(linalg.det(C)/linalg.det(A),1))
return (X)