open-space-toolkit-mathematics 3.0.0__py39-none-manylinux2014_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of open-space-toolkit-mathematics might be problematic. Click here for more details.

Files changed (55) hide show
  1. open_space_toolkit_mathematics-3.0.0.dist-info/METADATA +28 -0
  2. open_space_toolkit_mathematics-3.0.0.dist-info/RECORD +55 -0
  3. open_space_toolkit_mathematics-3.0.0.dist-info/WHEEL +5 -0
  4. open_space_toolkit_mathematics-3.0.0.dist-info/top_level.txt +1 -0
  5. open_space_toolkit_mathematics-3.0.0.dist-info/zip-safe +1 -0
  6. ostk/__init__.py +1 -0
  7. ostk/mathematics/OpenSpaceToolkitMathematicsPy.cpython-39-aarch64-linux-gnu.so +0 -0
  8. ostk/mathematics/__init__.py +5 -0
  9. ostk/mathematics/libopen-space-toolkit-mathematics.so.3 +0 -0
  10. ostk/mathematics/test/__init__.py +1 -0
  11. ostk/mathematics/test/curve_fitting/__init__.py +1 -0
  12. ostk/mathematics/test/curve_fitting/interpolator/__init__.py +1 -0
  13. ostk/mathematics/test/curve_fitting/interpolator/test_barycentric_rational.py +34 -0
  14. ostk/mathematics/test/curve_fitting/interpolator/test_cubic_spline.py +45 -0
  15. ostk/mathematics/test/curve_fitting/interpolator/test_interpolator.py +71 -0
  16. ostk/mathematics/test/curve_fitting/interpolator/test_linear.py +36 -0
  17. ostk/mathematics/test/geometry/__init__.py +1 -0
  18. ostk/mathematics/test/geometry/d2/__init__.py +1 -0
  19. ostk/mathematics/test/geometry/d2/conftest.py +82 -0
  20. ostk/mathematics/test/geometry/d2/object/__init__.py +1 -0
  21. ostk/mathematics/test/geometry/d2/object/test_composite.py +96 -0
  22. ostk/mathematics/test/geometry/d2/object/test_line.py +57 -0
  23. ostk/mathematics/test/geometry/d2/object/test_linestring.py +174 -0
  24. ostk/mathematics/test/geometry/d2/object/test_multipolygon.py +101 -0
  25. ostk/mathematics/test/geometry/d2/object/test_point.py +213 -0
  26. ostk/mathematics/test/geometry/d2/object/test_point_set.py +102 -0
  27. ostk/mathematics/test/geometry/d2/object/test_polygon.py +370 -0
  28. ostk/mathematics/test/geometry/d2/object/test_segment.py +104 -0
  29. ostk/mathematics/test/geometry/d2/test_object.py +25 -0
  30. ostk/mathematics/test/geometry/d2/test_transformation.py +84 -0
  31. ostk/mathematics/test/geometry/d3/__init__.py +1 -0
  32. ostk/mathematics/test/geometry/d3/object/__init__.py +1 -0
  33. ostk/mathematics/test/geometry/d3/object/test_composite.py +262 -0
  34. ostk/mathematics/test/geometry/d3/object/test_cuboid.py +20 -0
  35. ostk/mathematics/test/geometry/d3/object/test_line.py +68 -0
  36. ostk/mathematics/test/geometry/d3/object/test_linestring.py +166 -0
  37. ostk/mathematics/test/geometry/d3/object/test_point.py +234 -0
  38. ostk/mathematics/test/geometry/d3/object/test_point_set.py +113 -0
  39. ostk/mathematics/test/geometry/d3/object/test_polygon.py +141 -0
  40. ostk/mathematics/test/geometry/d3/object/test_segment.py +120 -0
  41. ostk/mathematics/test/geometry/d3/objects/test_cuboid.py +20 -0
  42. ostk/mathematics/test/geometry/d3/test_intersection.py +3 -0
  43. ostk/mathematics/test/geometry/d3/test_object.py +3 -0
  44. ostk/mathematics/test/geometry/d3/test_transformation.py +3 -0
  45. ostk/mathematics/test/geometry/d3/transformation/__init__.py +1 -0
  46. ostk/mathematics/test/geometry/d3/transformation/rotation/__init__.py +1 -0
  47. ostk/mathematics/test/geometry/d3/transformation/rotation/test_quaternion.py +183 -0
  48. ostk/mathematics/test/geometry/d3/transformation/rotation/test_rotation_matrix.py +24 -0
  49. ostk/mathematics/test/geometry/d3/transformation/rotation/test_rotation_vector.py +34 -0
  50. ostk/mathematics/test/geometry/test_angle.py +345 -0
  51. ostk/mathematics/test/object/__init__.py +1 -0
  52. ostk/mathematics/test/object/test_interval.py +445 -0
  53. ostk/mathematics/test/object/test_vector.py +5 -0
  54. ostk/mathematics/test/solver/test_numerical_solver.py +176 -0
  55. ostk/mathematics/test/test_object.py +24 -0
@@ -0,0 +1,183 @@
1
+ # Apache License 2.0
2
+
3
+ import pytest
4
+
5
+ import numpy as np
6
+
7
+ from ostk.mathematics import geometry
8
+
9
+
10
+ Angle = geometry.Angle
11
+ Quaternion = geometry.d3.transformation.rotation.Quaternion
12
+ RotationVector = geometry.d3.transformation.rotation.RotationVector
13
+ RotationMatrix = geometry.d3.transformation.rotation.RotationMatrix
14
+
15
+
16
+ @pytest.fixture
17
+ def quaternion() -> Quaternion:
18
+ return Quaternion.xyzs(0.0, 0.0, 0.0, 1.0)
19
+
20
+
21
+ class TestQuaternion:
22
+ def test_constructors_success(self, quaternion: Quaternion):
23
+ assert Quaternion(0.0, 0.0, 0.0, 1.0, Quaternion.Format.XYZS) == quaternion
24
+ assert (
25
+ Quaternion(np.array((0.0, 0.0, 0.0, 1.0)), Quaternion.Format.XYZS)
26
+ == quaternion
27
+ )
28
+ assert Quaternion(np.array((0.0, 0.0, 0.0)), 1.0) == quaternion
29
+ assert Quaternion(quaternion) == quaternion
30
+
31
+ def test_operators_success(self, quaternion: Quaternion):
32
+ assert (quaternion == quaternion) is True
33
+ assert (quaternion != quaternion) is False
34
+
35
+ assert (quaternion + quaternion) == Quaternion.xyzs(0.0, 0.0, 0.0, 2.0)
36
+
37
+ quaternion_2 = Quaternion(quaternion)
38
+ quaternion_2 += quaternion
39
+ assert quaternion_2 == Quaternion.xyzs(0.0, 0.0, 0.0, 2.0)
40
+
41
+ assert (quaternion * 1.0) == quaternion
42
+ assert (1.0 * quaternion) == quaternion
43
+
44
+ assert (quaternion**1.0) == quaternion
45
+
46
+ def test_is_defined_success(self, quaternion: Quaternion):
47
+ assert quaternion.is_defined() is True
48
+
49
+ def test_is_unitary_success(self, quaternion: Quaternion):
50
+ assert quaternion.is_unitary() is True
51
+
52
+ def test_is_near_success(self, quaternion: Quaternion):
53
+ assert quaternion.is_near(quaternion, Angle.zero()) is True
54
+
55
+ def test_getter_success(self, quaternion: Quaternion):
56
+ assert quaternion.x() == 0.0
57
+ assert quaternion.y() == 0.0
58
+ assert quaternion.z() == 0.0
59
+ assert quaternion.s() == 1.0
60
+
61
+ def test_get_vector_part_success(self, quaternion: Quaternion):
62
+ assert (
63
+ np.array_equal(quaternion.get_vector_part(), np.array((0.0, 0.0, 0.0)))
64
+ is True
65
+ )
66
+
67
+ def test_get_scalar_part_success(self, quaternion: Quaternion):
68
+ assert quaternion.get_scalar_part() == 1.0
69
+
70
+ def test_to_normalized_success(self, quaternion: Quaternion):
71
+ assert quaternion.to_normalized() == quaternion
72
+
73
+ def test_to_conjugate_success(self, quaternion: Quaternion):
74
+ assert quaternion.to_conjugate() == quaternion
75
+
76
+ def test_to_inverse_success(self, quaternion: Quaternion):
77
+ assert quaternion.to_inverse() == quaternion
78
+
79
+ def test_exp_success(self, quaternion: Quaternion):
80
+ assert quaternion.exp() == quaternion
81
+
82
+ def test_log_success(self, quaternion: Quaternion):
83
+ assert quaternion.log() == Quaternion.xyzs(0.0, 0.0, 0.0, 0.0)
84
+
85
+ def test_pow_success(self, quaternion: Quaternion):
86
+ assert quaternion.pow(1.0) == quaternion
87
+
88
+ def test_norm_success(self, quaternion: Quaternion):
89
+ assert quaternion.norm() == 1.0
90
+
91
+ def test_cross_multiply_success(self, quaternion: Quaternion):
92
+ assert quaternion.cross_multiply(quaternion) == quaternion
93
+
94
+ def test_dot_multiply_success(self, quaternion: Quaternion):
95
+ assert quaternion.dot_multiply(quaternion) == quaternion
96
+
97
+ def test_dot_product_success(self, quaternion: Quaternion):
98
+ assert quaternion.dot_product(quaternion) == 1.0
99
+
100
+ def test_rotate_vector_success(self, quaternion: Quaternion):
101
+ assert np.array_equal(
102
+ quaternion.rotate_vector(np.array((0.0, 0.0, 1.0))), np.array((0.0, 0.0, 1.0))
103
+ )
104
+
105
+ def test_to_vector_success(self, quaternion: Quaternion):
106
+ assert (
107
+ np.array_equal(
108
+ quaternion.to_vector(Quaternion.Format.XYZS),
109
+ np.array((0.0, 0.0, 0.0, 1.0)),
110
+ )
111
+ is True
112
+ )
113
+
114
+ def test_to_string_success(self, quaternion: Quaternion):
115
+ assert quaternion.to_string() == "[0.0, 0.0, 0.0, 1.0]"
116
+
117
+ def test_to_string_success_with_format(self, quaternion: Quaternion):
118
+ assert quaternion.to_string(Quaternion.Format.XYZS) == "[0.0, 0.0, 0.0, 1.0]"
119
+
120
+ def test_normalize_success(self, quaternion: Quaternion):
121
+ quaternion_2 = Quaternion(quaternion)
122
+ quaternion_2.normalize()
123
+ assert quaternion_2 == quaternion
124
+
125
+ def test_conjugate_success(self, quaternion: Quaternion):
126
+ quaternion_2 = Quaternion(quaternion)
127
+ quaternion_2.conjugate()
128
+ assert quaternion_2 == quaternion
129
+
130
+ def test_inverse_success(self, quaternion: Quaternion):
131
+ quaternion_2 = Quaternion(quaternion)
132
+ quaternion_2.inverse()
133
+ assert quaternion_2 == quaternion
134
+
135
+ def test_rectify_success(self, quaternion: Quaternion):
136
+ quaternion_2 = Quaternion(quaternion)
137
+ quaternion_2.rectify()
138
+ assert quaternion_2 == quaternion
139
+
140
+ def test_angular_difference_with_success(self, quaternion: Quaternion):
141
+ assert quaternion.angular_difference_with(quaternion) == Angle.zero()
142
+
143
+ def test_undefined_success(self):
144
+ assert Quaternion.undefined().is_defined() is False
145
+
146
+ def test_unit_success(self, quaternion: Quaternion):
147
+ assert Quaternion.unit() == quaternion
148
+
149
+ def test_xyzs_success(self, quaternion: Quaternion):
150
+ assert Quaternion.xyzs(0.0, 0.0, 0.0, 1.0) == quaternion
151
+
152
+ def test_rotation_vector_success(self, quaternion: Quaternion):
153
+ assert (
154
+ Quaternion.rotation_vector(
155
+ RotationVector(np.array((0.0, 0.0, 1.0)), Angle.zero())
156
+ )
157
+ == quaternion
158
+ )
159
+
160
+ def test_rotation_matrix_success(self, quaternion: Quaternion):
161
+ assert Quaternion.rotation_matrix(RotationMatrix.rz(Angle.zero())) == quaternion
162
+
163
+ def test_parse_success(self, quaternion: Quaternion):
164
+ assert (
165
+ Quaternion.parse("[0.0, 0.0, 0.0, 1.0]", Quaternion.Format.XYZS) == quaternion
166
+ )
167
+
168
+ def test_shortest_rotation_success(self, quaternion: Quaternion):
169
+ assert (
170
+ Quaternion.shortest_rotation(
171
+ np.array((1.0, 0.0, 0.0)), np.array((1.0, 0.0, 0.0))
172
+ )
173
+ == quaternion
174
+ )
175
+
176
+ def test_lerp_success(self, quaternion: Quaternion):
177
+ assert Quaternion.lerp(quaternion, quaternion, 0.0) == quaternion
178
+
179
+ def test_nlerp_success(self, quaternion: Quaternion):
180
+ assert Quaternion.nlerp(quaternion, quaternion, 0.0) == quaternion
181
+
182
+ def test_slerp_success(self, quaternion: Quaternion):
183
+ assert Quaternion.slerp(quaternion, quaternion, 0.0) == quaternion
@@ -0,0 +1,24 @@
1
+ # Apache License 2.0
2
+
3
+ from ostk.mathematics import geometry
4
+
5
+
6
+ Angle = geometry.Angle
7
+ Quaternion = geometry.d3.transformation.rotation.Quaternion
8
+ RotationMatrix = geometry.d3.transformation.rotation.RotationMatrix
9
+
10
+
11
+ # isDefined
12
+ # getRowAt
13
+ # getColumnAt
14
+ # toTransposed
15
+ # transpose
16
+ # Undefined
17
+ # Unit
18
+ # RX
19
+ # RY
20
+ # RZ
21
+ # Rows
22
+ # Columns
23
+ # Quaternion
24
+ # RotationVector
@@ -0,0 +1,34 @@
1
+ # Apache License 2.0
2
+
3
+ import numpy
4
+
5
+ from ostk.mathematics import geometry
6
+
7
+
8
+ Angle = geometry.Angle
9
+ Quaternion = geometry.d3.transformation.rotation.Quaternion
10
+ RotationVector = geometry.d3.transformation.rotation.RotationVector
11
+
12
+
13
+ def test_geometry_d3_transformation_rotation_rotation_vector():
14
+ rv: RotationVector = RotationVector(
15
+ numpy.array([[0.0], [0.0], [1.0]], dtype=float), Angle.zero()
16
+ )
17
+
18
+ assert (rv == rv) is True
19
+ assert (rv != rv) is False
20
+
21
+ assert rv.is_defined() is True
22
+
23
+ # assert numpy.array_equal(rv.get_axis(), numpy.array([[0.0], [0.0], [1.0]], dtype=float))
24
+ assert rv.get_angle() == Angle.zero()
25
+
26
+ assert RotationVector.undefined().is_defined() is False
27
+ assert RotationVector.unit().is_defined() is True
28
+ assert (
29
+ RotationVector.quaternion(
30
+ Quaternion(0.0, 0.0, 0.0, 1.0, Quaternion.Format.XYZS)
31
+ ).is_defined()
32
+ is True
33
+ )
34
+ # assert RotationVector.RotationMatrix().is_defined() is True
@@ -0,0 +1,345 @@
1
+ # Apache License 2.0
2
+
3
+ import pytest
4
+
5
+ import math
6
+
7
+ import ostk.mathematics as mathematics
8
+
9
+
10
+ Angle = mathematics.geometry.Angle
11
+ Unit = Angle.Unit
12
+
13
+
14
+ def test_angle_unit():
15
+ enum_members = Unit.__members__
16
+
17
+ list_keys = ["Undefined", "Radian", "Degree", "Arcminute", "Arcsecond", "Revolution"]
18
+
19
+ list_values = [
20
+ Unit.Undefined,
21
+ Unit.Radian,
22
+ Unit.Degree,
23
+ Unit.Arcminute,
24
+ Unit.Arcsecond,
25
+ Unit.Revolution,
26
+ ]
27
+
28
+ assert list(enum_members.keys()) == list_keys
29
+ assert list(enum_members.values()) == list_values
30
+
31
+
32
+ def test_angle_default_constructor():
33
+ # Default constructor with Degree Unit
34
+ angle: Angle = Angle(12.34, Unit.Degree)
35
+
36
+ assert angle is not None
37
+ assert isinstance(angle, Angle)
38
+ assert angle.in_degrees() == 12.34
39
+
40
+ angle: Angle = Angle(-12.34, Unit.Degree)
41
+
42
+ assert angle is not None
43
+ assert isinstance(angle, Angle)
44
+ assert angle.in_degrees() == -12.34
45
+
46
+ angle: Angle = Angle(365.34, Unit.Degree)
47
+
48
+ assert angle is not None
49
+ assert isinstance(angle, Angle)
50
+ assert angle.in_degrees() == 365.34
51
+
52
+ angle: Angle = Angle(-4000.34, Unit.Degree)
53
+
54
+ assert angle is not None
55
+ assert isinstance(angle, Angle)
56
+ assert angle.in_degrees() == -4000.34
57
+
58
+ # Default constructor with Radian Unit
59
+ angle: Angle = Angle(3.4, Unit.Radian)
60
+
61
+ assert angle is not None
62
+ assert isinstance(angle, Angle)
63
+ assert angle.in_radians() == 3.4
64
+
65
+ # Default constructor with Arcminute Unit
66
+ angle: Angle = Angle(3600.0, Unit.Arcminute)
67
+
68
+ assert angle is not None
69
+ assert isinstance(angle, Angle)
70
+ assert angle.in_arcminutes() == 3600.0
71
+
72
+ # Default constructor with Arcsecond Unit
73
+ angle: Angle = Angle(3600.0, Unit.Arcsecond)
74
+
75
+ assert angle is not None
76
+ assert isinstance(angle, Angle)
77
+ assert angle.in_arcseconds() == 3600.0
78
+
79
+ # Default constructor with Revolution Unit
80
+ angle: Angle = Angle(18.0, Unit.Revolution)
81
+
82
+ assert angle is not None
83
+ assert isinstance(angle, Angle)
84
+ assert angle.in_revolutions() == 18.0
85
+
86
+ # Invalid construction
87
+ with pytest.raises(TypeError):
88
+ angle: Angle = Angle(45, Unit.Degree)
89
+
90
+
91
+ def test_angle_undefined_constructor():
92
+ angle: Angle = Angle.undefined()
93
+
94
+ assert angle is not None
95
+ assert isinstance(angle, Angle)
96
+ assert angle.is_defined() is False
97
+
98
+
99
+ def test_angle_zero_constructor():
100
+ angle: Angle = Angle.zero()
101
+
102
+ assert angle is not None
103
+ assert isinstance(angle, Angle)
104
+ assert angle.is_defined() is True
105
+ assert angle.get_unit() == Unit.Radian
106
+ assert angle.is_zero() is True
107
+ assert angle.in_radians() == 0.0
108
+ assert angle.in_degrees() == 0.0
109
+ assert angle.in_arcminutes() == 0.0
110
+ assert angle.in_arcseconds() == 0.0
111
+ assert angle.in_revolutions() == 0.0
112
+
113
+
114
+ def test_angle_pi_constructors():
115
+ angle: Angle = Angle.half_pi()
116
+
117
+ assert angle is not None
118
+ assert isinstance(angle, Angle)
119
+ assert angle.is_defined()
120
+ assert angle.get_unit() == Unit.Radian
121
+ assert angle.in_radians() == math.pi / 2
122
+
123
+ angle: Angle = Angle.pi()
124
+
125
+ assert angle is not None
126
+ assert isinstance(angle, Angle)
127
+ assert angle.is_defined()
128
+ assert angle.get_unit() == Unit.Radian
129
+ assert angle.in_radians() == math.pi
130
+
131
+ angle: Angle = Angle.two_pi()
132
+
133
+ assert angle is not None
134
+ assert isinstance(angle, Angle)
135
+ assert angle.is_defined()
136
+ assert angle.get_unit() == Unit.Radian
137
+ assert angle.in_radians() == 2 * math.pi
138
+
139
+
140
+ def test_angle_unit_constructors():
141
+ # Radian
142
+ angle: Angle = Angle.radians(3.4)
143
+
144
+ assert angle is not None
145
+ assert isinstance(angle, Angle)
146
+ assert angle.is_defined()
147
+ assert angle.get_unit() == Unit.Radian
148
+ assert angle.in_radians() == 3.4
149
+
150
+ # Degree
151
+ angle: Angle = Angle.degrees(-45.0)
152
+
153
+ assert angle is not None
154
+ assert isinstance(angle, Angle)
155
+ assert angle.is_defined()
156
+ assert angle.get_unit() == Unit.Degree
157
+ assert angle.in_degrees() == -45.0
158
+
159
+ # Arcminutes
160
+ angle: Angle = Angle.arcminutes(60.5)
161
+
162
+ assert angle is not None
163
+ assert isinstance(angle, Angle)
164
+ assert angle.is_defined()
165
+ assert angle.get_unit() == Unit.Arcminute
166
+ assert angle.in_arcminutes() == 60.5
167
+
168
+ # Arcseconds
169
+ angle: Angle = Angle.arcseconds(60.5)
170
+
171
+ assert angle is not None
172
+ assert isinstance(angle, Angle)
173
+ assert angle.is_defined()
174
+ assert angle.get_unit() == Unit.Arcsecond
175
+ assert angle.in_arcseconds() == 60.5
176
+
177
+ # Revolutions
178
+ angle: Angle = Angle.revolutions(3.9)
179
+
180
+ assert angle is not None
181
+ assert isinstance(angle, Angle)
182
+ assert angle.is_defined()
183
+ assert angle.get_unit() == Unit.Revolution
184
+ assert angle.in_revolutions() == 3.9
185
+
186
+
187
+ def test_angle_unit_conversion():
188
+ angle: Angle = Angle(60.0, Unit.Degree)
189
+
190
+ assert angle.in_degrees() == 60.0
191
+ assert angle.in_radians() == (math.pi * 60.0 / 180.0)
192
+ assert angle.in_arcminutes() == 60.0 * 60.0
193
+ assert (angle.in_arcseconds() - 60.0 * 3600.0) <= 1e-10
194
+
195
+
196
+ def test_angle_comparators():
197
+ angle_deg: Angle = Angle(60.0, Unit.Degree)
198
+ angle_rad: Angle = Angle(60.0 * math.pi / 180.0, Unit.Radian)
199
+
200
+ assert angle_deg == angle_deg
201
+ assert angle_rad == angle_rad
202
+ assert angle_deg == angle_rad
203
+ assert angle_deg != Angle(59.0, Unit.Degree)
204
+
205
+
206
+ def test_angle_operators():
207
+ angle: Angle = Angle(30.0, Unit.Degree)
208
+ half_angle: Angle = angle / 2.0
209
+ double_angle: Angle = angle * 2.0
210
+ sum_angle: Angle = angle + angle
211
+ diff_angle: Angle = angle - angle
212
+ positive_angle: Angle = +angle
213
+ negative_angle: Angle = -angle
214
+
215
+ assert half_angle is not None
216
+ assert isinstance(half_angle, Angle)
217
+ assert double_angle is not None
218
+ assert isinstance(double_angle, Angle)
219
+ assert sum_angle is not None
220
+ assert isinstance(sum_angle, Angle)
221
+ assert diff_angle is not None
222
+ assert isinstance(diff_angle, Angle)
223
+ assert positive_angle is not None
224
+ assert isinstance(positive_angle, Angle)
225
+ assert negative_angle is not None
226
+ assert isinstance(negative_angle, Angle)
227
+
228
+ assert half_angle.in_degrees() == 15.0
229
+ assert double_angle.in_degrees() == 60.0
230
+ assert sum_angle.in_degrees() == 60.0
231
+ assert diff_angle.in_degrees() == 0.0
232
+ assert diff_angle.is_zero()
233
+ assert positive_angle.in_degrees() == +30.0
234
+ assert negative_angle.in_degrees() == -30.0
235
+
236
+ angle_deg: Angle = Angle(90.0, Unit.Degree)
237
+ angle_rad: Angle = Angle(math.pi / 2, Unit.Radian)
238
+
239
+ sum_angle: Angle = angle_rad + angle_deg
240
+ assert sum_angle is not None
241
+ assert isinstance(sum_angle, Angle)
242
+ assert (sum_angle.in_degrees() - 180.0) <= 1e-10
243
+
244
+ angle: Angle = Angle(90.0, Unit.Degree)
245
+
246
+ angle *= 3.0
247
+ assert angle is not None
248
+ assert isinstance(angle, Angle)
249
+ assert angle.get_unit() == Unit.Degree
250
+ assert angle.in_degrees() == 270.0
251
+
252
+ angle /= 3.0
253
+ assert angle is not None
254
+ assert isinstance(angle, Angle)
255
+ assert angle.get_unit() == Unit.Degree
256
+ assert angle.in_degrees() == 90.0
257
+
258
+
259
+ # def test_angle_between_vector2d ():
260
+
261
+ # def test_angle_between_vector3d ():
262
+
263
+ # def test_angle_to_string ():
264
+
265
+
266
+ def test_angle_string_from_unit():
267
+ assert Angle.string_from_unit(Unit.Degree) == "Degree"
268
+ assert Angle.string_from_unit(Unit.Radian) == "Radian"
269
+ assert Angle.string_from_unit(Unit.Arcminute) == "Arcminute"
270
+ assert Angle.string_from_unit(Unit.Arcsecond) == "Arcsecond"
271
+ assert Angle.string_from_unit(Unit.Revolution) == "Revolution"
272
+
273
+
274
+ def test_angle_string_symbol_from_unit():
275
+ assert Angle.symbol_from_unit(Unit.Degree) == "deg"
276
+ assert Angle.symbol_from_unit(Unit.Radian) == "rad"
277
+ assert Angle.symbol_from_unit(Unit.Arcminute) == "amin"
278
+ assert Angle.symbol_from_unit(Unit.Arcsecond) == "asec"
279
+ assert Angle.symbol_from_unit(Unit.Revolution) == "rev"
280
+
281
+
282
+ def test_angle_in_radians_reduction():
283
+ angle: Angle = Angle(math.pi * 3 / 2, Unit.Radian)
284
+ assert angle.in_radians(lower_bound=-math.pi, upper_bound=math.pi) == -math.pi / 2
285
+
286
+ angle: Angle = Angle(math.pi / 2, Unit.Radian)
287
+ assert angle.in_radians(lower_bound=-math.pi, upper_bound=math.pi) == math.pi / 2
288
+
289
+ angle: Angle = Angle(-math.pi, Unit.Radian)
290
+ assert angle.in_radians(-math.pi, math.pi) == -math.pi
291
+
292
+ angle: Angle = Angle(math.pi, Unit.Radian)
293
+ assert angle.in_radians(-math.pi, math.pi) == -math.pi
294
+
295
+
296
+ def test_angle_in_degrees_reduction():
297
+ angle: Angle = Angle(359.0, Unit.Degree)
298
+ assert angle.in_degrees(lower_bound=-180.0, upper_bound=180.0) == -1.0
299
+
300
+ angle: Angle = Angle(1.0, Unit.Degree)
301
+ assert angle.in_degrees(lower_bound=-180.0, upper_bound=180.0) == 1.0
302
+
303
+ angle: Angle = Angle(-180.0, Unit.Degree)
304
+ assert angle.in_degrees(-180.0, 180.0) == -180.0
305
+
306
+ angle: Angle = Angle(180.0, Unit.Degree)
307
+ assert angle.in_degrees(-180.0, 180.0) == -180.0
308
+
309
+
310
+ def test_angle_in_arcminutes_reduction():
311
+ angle: Angle = Angle(359.0 * 60.0, Unit.Arcminute)
312
+ assert (
313
+ angle.in_arcminutes(lower_bound=-180.0 * 60.0, upper_bound=180.0 * 60.0) == -60.0
314
+ )
315
+
316
+ angle: Angle = Angle(60.0, Unit.Arcminute)
317
+ assert (
318
+ angle.in_arcminutes(lower_bound=-180.0 * 60.0, upper_bound=180.0 * 60.0) == 60.0
319
+ )
320
+
321
+ angle: Angle = Angle(-180.0 * 60.0, Unit.Arcminute)
322
+ assert angle.in_arcminutes(-180.0 * 60.0, 180.0 * 60.0) == -180.0 * 60.0
323
+
324
+ angle: Angle = Angle(180.0 * 60.0, Unit.Arcminute)
325
+ assert angle.in_arcminutes(-180.0 * 60.0, 180.0 * 60.0) == -180.0 * 60.0
326
+
327
+
328
+ def test_angle_in_arcseconds_reduction():
329
+ angle: Angle = Angle(359.0 * 3600.0, Unit.Arcsecond)
330
+ assert (
331
+ angle.in_arcseconds(lower_bound=-180.0 * 3600.0, upper_bound=180.0 * 3600.0)
332
+ == -3600.0
333
+ )
334
+
335
+ angle: Angle = Angle(3600.0, Unit.Arcsecond)
336
+ assert (
337
+ angle.in_arcseconds(lower_bound=-180.0 * 3600.0, upper_bound=180.0 * 3600.0)
338
+ == 3600.0
339
+ )
340
+
341
+ angle: Angle = Angle(-180 * 3600.0, Unit.Arcsecond)
342
+ assert angle.in_arcseconds(-180.0 * 3600.0, 180.0 * 3600.0) == -180.0 * 3600.0
343
+
344
+ angle: Angle = Angle(180.0 * 3600.0, Unit.Arcsecond)
345
+ assert angle.in_arcseconds(-180.0 * 3600.0, 180.0 * 3600.0) == -180.0 * 3600.0
@@ -0,0 +1 @@
1
+ # Apache License 2.0