# Intersection of a line and a plane

Hi,

I have a line described by points (1, 0, 1), (4, -2, 2) and a plane x + y + z = 6. If solve by hand I get the point of intersection as (7, -4, 3). But in sage, I don't find any intersection point. My code in sage is as follows:

P = Polyhedron(eqns=[(-6,1,1,1)])

L = [[1, 0, 1], [4, -2, 2]]

L1 = Polyhedron(L)

intersect = L1.intersection(P)


Output is "The empty polyhedron in QQ^3". Whats wrong here? my calculation by hand or my code?

edit retag close merge delete

Sort by » oldest newest most voted

The Problem is that the way you define your line above, you only get the line segment between the two indicated points. The intersection points lies however on the line outside of this segment. So try this instead to see the difference:

P = Polyhedron(eqns=[(-6,1,1,1)])
L1 = Polyhedron([[1, 0, 1], [4, -2, 2]])
L2 = Polyhedron(vertices=[[1,0,1]], rays=[[3,-2,1],[-3,2,-1]])
print L1.intersection(P)
print L2.intersection(P).vertices()


By the way: Is there an easier way of defining a complete line as a Polyhedron?

more

Thanks for the explanation but how do we get rays=[[3,-2,1],[-3,2,-1]] ???

more

Well its just the vector connecting your two points. You have to take both directions (plus and minus) of this vector to generate the full line.