Skip to content

Commit 843a0b2

Browse files
committed
Fixes sympy#7757
1 parent 88cd3ab commit 843a0b2

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

sympy/geometry/line3d.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -707,9 +707,7 @@ def intersection(self, o):
707707
b = o.arbitrary_point(t2)
708708
c = solve([a.x - b.x, a.y - b.y], [t1, t2])
709709
d = solve([a.x - b.x, a.z - b.z], [t1, t2])
710-
if len(c) == 1:
711-
return []
712-
if len(d) == 1:
710+
if len(c) == 1 and len(d) == 1:
713711
return []
714712
if c is {}:
715713
e = a.subs(t1, d[t1])

sympy/geometry/plane.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ def intersection(self, o):
638638
from sympy.geometry.line import LinearEntity
639639
if isinstance(o, Point) or isinstance(o, Point3D):
640640
if o in self:
641-
return o
641+
return [o]
642642
else:
643643
return []
644644
if isinstance(o, LinearEntity3D):
@@ -655,7 +655,7 @@ def intersection(self, o):
655655
else:
656656
a = a.subs(t, c[0])
657657
if a in o:
658-
return a
658+
return [a]
659659
else:
660660
return []
661661
if isinstance(o, LinearEntity):
@@ -673,7 +673,7 @@ def intersection(self, o):
673673
return [Point(c[x], c[y])]
674674
if isinstance(o, Plane):
675675
if o == self:
676-
return self
676+
return [self]
677677
if self.is_parallel(o):
678678
return []
679679
else:

sympy/geometry/tests/test_geometry.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,10 @@ def test_line3d():
564564
assert intersection(l1, p5) == []
565565
assert intersection(l1, l1.parallel_line(p1)) == [Line3D(Point3D(0, 0, 0), Point3D(1, 1, 1))]
566566

567+
p = Ray3D(Point3D(1, 0, 0), Point3D(-1, 0, 0))
568+
q = Ray3D(Point3D(0, 1, 0), Point3D(0, -1, 0))
569+
assert intersection(p, q) == [Point3D(0, 0, 0)]
570+
567571
# Concurrency
568572
assert Line3D.is_concurrent(l1) is False
569573
assert Line3D.is_concurrent(l1, l2)
@@ -736,10 +740,10 @@ def test_plane():
736740
assert pl6.perpendicular_line(Point3D(6, 4, 2)) == \
737741
Line3D(Point3D(6, 4, 2), Point3D(8, 6, 4))
738742

739-
assert pl6.intersection(pl6) == pl6
740-
assert pl4.intersection(pl4.p1) == pl4.p1
743+
assert pl6.intersection(pl6) == [pl6]
744+
assert pl4.intersection(pl4.p1) == [pl4.p1]
741745
assert pl3.intersection(pl6) == [Line3D(Point3D(8, 4, 0), Point3D(2, 4, 6))]
742-
assert pl3.intersection(Line3D(Point3D(1,2,4), Point3D(4,4,2))) == Point3D(2, 8/3, 10/3)
746+
assert pl3.intersection(Line3D(Point3D(1,2,4), Point3D(4,4,2))) == [Point3D(2, 8/3, 10/3)]
743747
assert pl3.intersection(Plane(Point3D(6, 0, 0), normal_vector=(2, -5, 3))) == \
744748
[Line3D(Point3D(-24, -12, 0), Point3D(-25, -13, -1))]
745749

0 commit comments

Comments
 (0)