ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 27 Feb 2013 22:03:28 -0600Intersection of a line and a planehttps://ask.sagemath.org/question/9855/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?
Tue, 26 Feb 2013 17:03:37 -0600https://ask.sagemath.org/question/9855/intersection-of-a-line-and-a-plane/Answer by twch for <p>Hi,</p>
<p>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>
<pre><code>P = Polyhedron(eqns=[(-6,1,1,1)])
L = [[1, 0, 1], [4, -2, 2]]
L1 = Polyhedron(L)
intersect = L1.intersection(P)
</code></pre>
<p>Output is "The empty polyhedron in QQ^3". Whats wrong here? my calculation by hand or my code?</p>
https://ask.sagemath.org/question/9855/intersection-of-a-line-and-a-plane/?answer=14603#post-id-14603The 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?Tue, 26 Feb 2013 20:48:16 -0600https://ask.sagemath.org/question/9855/intersection-of-a-line-and-a-plane/?answer=14603#post-id-14603Answer by assadabbasi for <p>Hi,</p>
<p>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>
<pre><code>P = Polyhedron(eqns=[(-6,1,1,1)])
L = [[1, 0, 1], [4, -2, 2]]
L1 = Polyhedron(L)
intersect = L1.intersection(P)
</code></pre>
<p>Output is "The empty polyhedron in QQ^3". Whats wrong here? my calculation by hand or my code?</p>
https://ask.sagemath.org/question/9855/intersection-of-a-line-and-a-plane/?answer=14608#post-id-14608Thanks for the explanation but how do we get rays=[[3,-2,1],[-3,2,-1]] ???Wed, 27 Feb 2013 11:35:29 -0600https://ask.sagemath.org/question/9855/intersection-of-a-line-and-a-plane/?answer=14608#post-id-14608Comment by twch for <p>Thanks for the explanation but how do we get rays=[[3,-2,1],[-3,2,-1]] ???</p>
https://ask.sagemath.org/question/9855/intersection-of-a-line-and-a-plane/?comment=18133#post-id-18133Well 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.Wed, 27 Feb 2013 22:03:28 -0600https://ask.sagemath.org/question/9855/intersection-of-a-line-and-a-plane/?comment=18133#post-id-18133