Skip to content

Commit 305c929

Browse files
committed
Add tests for geometry/plane
1 parent 8053a45 commit 305c929

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

sympy/geometry/tests/test_plane.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from sympy import Dummy, S, symbols, pi, sqrt, asin, sin, cos, Rational
2-
from sympy.geometry import Line, Point, Ray, Segment, Point3D, Line3D, Ray3D, Segment3D, Plane
2+
from sympy.geometry import Line, Point, Ray, Segment, Point3D, Line3D, Ray3D, Segment3D, Plane, Circle
33
from sympy.geometry.util import are_coplanar
44
from sympy.testing.pytest import raises
55

@@ -23,8 +23,14 @@ def test_plane():
2323
l2 = Line3D(Point3D(0, -2, 0), Point3D(3, 1, 1))
2424
l3 = Line3D(Point3D(0, -1, 0), Point3D(5, -1, 9))
2525

26+
raises(ValueError, lambda: Plane(p1, p1, p1))
27+
2628
assert Plane(p1, p2, p3) != Plane(p1, p3, p2)
2729
assert Plane(p1, p2, p3).is_coplanar(Plane(p1, p3, p2))
30+
assert Plane(p1, p2, p3).is_coplanar(p1)
31+
assert Plane(p1, p2, p3).is_coplanar(Circle(p1, 1)) is False
32+
assert Plane(p1, normal_vector=(0, 0, 1)).is_coplanar(Circle(p1, 1))
33+
2834
assert pl3 == Plane(Point3D(0, 0, 0), normal_vector=(1, -2, 1))
2935
assert pl3 != pl4
3036
assert pl4 == pl4b
@@ -68,12 +74,16 @@ def test_plane():
6874

6975
assert pl3.is_parallel(pl6) is False
7076
assert pl4.is_parallel(pl6)
77+
assert pl3.is_parallel(Line(p1, p2))
7178
assert pl6.is_parallel(l1) is False
7279

7380
assert pl3.is_perpendicular(pl6)
7481
assert pl4.is_perpendicular(pl7)
7582
assert pl6.is_perpendicular(pl7)
83+
assert pl6.is_perpendicular(pl4) is False
7684
assert pl6.is_perpendicular(l1) is False
85+
assert pl6.is_perpendicular(Line((0, 0, 0), (1, 1, 1)))
86+
assert pl6.is_perpendicular((1, 1)) is False
7787

7888
assert pl6.distance(pl6.arbitrary_point(u, v)) == 0
7989
assert pl7.distance(pl7.arbitrary_point(u, v)) == 0
@@ -136,6 +146,8 @@ def test_plane():
136146
# pts as tuples
137147
assert p.perpendicular_plane((1, 0, 1), (1, 1, 1)) == \
138148
Plane(Point3D(1, 0, 1), (0, 0, -1))
149+
# more than two planes
150+
raises(ValueError, lambda: p.perpendicular_plane((1, 0, 1), (1, 1, 1), (1, 1, 0)))
139151

140152
a, b = Point3D(0, 0, 0), Point3D(0, 1, 0)
141153
Z = (0, 0, 1)
@@ -154,6 +166,9 @@ def test_plane():
154166
# case 2&3
155167
assert Plane(b, normal_vector=b.args).perpendicular_plane(n, n + b) == \
156168
Plane(Point3D(0, 0, 1), (1, 0, 0))
169+
170+
p = Plane(a, normal_vector=(0, 0, 1))
171+
assert p.perpendicular_plane() == Plane(a, normal_vector=(1, 0, 0))
157172

158173
assert pl6.intersection(pl6) == [pl6]
159174
assert pl4.intersection(pl4.p1) == [pl4.p1]
@@ -178,6 +193,7 @@ def test_plane():
178193
assert pl9.intersection(pl11) == [Line3D(Point3D(0, 0, 1), Point3D(12, 0, 1))]
179194
assert pl9.intersection(pl4) == [Line3D(Point3D(0, 0, 0), Point3D(12, 0, -12))]
180195
assert pl3.random_point() in pl3
196+
assert pl3.random_point(seed=1) in pl3
181197

182198
# test geometrical entity using equals
183199
assert pl4.intersection(pl4.p1)[0].equals(pl4.p1)
@@ -203,6 +219,7 @@ def test_plane():
203219
assert pl8.equals(pl8)
204220
assert pl8.equals(Plane(p1, normal_vector=(0, 0, -12)))
205221
assert pl8.equals(Plane(p1, normal_vector=(0, 0, -12*sqrt(3))))
222+
assert pl8.equals(p1) is False
206223

207224
# issue 8570
208225
l2 = Line3D(Point3D(Rational(50000004459633, 5000000000000),
@@ -237,7 +254,11 @@ def test_dimension_normalization():
237254

238255
def test_parameter_value():
239256
t, u, v = symbols("t, u v")
240-
p = Plane((0, 0, 0), (0, 0, 1), (0, 1, 0))
257+
p1, p2, p3 = Point(0, 0, 0), Point(0, 0, 1), Point(0, 1, 0)
258+
p = Plane(p1, p2, p3)
241259
assert p.parameter_value((0, -3, 2), t) == {t: asin(2*sqrt(13)/13)}
242260
assert p.parameter_value((0, -3, 2), u, v) == {u: 3, v: 2}
261+
assert p.parameter_value(p1, t) == p1
243262
raises(ValueError, lambda: p.parameter_value((1, 0, 0), t))
263+
raises(ValueError, lambda: p.parameter_value(Line(Point(0, 0), Point(1, 1)), t))
264+
raises(ValueError, lambda: p.parameter_value((0, -3, 2), t, 1))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy