sympyintersectionequationplane

How do i find an equation of a line where two planes intersecting each other


so i have two equations(planes) and would like to find an equation for the line(3D) where they intersect each other.

I tried solving for my variables with the equations i have and then made third equations from the solution but it doesnt look like my solution is correct. what am i missing here?

    import sympy as sym
    import matplotlib.pyplot as plt
    
    x, y = sym.symbols('x y')
    
    #equations
    myeq_1 = x + 2*y
    myeq_2 = x + y**2
    
    # expressions from the two eq. above
    ex1 = sym.Eq(myeq_1,0)
    ex2 = sym.Eq(myeq_2,0)
    
    # solving for x,y values
    slv = sym.solve([ex1,ex2],(x,y))
    print(slv)
    
    #third equation using the x and y values from the above solution
    myeq_3 = -0.5*x+y # was -0.5*x+0*y
    
    # all planes plotted together 
    fig = plt.figure(figsize=(8,0))
    %matplotlib notebook
    
    sym.plotting.plot3d((myeq_1,(x,-1,1),(y,-1,1)),(myeq_2,(x,-1,1),(y,-1,1)),(myeq_3,(x,-1,1),(y,-.5,1)))

Solution

  • If you have a point and the normal vector for a Plane you can create a Plane object; the intersection of two Planes can be requested:

    >>> p1,p2 = Plane((1,2),(0,0,1)), Plane((4,5),(2,1,2))
    >>> p1.intersection(p2)
    [Line3D(Point3D(13/2, 0, 0), Point3D(11/2, 2, 0))]