1
1
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
3
3
from sympy .geometry .util import are_coplanar
4
4
from sympy .testing .pytest import raises
5
5
@@ -23,8 +23,14 @@ def test_plane():
23
23
l2 = Line3D (Point3D (0 , - 2 , 0 ), Point3D (3 , 1 , 1 ))
24
24
l3 = Line3D (Point3D (0 , - 1 , 0 ), Point3D (5 , - 1 , 9 ))
25
25
26
+ raises (ValueError , lambda : Plane (p1 , p1 , p1 ))
27
+
26
28
assert Plane (p1 , p2 , p3 ) != Plane (p1 , p3 , p2 )
27
29
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
+
28
34
assert pl3 == Plane (Point3D (0 , 0 , 0 ), normal_vector = (1 , - 2 , 1 ))
29
35
assert pl3 != pl4
30
36
assert pl4 == pl4b
@@ -68,12 +74,16 @@ def test_plane():
68
74
69
75
assert pl3 .is_parallel (pl6 ) is False
70
76
assert pl4 .is_parallel (pl6 )
77
+ assert pl3 .is_parallel (Line (p1 , p2 ))
71
78
assert pl6 .is_parallel (l1 ) is False
72
79
73
80
assert pl3 .is_perpendicular (pl6 )
74
81
assert pl4 .is_perpendicular (pl7 )
75
82
assert pl6 .is_perpendicular (pl7 )
83
+ assert pl6 .is_perpendicular (pl4 ) is False
76
84
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
77
87
78
88
assert pl6 .distance (pl6 .arbitrary_point (u , v )) == 0
79
89
assert pl7 .distance (pl7 .arbitrary_point (u , v )) == 0
@@ -136,6 +146,8 @@ def test_plane():
136
146
# pts as tuples
137
147
assert p .perpendicular_plane ((1 , 0 , 1 ), (1 , 1 , 1 )) == \
138
148
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 )))
139
151
140
152
a , b = Point3D (0 , 0 , 0 ), Point3D (0 , 1 , 0 )
141
153
Z = (0 , 0 , 1 )
@@ -154,6 +166,9 @@ def test_plane():
154
166
# case 2&3
155
167
assert Plane (b , normal_vector = b .args ).perpendicular_plane (n , n + b ) == \
156
168
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 ))
157
172
158
173
assert pl6 .intersection (pl6 ) == [pl6 ]
159
174
assert pl4 .intersection (pl4 .p1 ) == [pl4 .p1 ]
@@ -178,6 +193,7 @@ def test_plane():
178
193
assert pl9 .intersection (pl11 ) == [Line3D (Point3D (0 , 0 , 1 ), Point3D (12 , 0 , 1 ))]
179
194
assert pl9 .intersection (pl4 ) == [Line3D (Point3D (0 , 0 , 0 ), Point3D (12 , 0 , - 12 ))]
180
195
assert pl3 .random_point () in pl3
196
+ assert pl3 .random_point (seed = 1 ) in pl3
181
197
182
198
# test geometrical entity using equals
183
199
assert pl4 .intersection (pl4 .p1 )[0 ].equals (pl4 .p1 )
@@ -203,6 +219,7 @@ def test_plane():
203
219
assert pl8 .equals (pl8 )
204
220
assert pl8 .equals (Plane (p1 , normal_vector = (0 , 0 , - 12 )))
205
221
assert pl8 .equals (Plane (p1 , normal_vector = (0 , 0 , - 12 * sqrt (3 ))))
222
+ assert pl8 .equals (p1 ) is False
206
223
207
224
# issue 8570
208
225
l2 = Line3D (Point3D (Rational (50000004459633 , 5000000000000 ),
@@ -237,7 +254,11 @@ def test_dimension_normalization():
237
254
238
255
def test_parameter_value ():
239
256
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 )
241
259
assert p .parameter_value ((0 , - 3 , 2 ), t ) == {t : asin (2 * sqrt (13 )/ 13 )}
242
260
assert p .parameter_value ((0 , - 3 , 2 ), u , v ) == {u : 3 , v : 2 }
261
+ assert p .parameter_value (p1 , t ) == p1
243
262
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