Click here to Skip to main content
15,891,629 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Python
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)
Posted
Updated 3-Jul-19 22:23pm
v2
Comments
[no name] 3-Jul-19 14:49pm    
a.) Show what your planes are (either Coordinate- or Parameter- form)
b.) Show your code how you did it
c.) Be aware, as soon as two planes are parallel (or to be nore precise enough parallel for e.g. double number calculations) there will be no solution.

Use Editing a Question[^] to improve your question.
Member 14520123 3-Jul-19 15:19pm    
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)
That's where i am i don't know what to do next

MadMyche 3-Jul-19 17:11pm    
I edited your question to contain the code

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900