open-space-toolkit-mathematics 4.5.2__py312-none-manylinux2014_aarch64.whl → 4.5.4__py312-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.
- {open_space_toolkit_mathematics-4.5.2.dist-info → open_space_toolkit_mathematics-4.5.4.dist-info}/METADATA +1 -1
- {open_space_toolkit_mathematics-4.5.2.dist-info → open_space_toolkit_mathematics-4.5.4.dist-info}/RECORD +17 -17
- ostk/mathematics/OpenSpaceToolkitMathematicsPy.cpython-312-aarch64-linux-gnu.so +0 -0
- ostk/mathematics/curve_fitting/__init__.pyi +97 -7
- ostk/mathematics/curve_fitting/interpolator.pyi +204 -16
- ostk/mathematics/geometry/__init__.pyi +364 -32
- ostk/mathematics/geometry/d2/__init__.pyi +560 -48
- ostk/mathematics/geometry/d2/object.pyi +1524 -126
- ostk/mathematics/geometry/d3/__init__.pyi +774 -78
- ostk/mathematics/geometry/d3/object.pyi +3164 -250
- ostk/mathematics/geometry/d3/transformation/rotation.pyi +1007 -91
- ostk/mathematics/libopen-space-toolkit-mathematics.so.4 +0 -0
- ostk/mathematics/object.pyi +292 -22
- ostk/mathematics/solver.pyi +220 -16
- {open_space_toolkit_mathematics-4.5.2.dist-info → open_space_toolkit_mathematics-4.5.4.dist-info}/WHEEL +0 -0
- {open_space_toolkit_mathematics-4.5.2.dist-info → open_space_toolkit_mathematics-4.5.4.dist-info}/top_level.txt +0 -0
- {open_space_toolkit_mathematics-4.5.2.dist-info → open_space_toolkit_mathematics-4.5.4.dist-info}/zip-safe +0 -0
|
@@ -9,10 +9,29 @@ class Composite(ostk.mathematics.geometry.d3.Object):
|
|
|
9
9
|
__hash__: typing.ClassVar[None] = None
|
|
10
10
|
@staticmethod
|
|
11
11
|
def empty() -> Composite:
|
|
12
|
-
|
|
12
|
+
"""
|
|
13
|
+
Create an empty composite (containing no objects).
|
|
14
|
+
|
|
15
|
+
Returns:
|
|
16
|
+
Composite: An empty composite object.
|
|
17
|
+
|
|
18
|
+
Example:
|
|
19
|
+
>>> empty_composite = Composite.empty()
|
|
20
|
+
>>> empty_composite.is_empty() # True
|
|
21
|
+
>>> empty_composite.get_object_count() # 0
|
|
22
|
+
"""
|
|
13
23
|
@staticmethod
|
|
14
24
|
def undefined() -> Composite:
|
|
15
|
-
|
|
25
|
+
"""
|
|
26
|
+
Create an undefined composite.
|
|
27
|
+
|
|
28
|
+
Returns:
|
|
29
|
+
Composite: An undefined composite object.
|
|
30
|
+
|
|
31
|
+
Example:
|
|
32
|
+
>>> undefined_composite = Composite.undefined()
|
|
33
|
+
>>> undefined_composite.is_defined() # False
|
|
34
|
+
"""
|
|
16
35
|
def __add__(self, arg0: Composite) -> Composite:
|
|
17
36
|
...
|
|
18
37
|
def __eq__(self, arg0: Composite) -> bool:
|
|
@@ -20,7 +39,16 @@ class Composite(ostk.mathematics.geometry.d3.Object):
|
|
|
20
39
|
def __iadd__(self, arg0: Composite) -> Composite:
|
|
21
40
|
...
|
|
22
41
|
def __init__(self, object: ostk.mathematics.geometry.d3.Object) -> None:
|
|
23
|
-
|
|
42
|
+
"""
|
|
43
|
+
Create a composite object from a single geometric object.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
object (Object): The geometric object to wrap in the composite.
|
|
47
|
+
|
|
48
|
+
Example:
|
|
49
|
+
>>> point = Point(1.0, 2.0, 3.0)
|
|
50
|
+
>>> composite = Composite(point)
|
|
51
|
+
"""
|
|
24
52
|
def __ne__(self, arg0: Composite) -> bool:
|
|
25
53
|
...
|
|
26
54
|
def __repr__(self) -> str:
|
|
@@ -28,94 +56,551 @@ class Composite(ostk.mathematics.geometry.d3.Object):
|
|
|
28
56
|
def __str__(self) -> str:
|
|
29
57
|
...
|
|
30
58
|
def access_object_at(self, index: int) -> ostk.mathematics.geometry.d3.Object:
|
|
31
|
-
|
|
59
|
+
"""
|
|
60
|
+
Access the object at a specific index in the composite.
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
index (int): The index of the object to access.
|
|
64
|
+
|
|
65
|
+
Returns:
|
|
66
|
+
Object: Reference to the object at the specified index.
|
|
67
|
+
|
|
68
|
+
Raises:
|
|
69
|
+
IndexError: If the index is out of bounds.
|
|
70
|
+
|
|
71
|
+
Example:
|
|
72
|
+
>>> composite = Composite(Point(1.0, 2.0, 3.0))
|
|
73
|
+
>>> obj = composite.access_object_at(0)
|
|
74
|
+
"""
|
|
32
75
|
def apply_transformation(self, transformation: typing.Any) -> None:
|
|
33
|
-
|
|
76
|
+
"""
|
|
77
|
+
Apply a transformation to all objects in the composite in place.
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
transformation (Transformation): The transformation to apply.
|
|
81
|
+
|
|
82
|
+
Example:
|
|
83
|
+
>>> composite = Composite(Point(1.0, 2.0, 3.0))
|
|
84
|
+
>>> transformation = Translation([1.0, 1.0, 1.0])
|
|
85
|
+
>>> composite.apply_transformation(transformation)
|
|
86
|
+
"""
|
|
34
87
|
def as_composite(self) -> Composite:
|
|
35
|
-
|
|
88
|
+
"""
|
|
89
|
+
Convert the composite to a Composite object.
|
|
90
|
+
|
|
91
|
+
Returns:
|
|
92
|
+
Composite: The composite object contained in the composite.
|
|
93
|
+
|
|
94
|
+
Raises:
|
|
95
|
+
RuntimeError: If the composite does not contain a Composite.
|
|
96
|
+
|
|
97
|
+
Example:
|
|
98
|
+
>>> inner_composite = Composite(Point(1.0, 2.0, 3.0))
|
|
99
|
+
>>> outer_composite = Composite(inner_composite)
|
|
100
|
+
>>> extracted_composite = outer_composite.as_composite()
|
|
101
|
+
"""
|
|
36
102
|
def as_cone(self) -> Cone:
|
|
37
|
-
|
|
103
|
+
"""
|
|
104
|
+
Convert the composite to a Cone object.
|
|
105
|
+
|
|
106
|
+
Returns:
|
|
107
|
+
Cone: The cone object contained in the composite.
|
|
108
|
+
|
|
109
|
+
Raises:
|
|
110
|
+
RuntimeError: If the composite does not contain a Cone.
|
|
111
|
+
|
|
112
|
+
Example:
|
|
113
|
+
>>> cone = Cone(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]), Angle.degrees(30.0))
|
|
114
|
+
>>> composite = Composite(cone)
|
|
115
|
+
>>> extracted_cone = composite.as_cone()
|
|
116
|
+
"""
|
|
38
117
|
def as_ellipsoid(self) -> Ellipsoid:
|
|
39
|
-
|
|
118
|
+
"""
|
|
119
|
+
Convert the composite to an Ellipsoid object.
|
|
120
|
+
|
|
121
|
+
Returns:
|
|
122
|
+
Ellipsoid: The ellipsoid object contained in the composite.
|
|
123
|
+
|
|
124
|
+
Raises:
|
|
125
|
+
RuntimeError: If the composite does not contain an Ellipsoid.
|
|
126
|
+
|
|
127
|
+
Example:
|
|
128
|
+
>>> ellipsoid = Ellipsoid(Point(0.0, 0.0, 0.0), 1.0, 0.8, 0.6)
|
|
129
|
+
>>> composite = Composite(ellipsoid)
|
|
130
|
+
>>> extracted_ellipsoid = composite.as_ellipsoid()
|
|
131
|
+
"""
|
|
40
132
|
def as_line(self) -> Line:
|
|
41
|
-
|
|
133
|
+
"""
|
|
134
|
+
Convert the composite to a Line object.
|
|
135
|
+
|
|
136
|
+
Returns:
|
|
137
|
+
Line: The line object contained in the composite.
|
|
138
|
+
|
|
139
|
+
Raises:
|
|
140
|
+
RuntimeError: If the composite does not contain a Line.
|
|
141
|
+
|
|
142
|
+
Example:
|
|
143
|
+
>>> line = Line(Point(0.0, 0.0, 0.0), np.array([1.0, 0.0, 0.0]))
|
|
144
|
+
>>> composite = Composite(line)
|
|
145
|
+
>>> extracted_line = composite.as_line()
|
|
146
|
+
"""
|
|
42
147
|
def as_line_string(self) -> LineString:
|
|
43
|
-
|
|
148
|
+
"""
|
|
149
|
+
Convert the composite to a LineString object.
|
|
150
|
+
|
|
151
|
+
Returns:
|
|
152
|
+
LineString: The line string object contained in the composite.
|
|
153
|
+
|
|
154
|
+
Raises:
|
|
155
|
+
RuntimeError: If the composite does not contain a LineString.
|
|
156
|
+
|
|
157
|
+
Example:
|
|
158
|
+
>>> points = [Point(0.0, 0.0, 0.0), Point(1.0, 1.0, 1.0), Point(2.0, 2.0, 2.0)]
|
|
159
|
+
>>> line_string = LineString(points)
|
|
160
|
+
>>> composite = Composite(line_string)
|
|
161
|
+
>>> extracted_line_string = composite.as_line_string()
|
|
162
|
+
"""
|
|
44
163
|
def as_plane(self) -> Plane:
|
|
45
|
-
|
|
164
|
+
"""
|
|
165
|
+
Convert the composite to a Plane object.
|
|
166
|
+
|
|
167
|
+
Returns:
|
|
168
|
+
Plane: The plane object contained in the composite.
|
|
169
|
+
|
|
170
|
+
Raises:
|
|
171
|
+
RuntimeError: If the composite does not contain a Plane.
|
|
172
|
+
|
|
173
|
+
Example:
|
|
174
|
+
>>> plane = Plane(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]))
|
|
175
|
+
>>> composite = Composite(plane)
|
|
176
|
+
>>> extracted_plane = composite.as_plane()
|
|
177
|
+
"""
|
|
46
178
|
def as_point(self) -> Point:
|
|
47
|
-
|
|
179
|
+
"""
|
|
180
|
+
Convert the composite to a Point object.
|
|
181
|
+
|
|
182
|
+
Returns:
|
|
183
|
+
Point: The point object contained in the composite.
|
|
184
|
+
|
|
185
|
+
Raises:
|
|
186
|
+
RuntimeError: If the composite does not contain a Point.
|
|
187
|
+
|
|
188
|
+
Example:
|
|
189
|
+
>>> composite = Composite(Point(1.0, 2.0, 3.0))
|
|
190
|
+
>>> point = composite.as_point()
|
|
191
|
+
"""
|
|
48
192
|
def as_point_set(self) -> PointSet:
|
|
49
|
-
|
|
193
|
+
"""
|
|
194
|
+
Convert the composite to a PointSet object.
|
|
195
|
+
|
|
196
|
+
Returns:
|
|
197
|
+
PointSet: The point set object contained in the composite.
|
|
198
|
+
|
|
199
|
+
Raises:
|
|
200
|
+
RuntimeError: If the composite does not contain a PointSet.
|
|
201
|
+
|
|
202
|
+
Example:
|
|
203
|
+
>>> point_set = PointSet([Point(1.0, 2.0, 3.0), Point(4.0, 5.0, 6.0)])
|
|
204
|
+
>>> composite = Composite(point_set)
|
|
205
|
+
>>> extracted_set = composite.as_point_set()
|
|
206
|
+
"""
|
|
50
207
|
def as_polygon(self) -> Polygon:
|
|
51
|
-
|
|
208
|
+
"""
|
|
209
|
+
Convert the composite to a Polygon object.
|
|
210
|
+
|
|
211
|
+
Returns:
|
|
212
|
+
Polygon: The polygon object contained in the composite.
|
|
213
|
+
|
|
214
|
+
Raises:
|
|
215
|
+
RuntimeError: If the composite does not contain a Polygon.
|
|
216
|
+
|
|
217
|
+
Example:
|
|
218
|
+
>>> vertices = [Point(0.0, 0.0, 0.0), Point(1.0, 0.0, 0.0), Point(1.0, 1.0, 0.0)]
|
|
219
|
+
>>> polygon = Polygon(vertices)
|
|
220
|
+
>>> composite = Composite(polygon)
|
|
221
|
+
>>> extracted_polygon = composite.as_polygon()
|
|
222
|
+
"""
|
|
52
223
|
def as_pyramid(self) -> Pyramid:
|
|
53
|
-
|
|
224
|
+
"""
|
|
225
|
+
Convert the composite to a Pyramid object.
|
|
226
|
+
|
|
227
|
+
Returns:
|
|
228
|
+
Pyramid: The pyramid object contained in the composite.
|
|
229
|
+
|
|
230
|
+
Raises:
|
|
231
|
+
RuntimeError: If the composite does not contain a Pyramid.
|
|
232
|
+
|
|
233
|
+
Example:
|
|
234
|
+
>>> apex = Point(0.0, 0.0, 1.0)
|
|
235
|
+
>>> base = Polygon([Point(0.0, 0.0, 0.0), Point(1.0, 0.0, 0.0), Point(1.0, 1.0, 0.0)])
|
|
236
|
+
>>> pyramid = Pyramid(base, apex)
|
|
237
|
+
>>> composite = Composite(pyramid)
|
|
238
|
+
>>> extracted_pyramid = composite.as_pyramid()
|
|
239
|
+
"""
|
|
54
240
|
def as_ray(self) -> Ray:
|
|
55
|
-
|
|
241
|
+
"""
|
|
242
|
+
Convert the composite to a Ray object.
|
|
243
|
+
|
|
244
|
+
Returns:
|
|
245
|
+
Ray: The ray object contained in the composite.
|
|
246
|
+
|
|
247
|
+
Raises:
|
|
248
|
+
RuntimeError: If the composite does not contain a Ray.
|
|
249
|
+
|
|
250
|
+
Example:
|
|
251
|
+
>>> ray = Ray(Point(0.0, 0.0, 0.0), np.array([1.0, 0.0, 0.0]))
|
|
252
|
+
>>> composite = Composite(ray)
|
|
253
|
+
>>> extracted_ray = composite.as_ray()
|
|
254
|
+
"""
|
|
56
255
|
def as_segment(self) -> Segment:
|
|
57
|
-
|
|
256
|
+
"""
|
|
257
|
+
Convert the composite to a Segment object.
|
|
258
|
+
|
|
259
|
+
Returns:
|
|
260
|
+
Segment: The segment object contained in the composite.
|
|
261
|
+
|
|
262
|
+
Raises:
|
|
263
|
+
RuntimeError: If the composite does not contain a Segment.
|
|
264
|
+
|
|
265
|
+
Example:
|
|
266
|
+
>>> segment = Segment(Point(0.0, 0.0, 0.0), Point(1.0, 1.0, 1.0))
|
|
267
|
+
>>> composite = Composite(segment)
|
|
268
|
+
>>> extracted_segment = composite.as_segment()
|
|
269
|
+
"""
|
|
58
270
|
def as_sphere(self) -> Sphere:
|
|
59
|
-
|
|
271
|
+
"""
|
|
272
|
+
Convert the composite to a Sphere object.
|
|
273
|
+
|
|
274
|
+
Returns:
|
|
275
|
+
Sphere: The sphere object contained in the composite.
|
|
276
|
+
|
|
277
|
+
Raises:
|
|
278
|
+
RuntimeError: If the composite does not contain a Sphere.
|
|
279
|
+
|
|
280
|
+
Example:
|
|
281
|
+
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0)
|
|
282
|
+
>>> composite = Composite(sphere)
|
|
283
|
+
>>> extracted_sphere = composite.as_sphere()
|
|
284
|
+
"""
|
|
60
285
|
@typing.overload
|
|
61
286
|
def contains(self, object: ostk.mathematics.geometry.d3.Object) -> bool:
|
|
62
|
-
|
|
287
|
+
"""
|
|
288
|
+
Check if the composite contains another geometric object.
|
|
289
|
+
|
|
290
|
+
Args:
|
|
291
|
+
object (Object): The object to check containment for.
|
|
292
|
+
|
|
293
|
+
Returns:
|
|
294
|
+
bool: True if the composite contains the object, False otherwise.
|
|
295
|
+
|
|
296
|
+
Example:
|
|
297
|
+
>>> composite = Composite(Sphere(Point(0.0, 0.0, 0.0), 2.0))
|
|
298
|
+
>>> point = Point(0.5, 0.0, 0.0)
|
|
299
|
+
>>> composite.contains(point) # True
|
|
300
|
+
"""
|
|
63
301
|
@typing.overload
|
|
64
302
|
def contains(self, composite: Composite) -> bool:
|
|
65
|
-
|
|
303
|
+
"""
|
|
304
|
+
Check if the composite contains another composite.
|
|
305
|
+
|
|
306
|
+
Args:
|
|
307
|
+
composite (Composite): The composite to check containment for.
|
|
308
|
+
|
|
309
|
+
Returns:
|
|
310
|
+
bool: True if this composite contains the other composite, False otherwise.
|
|
311
|
+
|
|
312
|
+
Example:
|
|
313
|
+
>>> outer_composite = Composite(Sphere(Point(0.0, 0.0, 0.0), 2.0))
|
|
314
|
+
>>> inner_composite = Composite(Sphere(Point(0.0, 0.0, 0.0), 1.0))
|
|
315
|
+
>>> outer_composite.contains(inner_composite) # True
|
|
316
|
+
"""
|
|
66
317
|
def get_object_count(self) -> int:
|
|
67
|
-
|
|
318
|
+
"""
|
|
319
|
+
Get the number of objects contained in the composite.
|
|
320
|
+
|
|
321
|
+
Returns:
|
|
322
|
+
int: The number of objects in the composite.
|
|
323
|
+
|
|
324
|
+
Example:
|
|
325
|
+
>>> composite = Composite(Point(1.0, 2.0, 3.0))
|
|
326
|
+
>>> count = composite.get_object_count() # 1
|
|
327
|
+
"""
|
|
68
328
|
@typing.overload
|
|
69
329
|
def intersection_with(self, object: ostk.mathematics.geometry.d3.Object) -> ...:
|
|
70
|
-
|
|
330
|
+
"""
|
|
331
|
+
Compute the intersection of the composite with another geometric object.
|
|
332
|
+
|
|
333
|
+
Args:
|
|
334
|
+
object (Object): The object to compute intersection with.
|
|
335
|
+
|
|
336
|
+
Returns:
|
|
337
|
+
Intersection: The intersection result.
|
|
338
|
+
|
|
339
|
+
Example:
|
|
340
|
+
>>> composite = Composite(Sphere(Point(0.0, 0.0, 0.0), 1.0))
|
|
341
|
+
>>> line = Line(Point(-2.0, 0.0, 0.0), np.array([1.0, 0.0, 0.0]))
|
|
342
|
+
>>> intersection = composite.intersection_with(line)
|
|
343
|
+
"""
|
|
71
344
|
@typing.overload
|
|
72
345
|
def intersection_with(self, composite: Composite) -> ...:
|
|
73
|
-
|
|
346
|
+
"""
|
|
347
|
+
Compute the intersection of the composite with another composite.
|
|
348
|
+
|
|
349
|
+
Args:
|
|
350
|
+
composite (Composite): The composite to compute intersection with.
|
|
351
|
+
|
|
352
|
+
Returns:
|
|
353
|
+
Intersection: The intersection result.
|
|
354
|
+
|
|
355
|
+
Example:
|
|
356
|
+
>>> composite1 = Composite(Sphere(Point(0.0, 0.0, 0.0), 1.0))
|
|
357
|
+
>>> composite2 = Composite(Sphere(Point(1.5, 0.0, 0.0), 1.0))
|
|
358
|
+
>>> intersection = composite1.intersection_with(composite2)
|
|
359
|
+
"""
|
|
74
360
|
@typing.overload
|
|
75
361
|
def intersects(self, object: ostk.mathematics.geometry.d3.Object) -> bool:
|
|
76
|
-
|
|
362
|
+
"""
|
|
363
|
+
Check if the composite intersects with another geometric object.
|
|
364
|
+
|
|
365
|
+
Args:
|
|
366
|
+
object (Object): The object to check intersection with.
|
|
367
|
+
|
|
368
|
+
Returns:
|
|
369
|
+
bool: True if the composite intersects the object, False otherwise.
|
|
370
|
+
|
|
371
|
+
Example:
|
|
372
|
+
>>> composite = Composite(Sphere(Point(0.0, 0.0, 0.0), 1.0))
|
|
373
|
+
>>> point = Point(0.5, 0.0, 0.0)
|
|
374
|
+
>>> composite.intersects(point) # True
|
|
375
|
+
"""
|
|
77
376
|
@typing.overload
|
|
78
377
|
def intersects(self, composite: Composite) -> bool:
|
|
79
|
-
|
|
378
|
+
"""
|
|
379
|
+
Check if the composite intersects with another composite.
|
|
380
|
+
|
|
381
|
+
Args:
|
|
382
|
+
composite (Composite): The composite to check intersection with.
|
|
383
|
+
|
|
384
|
+
Returns:
|
|
385
|
+
bool: True if the composites intersect, False otherwise.
|
|
386
|
+
|
|
387
|
+
Example:
|
|
388
|
+
>>> composite1 = Composite(Sphere(Point(0.0, 0.0, 0.0), 1.0))
|
|
389
|
+
>>> composite2 = Composite(Sphere(Point(1.5, 0.0, 0.0), 1.0))
|
|
390
|
+
>>> composite1.intersects(composite2) # True
|
|
391
|
+
"""
|
|
80
392
|
def is_composite(self) -> bool:
|
|
81
|
-
|
|
393
|
+
"""
|
|
394
|
+
Check if the composite contains another Composite object.
|
|
395
|
+
|
|
396
|
+
Returns:
|
|
397
|
+
bool: True if the composite contains a Composite, False otherwise.
|
|
398
|
+
|
|
399
|
+
Example:
|
|
400
|
+
>>> inner_composite = Composite(Point(1.0, 2.0, 3.0))
|
|
401
|
+
>>> outer_composite = Composite(inner_composite)
|
|
402
|
+
>>> outer_composite.is_composite() # True
|
|
403
|
+
"""
|
|
82
404
|
def is_cone(self) -> bool:
|
|
83
|
-
|
|
405
|
+
"""
|
|
406
|
+
Check if the composite contains a Cone object.
|
|
407
|
+
|
|
408
|
+
Returns:
|
|
409
|
+
bool: True if the composite contains a Cone, False otherwise.
|
|
410
|
+
|
|
411
|
+
Example:
|
|
412
|
+
>>> cone = Cone(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]), Angle.degrees(30.0))
|
|
413
|
+
>>> composite = Composite(cone)
|
|
414
|
+
>>> composite.is_cone() # True
|
|
415
|
+
"""
|
|
84
416
|
def is_defined(self) -> bool:
|
|
85
|
-
|
|
417
|
+
"""
|
|
418
|
+
Check if the composite is defined.
|
|
419
|
+
|
|
420
|
+
Returns:
|
|
421
|
+
bool: True if the composite is defined, False otherwise.
|
|
422
|
+
|
|
423
|
+
Example:
|
|
424
|
+
>>> composite = Composite(Point(1.0, 2.0, 3.0))
|
|
425
|
+
>>> composite.is_defined() # True
|
|
426
|
+
"""
|
|
86
427
|
def is_ellipsoid(self) -> bool:
|
|
87
|
-
|
|
428
|
+
"""
|
|
429
|
+
Check if the composite contains an Ellipsoid object.
|
|
430
|
+
|
|
431
|
+
Returns:
|
|
432
|
+
bool: True if the composite contains an Ellipsoid, False otherwise.
|
|
433
|
+
|
|
434
|
+
Example:
|
|
435
|
+
>>> ellipsoid = Ellipsoid(Point(0.0, 0.0, 0.0), 1.0, 0.8, 0.6)
|
|
436
|
+
>>> composite = Composite(ellipsoid)
|
|
437
|
+
>>> composite.is_ellipsoid() # True
|
|
438
|
+
"""
|
|
88
439
|
def is_empty(self) -> bool:
|
|
89
|
-
|
|
440
|
+
"""
|
|
441
|
+
Check if the composite is empty (contains no objects).
|
|
442
|
+
|
|
443
|
+
Returns:
|
|
444
|
+
bool: True if the composite is empty, False otherwise.
|
|
445
|
+
|
|
446
|
+
Example:
|
|
447
|
+
>>> empty_composite = Composite.empty()
|
|
448
|
+
>>> empty_composite.is_empty() # True
|
|
449
|
+
"""
|
|
90
450
|
def is_line(self) -> bool:
|
|
91
|
-
|
|
451
|
+
"""
|
|
452
|
+
Check if the composite contains a Line object.
|
|
453
|
+
|
|
454
|
+
Returns:
|
|
455
|
+
bool: True if the composite contains a Line, False otherwise.
|
|
456
|
+
|
|
457
|
+
Example:
|
|
458
|
+
>>> line = Line(Point(0.0, 0.0, 0.0), np.array([1.0, 0.0, 0.0]))
|
|
459
|
+
>>> composite = Composite(line)
|
|
460
|
+
>>> composite.is_line() # True
|
|
461
|
+
"""
|
|
92
462
|
def is_line_string(self) -> bool:
|
|
93
|
-
|
|
463
|
+
"""
|
|
464
|
+
Check if the composite contains a LineString object.
|
|
465
|
+
|
|
466
|
+
Returns:
|
|
467
|
+
bool: True if the composite contains a LineString, False otherwise.
|
|
468
|
+
|
|
469
|
+
Example:
|
|
470
|
+
>>> points = [Point(0.0, 0.0, 0.0), Point(1.0, 1.0, 1.0), Point(2.0, 2.0, 2.0)]
|
|
471
|
+
>>> line_string = LineString(points)
|
|
472
|
+
>>> composite = Composite(line_string)
|
|
473
|
+
>>> composite.is_line_string() # True
|
|
474
|
+
"""
|
|
94
475
|
def is_plane(self) -> bool:
|
|
95
|
-
|
|
476
|
+
"""
|
|
477
|
+
Check if the composite contains a Plane object.
|
|
478
|
+
|
|
479
|
+
Returns:
|
|
480
|
+
bool: True if the composite contains a Plane, False otherwise.
|
|
481
|
+
|
|
482
|
+
Example:
|
|
483
|
+
>>> plane = Plane(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]))
|
|
484
|
+
>>> composite = Composite(plane)
|
|
485
|
+
>>> composite.is_plane() # True
|
|
486
|
+
"""
|
|
96
487
|
def is_point(self) -> bool:
|
|
97
|
-
|
|
488
|
+
"""
|
|
489
|
+
Check if the composite contains a Point object.
|
|
490
|
+
|
|
491
|
+
Returns:
|
|
492
|
+
bool: True if the composite contains a Point, False otherwise.
|
|
493
|
+
|
|
494
|
+
Example:
|
|
495
|
+
>>> composite = Composite(Point(1.0, 2.0, 3.0))
|
|
496
|
+
>>> composite.is_point() # True
|
|
497
|
+
"""
|
|
98
498
|
def is_point_set(self) -> bool:
|
|
99
|
-
|
|
499
|
+
"""
|
|
500
|
+
Check if the composite contains a PointSet object.
|
|
501
|
+
|
|
502
|
+
Returns:
|
|
503
|
+
bool: True if the composite contains a PointSet, False otherwise.
|
|
504
|
+
|
|
505
|
+
Example:
|
|
506
|
+
>>> point_set = PointSet([Point(1.0, 2.0, 3.0), Point(4.0, 5.0, 6.0)])
|
|
507
|
+
>>> composite = Composite(point_set)
|
|
508
|
+
>>> composite.is_point_set() # True
|
|
509
|
+
"""
|
|
100
510
|
def is_polygon(self) -> bool:
|
|
101
|
-
|
|
511
|
+
"""
|
|
512
|
+
Check if the composite contains a Polygon object.
|
|
513
|
+
|
|
514
|
+
Returns:
|
|
515
|
+
bool: True if the composite contains a Polygon, False otherwise.
|
|
516
|
+
|
|
517
|
+
Example:
|
|
518
|
+
>>> vertices = [Point(0.0, 0.0, 0.0), Point(1.0, 0.0, 0.0), Point(1.0, 1.0, 0.0)]
|
|
519
|
+
>>> polygon = Polygon(vertices)
|
|
520
|
+
>>> composite = Composite(polygon)
|
|
521
|
+
>>> composite.is_polygon() # True
|
|
522
|
+
"""
|
|
102
523
|
def is_pyramid(self) -> bool:
|
|
103
|
-
|
|
524
|
+
"""
|
|
525
|
+
Check if the composite contains a Pyramid object.
|
|
526
|
+
|
|
527
|
+
Returns:
|
|
528
|
+
bool: True if the composite contains a Pyramid, False otherwise.
|
|
529
|
+
|
|
530
|
+
Example:
|
|
531
|
+
>>> apex = Point(0.0, 0.0, 1.0)
|
|
532
|
+
>>> base = Polygon([Point(0.0, 0.0, 0.0), Point(1.0, 0.0, 0.0), Point(1.0, 1.0, 0.0)])
|
|
533
|
+
>>> pyramid = Pyramid(base, apex)
|
|
534
|
+
>>> composite = Composite(pyramid)
|
|
535
|
+
>>> composite.is_pyramid() # True
|
|
536
|
+
"""
|
|
104
537
|
def is_ray(self) -> bool:
|
|
105
|
-
|
|
538
|
+
"""
|
|
539
|
+
Check if the composite contains a Ray object.
|
|
540
|
+
|
|
541
|
+
Returns:
|
|
542
|
+
bool: True if the composite contains a Ray, False otherwise.
|
|
543
|
+
|
|
544
|
+
Example:
|
|
545
|
+
>>> ray = Ray(Point(0.0, 0.0, 0.0), np.array([1.0, 0.0, 0.0]))
|
|
546
|
+
>>> composite = Composite(ray)
|
|
547
|
+
>>> composite.is_ray() # True
|
|
548
|
+
"""
|
|
106
549
|
def is_segment(self) -> bool:
|
|
107
|
-
|
|
550
|
+
"""
|
|
551
|
+
Check if the composite contains a Segment object.
|
|
552
|
+
|
|
553
|
+
Returns:
|
|
554
|
+
bool: True if the composite contains a Segment, False otherwise.
|
|
555
|
+
|
|
556
|
+
Example:
|
|
557
|
+
>>> segment = Segment(Point(0.0, 0.0, 0.0), Point(1.0, 1.0, 1.0))
|
|
558
|
+
>>> composite = Composite(segment)
|
|
559
|
+
>>> composite.is_segment() # True
|
|
560
|
+
"""
|
|
108
561
|
def is_sphere(self) -> bool:
|
|
109
|
-
|
|
562
|
+
"""
|
|
563
|
+
Check if the composite contains a Sphere object.
|
|
564
|
+
|
|
565
|
+
Returns:
|
|
566
|
+
bool: True if the composite contains a Sphere, False otherwise.
|
|
567
|
+
|
|
568
|
+
Example:
|
|
569
|
+
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0)
|
|
570
|
+
>>> composite = Composite(sphere)
|
|
571
|
+
>>> composite.is_sphere() # True
|
|
572
|
+
"""
|
|
110
573
|
class Cone(ostk.mathematics.geometry.d3.Object):
|
|
111
574
|
__hash__: typing.ClassVar[None] = None
|
|
112
575
|
@staticmethod
|
|
113
576
|
def undefined() -> Cone:
|
|
114
|
-
|
|
577
|
+
"""
|
|
578
|
+
Create an undefined cone.
|
|
579
|
+
|
|
580
|
+
Returns:
|
|
581
|
+
Cone: An undefined cone object.
|
|
582
|
+
|
|
583
|
+
Example:
|
|
584
|
+
>>> undefined_cone = Cone.undefined()
|
|
585
|
+
>>> undefined_cone.is_defined() # False
|
|
586
|
+
"""
|
|
115
587
|
def __eq__(self, arg0: Cone) -> bool:
|
|
116
588
|
...
|
|
117
589
|
def __init__(self, apex: Point, axis: numpy.ndarray[numpy.float64[3, 1]], angle: typing.Any) -> None:
|
|
118
|
-
|
|
590
|
+
"""
|
|
591
|
+
Create a 3D cone with specified apex, axis, and angle.
|
|
592
|
+
|
|
593
|
+
Args:
|
|
594
|
+
apex (Point): The apex (tip) point of the cone.
|
|
595
|
+
axis (np.array): The axis direction vector of the cone.
|
|
596
|
+
angle (Angle): The half-angle of the cone opening.
|
|
597
|
+
|
|
598
|
+
Example:
|
|
599
|
+
>>> apex = Point(0.0, 0.0, 0.0)
|
|
600
|
+
>>> axis = np.array([0.0, 0.0, 1.0])
|
|
601
|
+
>>> angle = Angle.degrees(30.0)
|
|
602
|
+
>>> cone = Cone(apex, axis, angle)
|
|
603
|
+
"""
|
|
119
604
|
def __ne__(self, arg0: Cone) -> bool:
|
|
120
605
|
...
|
|
121
606
|
def __repr__(self) -> str:
|
|
@@ -123,61 +608,297 @@ class Cone(ostk.mathematics.geometry.d3.Object):
|
|
|
123
608
|
def __str__(self) -> str:
|
|
124
609
|
...
|
|
125
610
|
def apply_transformation(self, transformation: typing.Any) -> None:
|
|
126
|
-
|
|
611
|
+
"""
|
|
612
|
+
Apply a transformation to the cone in place.
|
|
613
|
+
|
|
614
|
+
Args:
|
|
615
|
+
transformation (Transformation): The transformation to apply.
|
|
616
|
+
|
|
617
|
+
Example:
|
|
618
|
+
>>> cone = Cone(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]), Angle.degrees(30.0))
|
|
619
|
+
>>> transformation = Translation([1.0, 2.0, 3.0])
|
|
620
|
+
>>> cone.apply_transformation(transformation)
|
|
621
|
+
"""
|
|
127
622
|
@typing.overload
|
|
128
623
|
def contains(self, point: Point) -> bool:
|
|
129
|
-
|
|
624
|
+
"""
|
|
625
|
+
Check if the cone contains a point.
|
|
626
|
+
|
|
627
|
+
Args:
|
|
628
|
+
point (Point): The point to check.
|
|
629
|
+
|
|
630
|
+
Returns:
|
|
631
|
+
bool: True if the cone contains the point, False otherwise.
|
|
632
|
+
|
|
633
|
+
Example:
|
|
634
|
+
>>> cone = Cone(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]), Angle.degrees(30.0))
|
|
635
|
+
>>> cone.contains(Point(0.1, 0.1, 1.0)) # True for point inside cone
|
|
636
|
+
"""
|
|
130
637
|
@typing.overload
|
|
131
638
|
def contains(self, point_set: PointSet) -> bool:
|
|
132
|
-
|
|
639
|
+
"""
|
|
640
|
+
Check if the cone contains a point set.
|
|
641
|
+
|
|
642
|
+
Args:
|
|
643
|
+
point_set (PointSet): The point set to check.
|
|
644
|
+
|
|
645
|
+
Returns:
|
|
646
|
+
bool: True if the cone contains the point set, False otherwise.
|
|
647
|
+
|
|
648
|
+
Example:
|
|
649
|
+
>>> cone = Cone(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]), Angle.degrees(30.0))
|
|
650
|
+
>>> cone.contains(PointSet([Point(0.1, 0.1, 1.0), Point(0.2, 0.2, 1.0)])) # True for points inside cone
|
|
651
|
+
"""
|
|
133
652
|
@typing.overload
|
|
134
653
|
def contains(self, segment: Segment) -> bool:
|
|
135
|
-
|
|
654
|
+
"""
|
|
655
|
+
Check if the cone contains a segment.
|
|
656
|
+
|
|
657
|
+
Args:
|
|
658
|
+
segment (Segment): The segment to check.
|
|
659
|
+
|
|
660
|
+
Returns:
|
|
661
|
+
bool: True if the cone contains the segment, False otherwise.
|
|
662
|
+
|
|
663
|
+
Example:
|
|
664
|
+
>>> cone = Cone(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]), Angle.degrees(30.0))
|
|
665
|
+
>>> cone.contains(Segment(Point(0.1, 0.1, 1.0), Point(0.2, 0.2, 1.0))) # True for segment inside cone
|
|
666
|
+
"""
|
|
136
667
|
@typing.overload
|
|
137
668
|
def contains(self, ray: Ray) -> bool:
|
|
138
|
-
|
|
669
|
+
"""
|
|
670
|
+
Check if the cone contains a ray.
|
|
671
|
+
|
|
672
|
+
Args:
|
|
673
|
+
ray (Ray): The ray to check.
|
|
674
|
+
|
|
675
|
+
Returns:
|
|
676
|
+
bool: True if the cone contains the ray, False otherwise.
|
|
677
|
+
|
|
678
|
+
Example:
|
|
679
|
+
>>> cone = Cone(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]), Angle.degrees(30.0))
|
|
680
|
+
>>> cone.contains(Ray(Point(0.1, 0.1, 1.0), np.array([0.0, 0.0, 1.0]))) # True for ray inside cone
|
|
681
|
+
"""
|
|
139
682
|
@typing.overload
|
|
140
683
|
def contains(self, sphere: Sphere) -> bool:
|
|
141
|
-
|
|
684
|
+
"""
|
|
685
|
+
Check if the cone contains a sphere.
|
|
686
|
+
|
|
687
|
+
Args:
|
|
688
|
+
sphere (Sphere): The sphere to check.
|
|
689
|
+
|
|
690
|
+
Returns:
|
|
691
|
+
bool: True if the cone contains the sphere, False otherwise.
|
|
692
|
+
|
|
693
|
+
Example:
|
|
694
|
+
>>> cone = Cone(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]), Angle.degrees(30.0))
|
|
695
|
+
>>> cone.contains(Sphere(Point(0.1, 0.1, 1.0), 0.1)) # True for sphere inside cone
|
|
696
|
+
"""
|
|
142
697
|
@typing.overload
|
|
143
698
|
def contains(self, ellipsoid: Ellipsoid) -> bool:
|
|
144
|
-
|
|
699
|
+
"""
|
|
700
|
+
Check if the cone contains an ellipsoid.
|
|
701
|
+
Args:
|
|
702
|
+
ellipsoid (Ellipsoid): The ellipsoid to check.
|
|
703
|
+
|
|
704
|
+
Returns:
|
|
705
|
+
bool: True if the cone contains the ellipsoid, False otherwise.
|
|
706
|
+
|
|
707
|
+
Example:
|
|
708
|
+
>>> cone = Cone(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]), Angle.degrees(30.0))
|
|
709
|
+
>>> cone.contains(Ellipsoid(Point(0.1, 0.1, 1.0), 0.1, 0.1, 0.1)) # True for ellipsoid inside cone
|
|
710
|
+
"""
|
|
145
711
|
def distance_to(self, point: Point) -> ostk.core.type.Real:
|
|
146
|
-
|
|
712
|
+
"""
|
|
713
|
+
Calculate the distance from the cone to a point.
|
|
714
|
+
|
|
715
|
+
Args:
|
|
716
|
+
point (Point): The point to calculate distance to.
|
|
717
|
+
|
|
718
|
+
Returns:
|
|
719
|
+
float: The minimum distance from the cone surface to the point.
|
|
720
|
+
|
|
721
|
+
Example:
|
|
722
|
+
>>> cone = Cone(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]), Angle.degrees(30.0))
|
|
723
|
+
>>> distance = cone.distance_to(Point(2.0, 0.0, 0.0))
|
|
724
|
+
"""
|
|
147
725
|
def get_angle(self) -> ...:
|
|
148
|
-
|
|
726
|
+
"""
|
|
727
|
+
Get the half-angle of the cone opening.
|
|
728
|
+
|
|
729
|
+
Returns:
|
|
730
|
+
Angle: The half-angle of the cone.
|
|
731
|
+
|
|
732
|
+
Example:
|
|
733
|
+
>>> cone = Cone(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]), Angle.degrees(30.0))
|
|
734
|
+
>>> angle = cone.get_angle() # 30 degrees
|
|
735
|
+
"""
|
|
149
736
|
def get_apex(self) -> Point:
|
|
150
|
-
|
|
737
|
+
"""
|
|
738
|
+
Get the apex (tip) point of the cone.
|
|
739
|
+
|
|
740
|
+
Returns:
|
|
741
|
+
Point: The apex point of the cone.
|
|
742
|
+
|
|
743
|
+
Example:
|
|
744
|
+
>>> cone = Cone(Point(1.0, 2.0, 3.0), np.array([0.0, 0.0, 1.0]), Angle.degrees(30.0))
|
|
745
|
+
>>> apex = cone.get_apex() # Point(1.0, 2.0, 3.0)
|
|
746
|
+
"""
|
|
151
747
|
def get_axis(self) -> numpy.ndarray[numpy.float64[3, 1]]:
|
|
152
|
-
|
|
748
|
+
"""
|
|
749
|
+
Get the axis direction vector of the cone.
|
|
750
|
+
|
|
751
|
+
Returns:
|
|
752
|
+
Vector3d: The axis direction vector.
|
|
753
|
+
|
|
754
|
+
Example:
|
|
755
|
+
>>> cone = Cone(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]), Angle.degrees(30.0))
|
|
756
|
+
>>> axis = cone.get_axis() # [0.0, 0.0, 1.0]
|
|
757
|
+
"""
|
|
153
758
|
def get_rays_of_lateral_surface(self, ray_count: int = 0) -> list[Ray]:
|
|
154
|
-
|
|
759
|
+
"""
|
|
760
|
+
Get rays representing the lateral surface of the cone.
|
|
761
|
+
|
|
762
|
+
Args:
|
|
763
|
+
ray_count (int): Number of rays to generate around the surface.
|
|
764
|
+
|
|
765
|
+
Returns:
|
|
766
|
+
list: Array of Ray objects representing the lateral surface.
|
|
767
|
+
|
|
768
|
+
Example:
|
|
769
|
+
>>> cone = Cone(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]), Angle.degrees(30.0))
|
|
770
|
+
>>> rays = cone.get_rays_of_lateral_surface(8)
|
|
771
|
+
"""
|
|
155
772
|
@typing.overload
|
|
156
773
|
def intersection_with(self, sphere: Sphere, only_in_sight: bool = False, discretization_level: int = 40) -> ...:
|
|
157
|
-
|
|
774
|
+
"""
|
|
775
|
+
Compute intersection of cone with sphere.
|
|
776
|
+
|
|
777
|
+
Args:
|
|
778
|
+
sphere (Sphere): The sphere to intersect with.
|
|
779
|
+
only_in_sight (bool): If true, only return intersection points that are in sight.
|
|
780
|
+
discretization_level (int): The discretization level for the intersection.
|
|
781
|
+
|
|
782
|
+
Returns:
|
|
783
|
+
Intersection: The intersection of the cone with the sphere.
|
|
784
|
+
|
|
785
|
+
Example:
|
|
786
|
+
>>> cone = Cone(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]), Angle.degrees(30.0))
|
|
787
|
+
>>> sphere = Sphere(Point(2.0, 0.0, 0.0), 1.0)
|
|
788
|
+
>>> intersection = cone.intersection_with(sphere)
|
|
789
|
+
>>> intersection.get_point() # Point(2.0, 0.0, 0.0)
|
|
790
|
+
"""
|
|
158
791
|
@typing.overload
|
|
159
792
|
def intersection_with(self, ellipsoid: Ellipsoid, only_in_sight: bool = False, discretization_level: int = 40) -> ...:
|
|
160
|
-
|
|
793
|
+
"""
|
|
794
|
+
Compute intersection of cone with ellipsoid.
|
|
795
|
+
|
|
796
|
+
Args:
|
|
797
|
+
ellipsoid (Ellipsoid): The ellipsoid to intersect with.
|
|
798
|
+
only_in_sight (bool): If true, only return intersection points that are in sight.
|
|
799
|
+
discretization_level (int): The discretization level for the intersection.
|
|
800
|
+
|
|
801
|
+
Returns:
|
|
802
|
+
Intersection: The intersection of the cone with the ellipsoid.
|
|
803
|
+
|
|
804
|
+
Example:
|
|
805
|
+
>>> cone = Cone(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]), Angle.degrees(30.0))
|
|
806
|
+
>>> ellipsoid = Ellipsoid(Point(2.0, 0.0, 0.0), 1.0, 1.0, 1.0)
|
|
807
|
+
>>> intersection = cone.intersection_with(ellipsoid)
|
|
808
|
+
>>> intersection.get_point() # Point(2.0, 0.0, 0.0)
|
|
809
|
+
"""
|
|
161
810
|
@typing.overload
|
|
162
811
|
def intersects(self, sphere: Sphere, discretization_level: int = 40) -> bool:
|
|
163
|
-
|
|
812
|
+
"""
|
|
813
|
+
Check if the cone intersects with a sphere.
|
|
814
|
+
|
|
815
|
+
Args:
|
|
816
|
+
sphere (Sphere): The sphere to check intersection with.
|
|
817
|
+
discretization_level (int): Level of discretization for intersection calculation.
|
|
818
|
+
|
|
819
|
+
Returns:
|
|
820
|
+
bool: True if the cone intersects the sphere, False otherwise.
|
|
821
|
+
|
|
822
|
+
Example:
|
|
823
|
+
>>> cone = Cone(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]), Angle.degrees(30.0))
|
|
824
|
+
>>> sphere = Sphere(Point(1.0, 0.0, 1.0), 0.5)
|
|
825
|
+
>>> cone.intersects(sphere)
|
|
826
|
+
"""
|
|
164
827
|
@typing.overload
|
|
165
828
|
def intersects(self, ellipsoid: Ellipsoid, discretization_level: int = 40) -> bool:
|
|
166
|
-
|
|
829
|
+
"""
|
|
830
|
+
Check if the cone intersects with an ellipsoid.
|
|
831
|
+
|
|
832
|
+
Args:
|
|
833
|
+
ellipsoid (Ellipsoid): The ellipsoid to check intersection with.
|
|
834
|
+
discretization_level (int): Level of discretization for intersection calculation.
|
|
835
|
+
|
|
836
|
+
Returns:
|
|
837
|
+
bool: True if the cone intersects the ellipsoid, False otherwise.
|
|
838
|
+
|
|
839
|
+
Example:
|
|
840
|
+
>>> cone = Cone(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]), Angle.degrees(30.0))
|
|
841
|
+
>>> ellipsoid = Ellipsoid(Point(1.0, 0.0, 1.0), 1.0, 0.8, 0.6)
|
|
842
|
+
>>> cone.intersects(ellipsoid)
|
|
843
|
+
"""
|
|
167
844
|
def is_defined(self) -> bool:
|
|
168
|
-
|
|
845
|
+
"""
|
|
846
|
+
Check if the cone is defined.
|
|
847
|
+
|
|
848
|
+
Returns:
|
|
849
|
+
bool: True if the cone is defined, False otherwise.
|
|
850
|
+
|
|
851
|
+
Example:
|
|
852
|
+
>>> cone = Cone(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]), Angle.degrees(30.0))
|
|
853
|
+
>>> cone.is_defined() # True
|
|
854
|
+
"""
|
|
169
855
|
class Cuboid(ostk.mathematics.geometry.d3.Object):
|
|
170
856
|
__hash__: typing.ClassVar[None] = None
|
|
171
857
|
@staticmethod
|
|
172
858
|
def cube(center: Point, extent: ostk.core.type.Real) -> Cuboid:
|
|
173
|
-
|
|
859
|
+
"""
|
|
860
|
+
Create a cube (equal extents along all axes) centered at a point.
|
|
861
|
+
|
|
862
|
+
Args:
|
|
863
|
+
center (Point): The center point of the cube.
|
|
864
|
+
extent (float): The half-extent along all axes.
|
|
865
|
+
|
|
866
|
+
Returns:
|
|
867
|
+
Cuboid: A cuboid representing a cube.
|
|
868
|
+
|
|
869
|
+
Example:
|
|
870
|
+
>>> center = Point(0.0, 0.0, 0.0)
|
|
871
|
+
>>> cube = Cuboid.cube(center, 1.0) # 2x2x2 cube
|
|
872
|
+
"""
|
|
174
873
|
@staticmethod
|
|
175
874
|
def undefined() -> Cuboid:
|
|
176
|
-
|
|
875
|
+
"""
|
|
876
|
+
Create an undefined cuboid.
|
|
877
|
+
|
|
878
|
+
Returns:
|
|
879
|
+
Cuboid: An undefined cuboid object.
|
|
880
|
+
|
|
881
|
+
Example:
|
|
882
|
+
>>> undefined_cuboid = Cuboid.undefined()
|
|
883
|
+
>>> undefined_cuboid.is_defined() # False
|
|
884
|
+
"""
|
|
177
885
|
def __eq__(self, arg0: Cuboid) -> bool:
|
|
178
886
|
...
|
|
179
887
|
def __init__(self, center: Point, axes: list, extent: list) -> None:
|
|
180
|
-
|
|
888
|
+
"""
|
|
889
|
+
Create a 3D cuboid with specified center, axes, and extents.
|
|
890
|
+
|
|
891
|
+
Args:
|
|
892
|
+
center (Point): The center point of the cuboid.
|
|
893
|
+
axes (list): List of three Vector3d objects defining the cuboid's orientation.
|
|
894
|
+
extent (list): List of three float values defining the half-extents along each axis.
|
|
895
|
+
|
|
896
|
+
Example:
|
|
897
|
+
>>> center = Point(0.0, 0.0, 0.0)
|
|
898
|
+
>>> axes = [np.array([1.0, 0.0, 0.0]), np.array([0.0, 1.0, 0.0]), np.array([0.0, 0.0, 1.0])]
|
|
899
|
+
>>> extent = [1.0, 2.0, 3.0]
|
|
900
|
+
>>> cuboid = Cuboid(center, axes, extent)
|
|
901
|
+
"""
|
|
181
902
|
def __ne__(self, arg0: Cuboid) -> bool:
|
|
182
903
|
...
|
|
183
904
|
def __repr__(self) -> str:
|
|
@@ -185,52 +906,236 @@ class Cuboid(ostk.mathematics.geometry.d3.Object):
|
|
|
185
906
|
def __str__(self) -> str:
|
|
186
907
|
...
|
|
187
908
|
def apply_transformation(self, transformation: typing.Any) -> None:
|
|
188
|
-
|
|
909
|
+
"""
|
|
910
|
+
Apply a transformation to the cuboid in place.
|
|
911
|
+
|
|
912
|
+
Args:
|
|
913
|
+
transformation (Transformation): The transformation to apply.
|
|
914
|
+
|
|
915
|
+
Example:
|
|
916
|
+
>>> cuboid = Cuboid(center, axes, extent)
|
|
917
|
+
>>> transformation = Translation([1.0, 2.0, 3.0])
|
|
918
|
+
>>> cuboid.apply_transformation(transformation)
|
|
919
|
+
"""
|
|
189
920
|
def get_center(self) -> Point:
|
|
190
|
-
|
|
921
|
+
"""
|
|
922
|
+
Get the center point of the cuboid.
|
|
923
|
+
|
|
924
|
+
Returns:
|
|
925
|
+
Point: The center point of the cuboid.
|
|
926
|
+
|
|
927
|
+
Example:
|
|
928
|
+
>>> cuboid = Cuboid(Point(1.0, 2.0, 3.0), axes, extent)
|
|
929
|
+
>>> center = cuboid.get_center() # Point(1.0, 2.0, 3.0)
|
|
930
|
+
"""
|
|
191
931
|
def get_first_axis(self) -> numpy.ndarray[numpy.float64[3, 1]]:
|
|
192
|
-
|
|
932
|
+
"""
|
|
933
|
+
Get the first axis vector of the cuboid.
|
|
934
|
+
|
|
935
|
+
Returns:
|
|
936
|
+
Vector3d: The first axis direction vector.
|
|
937
|
+
|
|
938
|
+
Example:
|
|
939
|
+
>>> cuboid = Cuboid(center, axes, extent)
|
|
940
|
+
>>> first_axis = cuboid.get_first_axis()
|
|
941
|
+
"""
|
|
193
942
|
def get_first_extent(self) -> ostk.core.type.Real:
|
|
194
|
-
|
|
943
|
+
"""
|
|
944
|
+
Get the first half-extent of the cuboid.
|
|
945
|
+
|
|
946
|
+
Returns:
|
|
947
|
+
float: The half-extent along the first axis.
|
|
948
|
+
|
|
949
|
+
Example:
|
|
950
|
+
>>> cuboid = Cuboid(center, axes, [1.0, 2.0, 3.0])
|
|
951
|
+
>>> first_extent = cuboid.get_first_extent() # 1.0
|
|
952
|
+
"""
|
|
195
953
|
def get_second_axis(self) -> numpy.ndarray[numpy.float64[3, 1]]:
|
|
196
|
-
|
|
954
|
+
"""
|
|
955
|
+
Get the second axis vector of the cuboid.
|
|
956
|
+
|
|
957
|
+
Returns:
|
|
958
|
+
Vector3d: The second axis direction vector.
|
|
959
|
+
|
|
960
|
+
Example:
|
|
961
|
+
>>> cuboid = Cuboid(center, axes, extent)
|
|
962
|
+
>>> second_axis = cuboid.get_second_axis()
|
|
963
|
+
"""
|
|
197
964
|
def get_second_extent(self) -> ostk.core.type.Real:
|
|
198
|
-
|
|
965
|
+
"""
|
|
966
|
+
Get the second half-extent of the cuboid.
|
|
967
|
+
|
|
968
|
+
Returns:
|
|
969
|
+
float: The half-extent along the second axis.
|
|
970
|
+
|
|
971
|
+
Example:
|
|
972
|
+
>>> cuboid = Cuboid(center, axes, [1.0, 2.0, 3.0])
|
|
973
|
+
>>> second_extent = cuboid.get_second_extent() # 2.0
|
|
974
|
+
"""
|
|
199
975
|
def get_third_axis(self) -> numpy.ndarray[numpy.float64[3, 1]]:
|
|
200
|
-
|
|
976
|
+
"""
|
|
977
|
+
Get the third axis vector of the cuboid.
|
|
978
|
+
|
|
979
|
+
Returns:
|
|
980
|
+
Vector3d: The third axis direction vector.
|
|
981
|
+
|
|
982
|
+
Example:
|
|
983
|
+
>>> cuboid = Cuboid(center, axes, extent)
|
|
984
|
+
>>> third_axis = cuboid.get_third_axis()
|
|
985
|
+
"""
|
|
201
986
|
def get_third_extent(self) -> ostk.core.type.Real:
|
|
202
|
-
|
|
987
|
+
"""
|
|
988
|
+
Get the third half-extent of the cuboid.
|
|
989
|
+
|
|
990
|
+
Returns:
|
|
991
|
+
float: The half-extent along the third axis.
|
|
992
|
+
|
|
993
|
+
Example:
|
|
994
|
+
>>> cuboid = Cuboid(center, axes, [1.0, 2.0, 3.0])
|
|
995
|
+
>>> third_extent = cuboid.get_third_extent() # 3.0
|
|
996
|
+
"""
|
|
203
997
|
def get_vertices(self) -> list[Point]:
|
|
204
|
-
|
|
998
|
+
"""
|
|
999
|
+
Get all vertices of the cuboid.
|
|
1000
|
+
|
|
1001
|
+
Returns:
|
|
1002
|
+
list: Array of Point objects representing the 8 vertices of the cuboid.
|
|
1003
|
+
|
|
1004
|
+
Example:
|
|
1005
|
+
>>> cuboid = Cuboid(center, axes, extent)
|
|
1006
|
+
>>> vertices = cuboid.get_vertices() # 8 corner points
|
|
1007
|
+
"""
|
|
205
1008
|
@typing.overload
|
|
206
1009
|
def intersects(self, point: Point) -> bool:
|
|
207
|
-
|
|
1010
|
+
"""
|
|
1011
|
+
Check if the cuboid intersects a point.
|
|
1012
|
+
|
|
1013
|
+
Args:
|
|
1014
|
+
point (Point): The point to check.
|
|
1015
|
+
|
|
1016
|
+
Returns:
|
|
1017
|
+
bool: True if the cuboid intersects the point, False otherwise.
|
|
1018
|
+
|
|
1019
|
+
Example:
|
|
1020
|
+
>>> cuboid = Cuboid(Point(0.0, 0.0, 0.0), axes, extent)
|
|
1021
|
+
>>> cuboid.intersects(Point(1.0, 2.0, 3.0)) # True
|
|
1022
|
+
"""
|
|
208
1023
|
@typing.overload
|
|
209
1024
|
def intersects(self, point_set: PointSet) -> bool:
|
|
210
|
-
|
|
1025
|
+
"""
|
|
1026
|
+
Check if the cuboid intersects a point set.
|
|
1027
|
+
|
|
1028
|
+
Args:
|
|
1029
|
+
point_set (PointSet): The point set to check.
|
|
1030
|
+
|
|
1031
|
+
Returns:
|
|
1032
|
+
bool: True if the cuboid intersects the point set, False otherwise.
|
|
1033
|
+
|
|
1034
|
+
Example:
|
|
1035
|
+
>>> cuboid = Cuboid(Point(0.0, 0.0, 0.0), axes, extent)
|
|
1036
|
+
>>> cuboid.intersects(PointSet([Point(1.0, 2.0, 3.0), Point(4.0, 5.0, 6.0)])) # True
|
|
1037
|
+
"""
|
|
211
1038
|
@typing.overload
|
|
212
1039
|
def intersects(self, line: Line) -> bool:
|
|
213
|
-
|
|
1040
|
+
"""
|
|
1041
|
+
Check if the cuboid intersects a line.
|
|
1042
|
+
|
|
1043
|
+
Args:
|
|
1044
|
+
line (Line): The line to check.
|
|
1045
|
+
|
|
1046
|
+
Returns:
|
|
1047
|
+
bool: True if the cuboid intersects the line, False otherwise.
|
|
1048
|
+
|
|
1049
|
+
Example:
|
|
1050
|
+
>>> cuboid = Cuboid(Point(0.0, 0.0, 0.0), axes, extent)
|
|
1051
|
+
>>> cuboid.intersects(Line(Point(1.0, 2.0, 3.0), Point(4.0, 5.0, 6.0))) # True
|
|
1052
|
+
"""
|
|
214
1053
|
@typing.overload
|
|
215
1054
|
def intersects(self, cuboid: Cuboid) -> bool:
|
|
216
|
-
|
|
1055
|
+
"""
|
|
1056
|
+
Check if the cuboid intersects a cuboid.
|
|
1057
|
+
|
|
1058
|
+
Args:
|
|
1059
|
+
cuboid (Cuboid): The cuboid to check.
|
|
1060
|
+
|
|
1061
|
+
Returns:
|
|
1062
|
+
bool: True if the cuboid intersects the cuboid, False otherwise.
|
|
1063
|
+
"""
|
|
217
1064
|
def is_defined(self) -> bool:
|
|
218
|
-
|
|
1065
|
+
"""
|
|
1066
|
+
Check if the cuboid is defined.
|
|
1067
|
+
|
|
1068
|
+
Returns:
|
|
1069
|
+
bool: True if the cuboid is defined, False otherwise.
|
|
1070
|
+
|
|
1071
|
+
Example:
|
|
1072
|
+
>>> cuboid = Cuboid(center, axes, extent)
|
|
1073
|
+
>>> cuboid.is_defined() # True
|
|
1074
|
+
"""
|
|
219
1075
|
def is_near(self, arg0: Cuboid, arg1: ostk.core.type.Real) -> bool:
|
|
220
|
-
|
|
1076
|
+
"""
|
|
1077
|
+
Check if this cuboid is near another cuboid.
|
|
1078
|
+
|
|
1079
|
+
Args:
|
|
1080
|
+
cuboid (Cuboid): The cuboid to compare with.
|
|
1081
|
+
tolerance (float): The tolerance for comparison.
|
|
1082
|
+
|
|
1083
|
+
Returns:
|
|
1084
|
+
bool: True if cuboids are within tolerance, False otherwise.
|
|
1085
|
+
|
|
1086
|
+
Example:
|
|
1087
|
+
>>> cuboid1 = Cuboid(center1, axes1, extent1)
|
|
1088
|
+
>>> cuboid2 = Cuboid(center2, axes2, extent2)
|
|
1089
|
+
>>> cuboid1.is_near(cuboid2, 1e-6)
|
|
1090
|
+
"""
|
|
221
1091
|
class Ellipsoid(ostk.mathematics.geometry.d3.Object):
|
|
222
1092
|
__hash__: typing.ClassVar[None] = None
|
|
223
1093
|
@staticmethod
|
|
224
1094
|
def undefined() -> Ellipsoid:
|
|
225
|
-
|
|
1095
|
+
"""
|
|
1096
|
+
Create an undefined ellipsoid.
|
|
1097
|
+
|
|
1098
|
+
Returns:
|
|
1099
|
+
Ellipsoid: An undefined ellipsoid object.
|
|
1100
|
+
|
|
1101
|
+
Example:
|
|
1102
|
+
>>> undefined_ellipsoid = Ellipsoid.undefined()
|
|
1103
|
+
>>> undefined_ellipsoid.is_defined() # False
|
|
1104
|
+
"""
|
|
226
1105
|
def __eq__(self, arg0: Ellipsoid) -> bool:
|
|
227
1106
|
...
|
|
228
1107
|
@typing.overload
|
|
229
1108
|
def __init__(self, center: Point, first_principal_semi_axis: ostk.core.type.Real, second_principal_semi_axis: ostk.core.type.Real, third_principal_semi_axis: ostk.core.type.Real) -> None:
|
|
230
|
-
|
|
1109
|
+
"""
|
|
1110
|
+
Create an ellipsoid with specified center and semi-axes.
|
|
1111
|
+
|
|
1112
|
+
Args:
|
|
1113
|
+
center (Point): The center point of the ellipsoid.
|
|
1114
|
+
first_principal_semi_axis (float): The first principal semi-axis length.
|
|
1115
|
+
second_principal_semi_axis (float): The second principal semi-axis length.
|
|
1116
|
+
third_principal_semi_axis (float): The third principal semi-axis length.
|
|
1117
|
+
|
|
1118
|
+
Example:
|
|
1119
|
+
>>> center = Point(0.0, 0.0, 0.0)
|
|
1120
|
+
>>> ellipsoid = Ellipsoid(center, 2.0, 1.5, 1.0)
|
|
1121
|
+
"""
|
|
231
1122
|
@typing.overload
|
|
232
1123
|
def __init__(self, center: Point, first_principal_semi_axis: ostk.core.type.Real, second_principal_semi_axis: ostk.core.type.Real, third_principal_semi_axis: ostk.core.type.Real, orientation: typing.Any) -> None:
|
|
233
|
-
|
|
1124
|
+
"""
|
|
1125
|
+
Create an ellipsoid with specified center, semi-axes, and orientation.
|
|
1126
|
+
|
|
1127
|
+
Args:
|
|
1128
|
+
center (Point): The center point of the ellipsoid.
|
|
1129
|
+
first_principal_semi_axis (float): The first principal semi-axis length.
|
|
1130
|
+
second_principal_semi_axis (float): The second principal semi-axis length.
|
|
1131
|
+
third_principal_semi_axis (float): The third principal semi-axis length.
|
|
1132
|
+
orientation (Quaternion): The orientation of the ellipsoid.
|
|
1133
|
+
|
|
1134
|
+
Example:
|
|
1135
|
+
>>> center = Point(0.0, 0.0, 0.0)
|
|
1136
|
+
>>> orientation = Quaternion.unit()
|
|
1137
|
+
>>> ellipsoid = Ellipsoid(center, 2.0, 1.5, 1.0, orientation)
|
|
1138
|
+
"""
|
|
234
1139
|
def __ne__(self, arg0: Ellipsoid) -> bool:
|
|
235
1140
|
...
|
|
236
1141
|
def __repr__(self) -> str:
|
|
@@ -238,34 +1143,161 @@ class Ellipsoid(ostk.mathematics.geometry.d3.Object):
|
|
|
238
1143
|
def __str__(self) -> str:
|
|
239
1144
|
...
|
|
240
1145
|
def apply_transformation(self, transformation: typing.Any) -> None:
|
|
241
|
-
|
|
1146
|
+
"""
|
|
1147
|
+
Apply a transformation to the ellipsoid in place.
|
|
1148
|
+
|
|
1149
|
+
Args:
|
|
1150
|
+
transformation (Transformation): The transformation to apply.
|
|
1151
|
+
|
|
1152
|
+
Example:
|
|
1153
|
+
>>> ellipsoid = Ellipsoid(center, 2.0, 1.5, 1.0)
|
|
1154
|
+
>>> transformation = Translation([1.0, 2.0, 3.0])
|
|
1155
|
+
>>> ellipsoid.apply_transformation(transformation)
|
|
1156
|
+
"""
|
|
242
1157
|
@typing.overload
|
|
243
1158
|
def contains(self, point: Point) -> bool:
|
|
244
|
-
|
|
1159
|
+
"""
|
|
1160
|
+
Check if the ellipsoid contains a point.
|
|
1161
|
+
|
|
1162
|
+
Args:
|
|
1163
|
+
point (Point): The point to check.
|
|
1164
|
+
|
|
1165
|
+
Returns:
|
|
1166
|
+
bool: True if the ellipsoid contains the point, False otherwise.
|
|
1167
|
+
|
|
1168
|
+
Example:
|
|
1169
|
+
>>> ellipsoid = Ellipsoid(Point(0.0, 0.0, 0.0), 2.0, 1.5, 1.0)
|
|
1170
|
+
>>> ellipsoid.contains(Point(0.5, 0.5, 0.5)) # True if inside
|
|
1171
|
+
"""
|
|
245
1172
|
@typing.overload
|
|
246
1173
|
def contains(self, point_set: PointSet) -> bool:
|
|
247
|
-
|
|
1174
|
+
"""
|
|
1175
|
+
Check if the ellipsoid contains a point set.
|
|
1176
|
+
|
|
1177
|
+
Args:
|
|
1178
|
+
point_set (PointSet): The point set to check.
|
|
1179
|
+
|
|
1180
|
+
Returns:
|
|
1181
|
+
bool: True if the ellipsoid contains the point set, False otherwise.
|
|
1182
|
+
|
|
1183
|
+
Example:
|
|
1184
|
+
>>> ellipsoid = Ellipsoid(Point(0.0, 0.0, 0.0), 2.0, 1.5, 1.0)
|
|
1185
|
+
>>> ellipsoid.contains(PointSet([Point(0.5, 0.5, 0.5), Point(1.0, 1.0, 1.0)])) # True if inside
|
|
1186
|
+
"""
|
|
248
1187
|
@typing.overload
|
|
249
1188
|
def contains(self, segment: Segment) -> bool:
|
|
250
|
-
|
|
1189
|
+
"""
|
|
1190
|
+
Check if the ellipsoid contains a segment.
|
|
1191
|
+
|
|
1192
|
+
Args:
|
|
1193
|
+
segment (Segment): The segment to check.
|
|
1194
|
+
|
|
1195
|
+
Returns:
|
|
1196
|
+
bool: True if the ellipsoid contains the segment, False otherwise.
|
|
1197
|
+
|
|
1198
|
+
Example:
|
|
1199
|
+
>>> ellipsoid = Ellipsoid(Point(0.0, 0.0, 0.0), 2.0, 1.5, 1.0)
|
|
1200
|
+
>>> ellipsoid.contains(Segment(Point(0.5, 0.5, 0.5), Point(1.0, 1.0, 1.0))) # True if inside
|
|
1201
|
+
"""
|
|
251
1202
|
def get_center(self) -> Point:
|
|
252
|
-
|
|
1203
|
+
"""
|
|
1204
|
+
Get the center point of the ellipsoid.
|
|
1205
|
+
|
|
1206
|
+
Returns:
|
|
1207
|
+
Point: The center point of the ellipsoid.
|
|
1208
|
+
|
|
1209
|
+
Example:
|
|
1210
|
+
>>> ellipsoid = Ellipsoid(Point(1.0, 2.0, 3.0), 2.0, 1.5, 1.0)
|
|
1211
|
+
>>> center = ellipsoid.get_center() # Point(1.0, 2.0, 3.0)
|
|
1212
|
+
"""
|
|
253
1213
|
def get_first_axis(self) -> numpy.ndarray[numpy.float64[3, 1]]:
|
|
254
|
-
|
|
1214
|
+
"""
|
|
1215
|
+
Get the first axis of the ellipsoid.
|
|
1216
|
+
|
|
1217
|
+
Returns:
|
|
1218
|
+
np.array: The first axis of the ellipsoid.
|
|
1219
|
+
|
|
1220
|
+
Example:
|
|
1221
|
+
>>> ellipsoid = Ellipsoid(center, 2.0, 1.5, 1.0)
|
|
1222
|
+
>>> first_axis = ellipsoid.get_first_axis() # np.array([1.0, 0.0, 0.0])
|
|
1223
|
+
"""
|
|
255
1224
|
def get_first_principal_semi_axis(self) -> ostk.core.type.Real:
|
|
256
|
-
|
|
1225
|
+
"""
|
|
1226
|
+
Get the first principal semi-axis length.
|
|
1227
|
+
|
|
1228
|
+
Returns:
|
|
1229
|
+
float: The length of the first principal semi-axis.
|
|
1230
|
+
|
|
1231
|
+
Example:
|
|
1232
|
+
>>> ellipsoid = Ellipsoid(center, 2.0, 1.5, 1.0)
|
|
1233
|
+
>>> first_axis = ellipsoid.get_first_principal_semi_axis() # 2.0
|
|
1234
|
+
"""
|
|
257
1235
|
def get_matrix(self) -> numpy.ndarray[numpy.float64[3, 3]]:
|
|
258
|
-
|
|
1236
|
+
"""
|
|
1237
|
+
Get the matrix of the ellipsoid.
|
|
1238
|
+
|
|
1239
|
+
Returns:
|
|
1240
|
+
np.array: The matrix of the ellipsoid.
|
|
1241
|
+
|
|
1242
|
+
Example:
|
|
1243
|
+
>>> ellipsoid = Ellipsoid(center, 2.0, 1.5, 1.0)
|
|
1244
|
+
>>> matrix = ellipsoid.get_matrix() # np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]])
|
|
1245
|
+
"""
|
|
259
1246
|
def get_orientation(self) -> ...:
|
|
260
|
-
|
|
1247
|
+
"""
|
|
1248
|
+
Get the orientation quaternion of the ellipsoid.
|
|
1249
|
+
|
|
1250
|
+
Returns:
|
|
1251
|
+
Quaternion: The orientation quaternion of the ellipsoid.
|
|
1252
|
+
|
|
1253
|
+
Example:
|
|
1254
|
+
>>> ellipsoid = Ellipsoid(center, 2.0, 1.5, 1.0, orientation)
|
|
1255
|
+
>>> quat = ellipsoid.get_orientation()
|
|
1256
|
+
"""
|
|
261
1257
|
def get_second_axis(self) -> numpy.ndarray[numpy.float64[3, 1]]:
|
|
262
|
-
|
|
1258
|
+
"""
|
|
1259
|
+
Get the second axis of the ellipsoid.
|
|
1260
|
+
|
|
1261
|
+
Returns:
|
|
1262
|
+
np.array: The second axis of the ellipsoid.
|
|
1263
|
+
|
|
1264
|
+
Example:
|
|
1265
|
+
>>> ellipsoid = Ellipsoid(center, 2.0, 1.5, 1.0)
|
|
1266
|
+
>>> second_axis = ellipsoid.get_second_axis() # np.array([0.0, 1.0, 0.0])
|
|
1267
|
+
"""
|
|
263
1268
|
def get_second_principal_semi_axis(self) -> ostk.core.type.Real:
|
|
264
|
-
|
|
1269
|
+
"""
|
|
1270
|
+
Get the second principal semi-axis length.
|
|
1271
|
+
|
|
1272
|
+
Returns:
|
|
1273
|
+
float: The length of the second principal semi-axis.
|
|
1274
|
+
|
|
1275
|
+
Example:
|
|
1276
|
+
>>> ellipsoid = Ellipsoid(center, 2.0, 1.5, 1.0)
|
|
1277
|
+
>>> second_axis = ellipsoid.get_second_principal_semi_axis() # 1.5
|
|
1278
|
+
"""
|
|
265
1279
|
def get_third_axis(self) -> numpy.ndarray[numpy.float64[3, 1]]:
|
|
266
|
-
|
|
1280
|
+
"""
|
|
1281
|
+
Get the third axis of the ellipsoid.
|
|
1282
|
+
|
|
1283
|
+
Returns:
|
|
1284
|
+
np.array: The third axis of the ellipsoid.
|
|
1285
|
+
|
|
1286
|
+
Example:
|
|
1287
|
+
>>> ellipsoid = Ellipsoid(center, 2.0, 1.5, 1.0)
|
|
1288
|
+
>>> third_axis = ellipsoid.get_third_axis() # np.array([0.0, 0.0, 1.0])
|
|
1289
|
+
"""
|
|
267
1290
|
def get_third_principal_semi_axis(self) -> ostk.core.type.Real:
|
|
268
|
-
|
|
1291
|
+
"""
|
|
1292
|
+
Get the third principal semi-axis length.
|
|
1293
|
+
|
|
1294
|
+
Returns:
|
|
1295
|
+
float: The length of the third principal semi-axis.
|
|
1296
|
+
|
|
1297
|
+
Example:
|
|
1298
|
+
>>> ellipsoid = Ellipsoid(center, 2.0, 1.5, 1.0)
|
|
1299
|
+
>>> third_axis = ellipsoid.get_third_principal_semi_axis() # 1.0
|
|
1300
|
+
"""
|
|
269
1301
|
@typing.overload
|
|
270
1302
|
def intersection(self, line: Line) -> ...:
|
|
271
1303
|
...
|
|
@@ -282,37 +1314,256 @@ class Ellipsoid(ostk.mathematics.geometry.d3.Object):
|
|
|
282
1314
|
def intersection(self, cone: typing.Any, only_in_sight: bool) -> ...:
|
|
283
1315
|
...
|
|
284
1316
|
@typing.overload
|
|
1317
|
+
def intersection_with(self, line: Line) -> ...:
|
|
1318
|
+
"""
|
|
1319
|
+
Get the intersection of the ellipsoid with a line.
|
|
1320
|
+
|
|
1321
|
+
Args:
|
|
1322
|
+
line (Line): The line to intersect with.
|
|
1323
|
+
|
|
1324
|
+
Returns:
|
|
1325
|
+
Intersection: The intersection of the ellipsoid with the line.
|
|
1326
|
+
|
|
1327
|
+
Example:
|
|
1328
|
+
>>> ellipsoid = Ellipsoid(center, 2.0, 1.5, 1.0)
|
|
1329
|
+
>>> line = Line.points(Point(0.0, 0.0, 0.0), Point(1.0, 0.0, 0.0))
|
|
1330
|
+
>>> intersection = ellipsoid.intersection_with(line)
|
|
1331
|
+
>>> intersection.get_point() # Point(0.0, 0.0, 0.0)
|
|
1332
|
+
"""
|
|
1333
|
+
@typing.overload
|
|
1334
|
+
def intersection_with(self, ray: Ray, only_in_sight: bool = False) -> ...:
|
|
1335
|
+
"""
|
|
1336
|
+
Get the intersection of the ellipsoid with a ray.
|
|
1337
|
+
|
|
1338
|
+
Args:
|
|
1339
|
+
ray (Ray): The ray to intersect with.
|
|
1340
|
+
only_in_sight (bool, optional): If true, only return intersection points that are in sight. Defaults to False.
|
|
1341
|
+
|
|
1342
|
+
Returns:
|
|
1343
|
+
Intersection: The intersection of the ellipsoid with the ray.
|
|
1344
|
+
|
|
1345
|
+
Example:
|
|
1346
|
+
>>> ellipsoid = Ellipsoid(center, 2.0, 1.5, 1.0)
|
|
1347
|
+
>>> ray = Ray(Point(0.0, 0.0, 0.0), Point(1.0, 0.0, 0.0))
|
|
1348
|
+
>>> intersection = ellipsoid.intersection_with(ray)
|
|
1349
|
+
>>> intersection.get_point() # Point(0.0, 0.0, 0.0)
|
|
1350
|
+
"""
|
|
1351
|
+
@typing.overload
|
|
1352
|
+
def intersection_with(self, segment: Segment) -> ...:
|
|
1353
|
+
"""
|
|
1354
|
+
Get the intersection of the ellipsoid with a segment.
|
|
1355
|
+
|
|
1356
|
+
Args:
|
|
1357
|
+
segment (Segment): The segment to intersect with.
|
|
1358
|
+
|
|
1359
|
+
Returns:
|
|
1360
|
+
Intersection: The intersection of the ellipsoid with the segment.
|
|
1361
|
+
|
|
1362
|
+
Example:
|
|
1363
|
+
>>> ellipsoid = Ellipsoid(center, 2.0, 1.5, 1.0)
|
|
1364
|
+
>>> segment = Segment(Point(0.0, 0.0, 0.0), Point(1.0, 0.0, 0.0))
|
|
1365
|
+
>>> intersection = ellipsoid.intersection_with(segment)
|
|
1366
|
+
>>> intersection.get_point() # Point(0.0, 0.0, 0.0)
|
|
1367
|
+
"""
|
|
1368
|
+
@typing.overload
|
|
1369
|
+
def intersection_with(self, pyramid: typing.Any, only_in_sight: bool = False) -> ...:
|
|
1370
|
+
"""
|
|
1371
|
+
Get the intersection of the ellipsoid with a pyramid.
|
|
1372
|
+
|
|
1373
|
+
Args:
|
|
1374
|
+
pyramid (Pyramid): The pyramid to intersect with.
|
|
1375
|
+
only_in_sight (bool, optional): If true, only return intersection points that are in sight. Defaults to False.
|
|
1376
|
+
|
|
1377
|
+
Returns:
|
|
1378
|
+
Intersection: The intersection of the ellipsoid with the pyramid.
|
|
1379
|
+
|
|
1380
|
+
Example:
|
|
1381
|
+
>>> origin = Point(0.0, 0.0, 0.0)
|
|
1382
|
+
>>> ellipsoid = Ellipsoid(origin, 2.0, 1.5, 1.0)
|
|
1383
|
+
>>> polygon2d = Polygon2d([Point2d(0.0, 0.0), Point2d(1.0, 0.0), Point2d(1.0, 1.0), Point2d(0.0, 1.0)])
|
|
1384
|
+
>>> x_axis = np.array([1.0, 0.0, 0.0])
|
|
1385
|
+
>>> y_axis = np.array([0.0, 1.0, 0.0])
|
|
1386
|
+
>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
|
|
1387
|
+
>>> pyramid = Pyramid(polygon, Point(0.0, 0.0, 1.0))
|
|
1388
|
+
>>> intersection = ellipsoid.intersection_with(pyramid)
|
|
1389
|
+
>>> intersection.get_point()
|
|
1390
|
+
"""
|
|
1391
|
+
@typing.overload
|
|
1392
|
+
def intersection_with(self, cone: typing.Any, only_in_sight: bool = False) -> ...:
|
|
1393
|
+
"""
|
|
1394
|
+
Get the intersection of the ellipsoid with a cone.
|
|
1395
|
+
|
|
1396
|
+
Args:
|
|
1397
|
+
cone (Cone): The cone to intersect with.
|
|
1398
|
+
only_in_sight (bool, optional): If true, only return intersection points that are in sight. Defaults to False.
|
|
1399
|
+
|
|
1400
|
+
Returns:
|
|
1401
|
+
Intersection: The intersection of the ellipsoid with the cone.
|
|
1402
|
+
|
|
1403
|
+
Example:
|
|
1404
|
+
>>> ellipsoid = Ellipsoid(center, 2.0, 1.5, 1.0)
|
|
1405
|
+
>>> cone = Cone(Point(0.0, 0.0, 0.0), [1.0, 0.0, 0.0], Angle.degrees(30.0))
|
|
1406
|
+
>>> intersection = ellipsoid.intersection_with(cone)
|
|
1407
|
+
>>> intersection.get_point()
|
|
1408
|
+
"""
|
|
1409
|
+
@typing.overload
|
|
285
1410
|
def intersects(self, point: Point) -> bool:
|
|
286
|
-
|
|
1411
|
+
"""
|
|
1412
|
+
Check if the ellipsoid intersects a point.
|
|
1413
|
+
|
|
1414
|
+
Args:
|
|
1415
|
+
point (Point): The point to check.
|
|
1416
|
+
|
|
1417
|
+
Returns:
|
|
1418
|
+
bool: True if the ellipsoid intersects the point, False otherwise.
|
|
1419
|
+
|
|
1420
|
+
Example:
|
|
1421
|
+
>>> ellipsoid = Ellipsoid(Point(0.0, 0.0, 0.0), 2.0, 1.5, 1.0)
|
|
1422
|
+
>>> ellipsoid.intersects(Point(0.5, 0.5, 0.5)) # True
|
|
1423
|
+
"""
|
|
287
1424
|
@typing.overload
|
|
288
1425
|
def intersects(self, point_set: PointSet) -> bool:
|
|
289
|
-
|
|
1426
|
+
"""
|
|
1427
|
+
Check if the ellipsoid intersects a point set.
|
|
1428
|
+
|
|
1429
|
+
Args:
|
|
1430
|
+
point_set (PointSet): The point set to check.
|
|
1431
|
+
|
|
1432
|
+
Returns:
|
|
1433
|
+
bool: True if the ellipsoid intersects the point set, False otherwise.
|
|
1434
|
+
|
|
1435
|
+
Example:
|
|
1436
|
+
>>> ellipsoid = Ellipsoid(Point(0.0, 0.0, 0.0), 2.0, 1.5, 1.0)
|
|
1437
|
+
>>> ellipsoid.intersects(PointSet([Point(0.5, 0.5, 0.5), Point(1.0, 1.0, 1.0)])) # True
|
|
1438
|
+
"""
|
|
290
1439
|
@typing.overload
|
|
291
1440
|
def intersects(self, line: Line) -> bool:
|
|
292
|
-
|
|
1441
|
+
"""
|
|
1442
|
+
Check if the ellipsoid intersects a line.
|
|
1443
|
+
|
|
1444
|
+
Args:
|
|
1445
|
+
line (Line): The line to check.
|
|
1446
|
+
|
|
1447
|
+
Returns:
|
|
1448
|
+
bool: True if the ellipsoid intersects the line, False otherwise.
|
|
1449
|
+
|
|
1450
|
+
Example:
|
|
1451
|
+
>>> ellipsoid = Ellipsoid(Point(0.0, 0.0, 0.0), 2.0, 1.5, 1.0)
|
|
1452
|
+
>>> ellipsoid.intersects(Line.points(Point(0.5, 0.5, 0.5), Point(1.0, 1.0, 1.0))) # True
|
|
1453
|
+
"""
|
|
293
1454
|
@typing.overload
|
|
294
1455
|
def intersects(self, ray: Ray) -> bool:
|
|
295
|
-
|
|
1456
|
+
"""
|
|
1457
|
+
Check if the ellipsoid intersects a ray.
|
|
1458
|
+
|
|
1459
|
+
Args:
|
|
1460
|
+
ray (Ray): The ray to check.
|
|
1461
|
+
|
|
1462
|
+
Returns:
|
|
1463
|
+
bool: True if the ellipsoid intersects the ray, False otherwise.
|
|
1464
|
+
|
|
1465
|
+
Example:
|
|
1466
|
+
>>> ellipsoid = Ellipsoid(Point(0.0, 0.0, 0.0), 2.0, 1.5, 1.0)
|
|
1467
|
+
>>> ellipsoid.intersects(Ray(Point(0.5, 0.5, 0.5), [1.0, 0.0, 0.0])) # True
|
|
1468
|
+
"""
|
|
296
1469
|
@typing.overload
|
|
297
1470
|
def intersects(self, segment: Segment) -> bool:
|
|
298
|
-
|
|
1471
|
+
"""
|
|
1472
|
+
Check if the ellipsoid intersects a segment.
|
|
1473
|
+
|
|
1474
|
+
Args:
|
|
1475
|
+
segment (Segment): The segment to check.
|
|
1476
|
+
|
|
1477
|
+
Returns:
|
|
1478
|
+
bool: True if the ellipsoid intersects the segment, False otherwise.
|
|
1479
|
+
|
|
1480
|
+
Example:
|
|
1481
|
+
>>> ellipsoid = Ellipsoid(Point(0.0, 0.0, 0.0), 2.0, 1.5, 1.0)
|
|
1482
|
+
>>> ellipsoid.intersects(Segment(Point(0.5, 0.5, 0.5), Point(1.0, 1.0, 1.0))) # True
|
|
1483
|
+
"""
|
|
299
1484
|
@typing.overload
|
|
300
1485
|
def intersects(self, plane: Plane) -> bool:
|
|
301
|
-
|
|
1486
|
+
"""
|
|
1487
|
+
Check if the ellipsoid intersects a plane.
|
|
1488
|
+
|
|
1489
|
+
Args:
|
|
1490
|
+
plane (Plane): The plane to check.
|
|
1491
|
+
|
|
1492
|
+
Returns:
|
|
1493
|
+
bool: True if the ellipsoid intersects the plane, False otherwise.
|
|
1494
|
+
|
|
1495
|
+
Example:
|
|
1496
|
+
>>> ellipsoid = Ellipsoid(Point(0.0, 0.0, 0.0), 2.0, 1.5, 1.0)
|
|
1497
|
+
>>> ellipsoid.intersects(Plane(Point(0.5, 0.5, 0.5), Vector3d(1.0, 1.0, 1.0))) # True
|
|
1498
|
+
"""
|
|
302
1499
|
def is_defined(self) -> bool:
|
|
303
|
-
|
|
1500
|
+
"""
|
|
1501
|
+
Check if the ellipsoid is defined.
|
|
1502
|
+
|
|
1503
|
+
Returns:
|
|
1504
|
+
bool: True if the ellipsoid is defined, False otherwise.
|
|
1505
|
+
|
|
1506
|
+
Example:
|
|
1507
|
+
>>> ellipsoid = Ellipsoid(center, 2.0, 1.5, 1.0)
|
|
1508
|
+
>>> ellipsoid.is_defined() # True
|
|
1509
|
+
"""
|
|
304
1510
|
class Line(ostk.mathematics.geometry.d3.Object):
|
|
1511
|
+
"""
|
|
1512
|
+
|
|
1513
|
+
An infinite line in 3D space.
|
|
1514
|
+
|
|
1515
|
+
A Line is defined by an origin point and a direction vector.
|
|
1516
|
+
|
|
1517
|
+
Example:
|
|
1518
|
+
>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
|
|
1519
|
+
>>> line.is_defined() # True
|
|
1520
|
+
|
|
1521
|
+
"""
|
|
305
1522
|
__hash__: typing.ClassVar[None] = None
|
|
306
1523
|
@staticmethod
|
|
307
1524
|
def points(first_point: Point, second_point: Point) -> Line:
|
|
308
|
-
|
|
1525
|
+
"""
|
|
1526
|
+
Create a line passing through two points.
|
|
1527
|
+
|
|
1528
|
+
Args:
|
|
1529
|
+
first_point (Point): The first point.
|
|
1530
|
+
second_point (Point): The second point.
|
|
1531
|
+
|
|
1532
|
+
Returns:
|
|
1533
|
+
Line: A line passing through both points.
|
|
1534
|
+
|
|
1535
|
+
Example:
|
|
1536
|
+
>>> point1 = Point(0.0, 0.0)
|
|
1537
|
+
>>> point2 = Point(1.0, 1.0)
|
|
1538
|
+
>>> line = Line.points(point1, point2)
|
|
1539
|
+
>>> line.is_defined() # True
|
|
1540
|
+
"""
|
|
309
1541
|
@staticmethod
|
|
310
1542
|
def undefined() -> Line:
|
|
311
|
-
|
|
1543
|
+
"""
|
|
1544
|
+
Create an undefined line.
|
|
1545
|
+
|
|
1546
|
+
Returns:
|
|
1547
|
+
Line: An undefined line.
|
|
1548
|
+
|
|
1549
|
+
Example:
|
|
1550
|
+
>>> undefined_line = Line.undefined()
|
|
1551
|
+
>>> undefined_line.is_defined() # False
|
|
1552
|
+
"""
|
|
312
1553
|
def __eq__(self, arg0: Line) -> bool:
|
|
313
1554
|
...
|
|
314
1555
|
def __init__(self, origin: Point, direction: numpy.ndarray[numpy.float64[3, 1]]) -> None:
|
|
315
|
-
|
|
1556
|
+
"""
|
|
1557
|
+
Construct a line from an origin point and direction vector.
|
|
1558
|
+
|
|
1559
|
+
Args:
|
|
1560
|
+
origin (Point): A point on the line.
|
|
1561
|
+
direction (numpy.ndarray): The direction vector of the line.
|
|
1562
|
+
|
|
1563
|
+
Example:
|
|
1564
|
+
>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
|
|
1565
|
+
>>> line.is_defined() # True
|
|
1566
|
+
"""
|
|
316
1567
|
def __ne__(self, arg0: Line) -> bool:
|
|
317
1568
|
...
|
|
318
1569
|
def __repr__(self) -> str:
|
|
@@ -320,49 +1571,232 @@ class Line(ostk.mathematics.geometry.d3.Object):
|
|
|
320
1571
|
def __str__(self) -> str:
|
|
321
1572
|
...
|
|
322
1573
|
def apply_transformation(self, transformation: typing.Any) -> None:
|
|
323
|
-
|
|
1574
|
+
"""
|
|
1575
|
+
Apply a transformation to the line in place.
|
|
1576
|
+
|
|
1577
|
+
Args:
|
|
1578
|
+
transformation (Transformation): The transformation to apply.
|
|
1579
|
+
|
|
1580
|
+
Example:
|
|
1581
|
+
>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
|
|
1582
|
+
>>> transformation = Translation([1.0, 1.0])
|
|
1583
|
+
>>> line.apply_transformation(transformation)
|
|
1584
|
+
"""
|
|
324
1585
|
@typing.overload
|
|
325
1586
|
def contains(self, point: Point) -> bool:
|
|
326
|
-
|
|
1587
|
+
"""
|
|
1588
|
+
Check if the line contains a point.
|
|
1589
|
+
|
|
1590
|
+
Args:
|
|
1591
|
+
point (Point): The point to check.
|
|
1592
|
+
|
|
1593
|
+
Returns:
|
|
1594
|
+
bool: True if the line contains the point.
|
|
1595
|
+
|
|
1596
|
+
Example:
|
|
1597
|
+
>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
|
|
1598
|
+
>>> line.contains(Point(0.5, 0.5)) # True
|
|
1599
|
+
"""
|
|
327
1600
|
@typing.overload
|
|
328
1601
|
def contains(self, point_set: PointSet) -> bool:
|
|
329
|
-
|
|
1602
|
+
"""
|
|
1603
|
+
Check if the line contains all points in a point set.
|
|
1604
|
+
|
|
1605
|
+
Args:
|
|
1606
|
+
point_set (PointSet): The point set to check.
|
|
1607
|
+
|
|
1608
|
+
Returns:
|
|
1609
|
+
bool: True if the line contains all points.
|
|
1610
|
+
|
|
1611
|
+
Example:
|
|
1612
|
+
>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
|
|
1613
|
+
>>> points = PointSet([Point(0.5, 0.5), Point(0.25, 0.25)])
|
|
1614
|
+
>>> line.contains(points) # True
|
|
1615
|
+
"""
|
|
330
1616
|
def distance_to(self, point: Point) -> ostk.core.type.Real:
|
|
331
|
-
|
|
1617
|
+
"""
|
|
1618
|
+
Calculate the distance from the line to a point.
|
|
1619
|
+
|
|
1620
|
+
Args:
|
|
1621
|
+
point (Point): The point to measure distance to.
|
|
1622
|
+
|
|
1623
|
+
Returns:
|
|
1624
|
+
float: The distance to the point.
|
|
1625
|
+
|
|
1626
|
+
Example:
|
|
1627
|
+
>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
|
|
1628
|
+
>>> distance = line.distance_to(Point(0.5, 1.0)) # 1.0
|
|
1629
|
+
"""
|
|
332
1630
|
def get_direction(self) -> numpy.ndarray[numpy.float64[3, 1]]:
|
|
333
|
-
|
|
1631
|
+
"""
|
|
1632
|
+
Get the direction vector of the line.
|
|
1633
|
+
|
|
1634
|
+
Returns:
|
|
1635
|
+
numpy.ndarray: The direction vector.
|
|
1636
|
+
|
|
1637
|
+
Example:
|
|
1638
|
+
>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
|
|
1639
|
+
>>> direction = line.get_direction() # [1.0, 0.0, 0.0]
|
|
1640
|
+
"""
|
|
334
1641
|
def get_origin(self) -> Point:
|
|
335
|
-
|
|
1642
|
+
"""
|
|
1643
|
+
Get the origin point of the line.
|
|
1644
|
+
|
|
1645
|
+
Returns:
|
|
1646
|
+
Point: The origin point.
|
|
1647
|
+
|
|
1648
|
+
Example:
|
|
1649
|
+
>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
|
|
1650
|
+
>>> origin = line.get_origin() # Point(0.0, 0.0, 0.0)
|
|
1651
|
+
"""
|
|
336
1652
|
def intersection_with(self, plane: typing.Any) -> ...:
|
|
337
|
-
|
|
1653
|
+
"""
|
|
1654
|
+
Compute the intersection of the line with a plane.
|
|
1655
|
+
|
|
1656
|
+
Args:
|
|
1657
|
+
plane (Plane): The plane to intersect with.
|
|
1658
|
+
|
|
1659
|
+
Returns:
|
|
1660
|
+
Intersection: The intersection result.
|
|
1661
|
+
|
|
1662
|
+
Example:
|
|
1663
|
+
>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
|
|
1664
|
+
>>> plane = Plane(Point(1.0, 0.0, 0.0), Vector3d(0.0, 0.0, 1.0))
|
|
1665
|
+
>>> intersection = line.intersection_with(plane)
|
|
1666
|
+
>>> intersection.get_point() # Point(1.0, 0.0, 0.0)
|
|
1667
|
+
"""
|
|
338
1668
|
@typing.overload
|
|
339
1669
|
def intersects(self, point: Point) -> bool:
|
|
340
|
-
|
|
1670
|
+
"""
|
|
1671
|
+
Check if the line intersects a point.
|
|
1672
|
+
|
|
1673
|
+
Args:
|
|
1674
|
+
point (Point): The point to check intersection with.
|
|
1675
|
+
|
|
1676
|
+
Returns:
|
|
1677
|
+
bool: True if the line intersects the point.
|
|
1678
|
+
|
|
1679
|
+
Example:
|
|
1680
|
+
>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
|
|
1681
|
+
>>> line.intersects(Point(0.5, 0.5)) # True
|
|
1682
|
+
"""
|
|
341
1683
|
@typing.overload
|
|
342
1684
|
def intersects(self, plane: typing.Any) -> bool:
|
|
343
|
-
|
|
1685
|
+
"""
|
|
1686
|
+
Check if the line intersects a plane.
|
|
1687
|
+
|
|
1688
|
+
Args:
|
|
1689
|
+
plane (Plane): The plane to check intersection with.
|
|
1690
|
+
|
|
1691
|
+
Returns:
|
|
1692
|
+
bool: True if the line intersects the plane.
|
|
1693
|
+
|
|
1694
|
+
Example:
|
|
1695
|
+
>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
|
|
1696
|
+
>>> plane = Plane(Point(1.0, 0.0, 0.0), Vector3d(0.0, 0.0, 1.0))
|
|
1697
|
+
>>> line.intersects(plane) # True
|
|
1698
|
+
"""
|
|
344
1699
|
@typing.overload
|
|
345
1700
|
def intersects(self, sphere: typing.Any) -> bool:
|
|
346
|
-
|
|
1701
|
+
"""
|
|
1702
|
+
Check if the line intersects a sphere.
|
|
1703
|
+
|
|
1704
|
+
Args:
|
|
1705
|
+
sphere (Sphere): The sphere to check intersection with.
|
|
1706
|
+
|
|
1707
|
+
Returns:
|
|
1708
|
+
bool: True if the line intersects the sphere.
|
|
1709
|
+
|
|
1710
|
+
Example:
|
|
1711
|
+
>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
|
|
1712
|
+
>>> sphere = Sphere(Point(1.0, 0.0, 0.0), 1.0)
|
|
1713
|
+
>>> line.intersects(sphere) # True
|
|
1714
|
+
"""
|
|
347
1715
|
@typing.overload
|
|
348
1716
|
def intersects(self, ellipsoid: typing.Any) -> bool:
|
|
349
|
-
|
|
1717
|
+
"""
|
|
1718
|
+
Check if the line intersects an ellipsoid.
|
|
1719
|
+
|
|
1720
|
+
Args:
|
|
1721
|
+
ellipsoid (Ellipsoid): The ellipsoid to check intersection with.
|
|
1722
|
+
|
|
1723
|
+
Returns:
|
|
1724
|
+
bool: True if the line intersects the ellipsoid.
|
|
1725
|
+
|
|
1726
|
+
Example:
|
|
1727
|
+
>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
|
|
1728
|
+
>>> ellipsoid = Ellipsoid(Point(2.0, 0.0, 0.0), 1.0, 1.0, 1.0)
|
|
1729
|
+
>>> line.intersects(ellipsoid) # True
|
|
1730
|
+
"""
|
|
350
1731
|
def is_defined(self) -> bool:
|
|
351
|
-
|
|
1732
|
+
"""
|
|
1733
|
+
Check if the line is defined.
|
|
1734
|
+
|
|
1735
|
+
Returns:
|
|
1736
|
+
bool: True if the line is defined.
|
|
1737
|
+
|
|
1738
|
+
Example:
|
|
1739
|
+
>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
|
|
1740
|
+
>>> line.is_defined() # True
|
|
1741
|
+
"""
|
|
352
1742
|
class LineString(ostk.mathematics.geometry.d3.Object):
|
|
1743
|
+
"""
|
|
1744
|
+
|
|
1745
|
+
A sequence of connected line segments in 3D space.
|
|
1746
|
+
|
|
1747
|
+
A LineString is an ordered sequence of points forming a polyline.
|
|
1748
|
+
|
|
1749
|
+
Example:
|
|
1750
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
1751
|
+
>>> line_string = LineString(points)
|
|
1752
|
+
>>> line_string.is_defined() # True
|
|
1753
|
+
|
|
1754
|
+
"""
|
|
353
1755
|
__hash__: typing.ClassVar[None] = None
|
|
354
1756
|
@staticmethod
|
|
355
1757
|
def empty() -> LineString:
|
|
356
|
-
|
|
1758
|
+
"""
|
|
1759
|
+
Create an empty line string.
|
|
1760
|
+
|
|
1761
|
+
Returns:
|
|
1762
|
+
LineString: An empty line string.
|
|
1763
|
+
|
|
1764
|
+
Example:
|
|
1765
|
+
>>> line_string = LineString.empty()
|
|
1766
|
+
>>> line_string.is_empty() # True
|
|
1767
|
+
"""
|
|
357
1768
|
@staticmethod
|
|
358
1769
|
def segment(segment: Segment) -> LineString:
|
|
359
|
-
|
|
1770
|
+
"""
|
|
1771
|
+
Create a line string from a segment.
|
|
1772
|
+
|
|
1773
|
+
Args:
|
|
1774
|
+
segment (Segment): The segment to convert.
|
|
1775
|
+
|
|
1776
|
+
Returns:
|
|
1777
|
+
LineString: A line string representing the segment.
|
|
1778
|
+
|
|
1779
|
+
Example:
|
|
1780
|
+
>>> segment = Segment(Point(0.0, 0.0, 0.0), Point(1.0, 1.0, 1.0))
|
|
1781
|
+
>>> line_string = LineString.segment(segment)
|
|
1782
|
+
>>> line_string.is_defined() # True
|
|
1783
|
+
"""
|
|
360
1784
|
def __eq__(self, arg0: LineString) -> bool:
|
|
361
1785
|
...
|
|
362
1786
|
def __getitem__(self, index: int) -> Point:
|
|
363
1787
|
...
|
|
364
1788
|
def __init__(self, points: list[Point]) -> None:
|
|
365
|
-
|
|
1789
|
+
"""
|
|
1790
|
+
Construct a line string from an array of points.
|
|
1791
|
+
|
|
1792
|
+
Args:
|
|
1793
|
+
points (list[Point]): Array of 3D points defining the line string.
|
|
1794
|
+
|
|
1795
|
+
Example:
|
|
1796
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
1797
|
+
>>> line_string = LineString(points)
|
|
1798
|
+
>>> line_string.is_defined() # True
|
|
1799
|
+
"""
|
|
366
1800
|
def __iter__(self) -> typing.Iterator[Point]:
|
|
367
1801
|
...
|
|
368
1802
|
def __len__(self) -> int:
|
|
@@ -374,28 +1808,127 @@ class LineString(ostk.mathematics.geometry.d3.Object):
|
|
|
374
1808
|
def __str__(self) -> str:
|
|
375
1809
|
...
|
|
376
1810
|
def access_point_at(self, index: int) -> Point:
|
|
377
|
-
|
|
1811
|
+
"""
|
|
1812
|
+
Access a point at a given index.
|
|
1813
|
+
|
|
1814
|
+
Args:
|
|
1815
|
+
index (int): The index of the point.
|
|
1816
|
+
|
|
1817
|
+
Returns:
|
|
1818
|
+
Point: Reference to the point at the index.
|
|
1819
|
+
|
|
1820
|
+
Example:
|
|
1821
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
1822
|
+
>>> line_string = LineString(points)
|
|
1823
|
+
>>> line_string.access_point_at(0) # Point(0.0, 0.0)
|
|
1824
|
+
"""
|
|
378
1825
|
def apply_transformation(self, transformation: typing.Any) -> None:
|
|
379
|
-
|
|
1826
|
+
"""
|
|
1827
|
+
Apply a transformation to all points in the line string.
|
|
1828
|
+
|
|
1829
|
+
Args:
|
|
1830
|
+
transformation (Transformation): The transformation to apply.
|
|
1831
|
+
|
|
1832
|
+
Example:
|
|
1833
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
1834
|
+
>>> line_string = LineString(points)
|
|
1835
|
+
>>> transformation = Transformation.translation([1.0, 0.0])
|
|
1836
|
+
>>> line_string.apply_transformation(transformation)
|
|
1837
|
+
"""
|
|
380
1838
|
def get_point_closest_to(self, point: Point) -> Point:
|
|
381
|
-
|
|
1839
|
+
"""
|
|
1840
|
+
Get the point in the line string closest to a given point.
|
|
1841
|
+
|
|
1842
|
+
Args:
|
|
1843
|
+
point (Point): The reference point.
|
|
1844
|
+
|
|
1845
|
+
Returns:
|
|
1846
|
+
Point: The closest point in the line string.
|
|
1847
|
+
|
|
1848
|
+
Example:
|
|
1849
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
1850
|
+
>>> line_string = LineString(points)
|
|
1851
|
+
>>> line_string.get_point_closest_to(Point(0.5, 0.5)) # Point(0.5, 0.5)
|
|
1852
|
+
"""
|
|
382
1853
|
def get_point_count(self) -> int:
|
|
383
|
-
|
|
1854
|
+
"""
|
|
1855
|
+
Get the number of points in the line string.
|
|
1856
|
+
|
|
1857
|
+
Returns:
|
|
1858
|
+
int: The number of points.
|
|
1859
|
+
|
|
1860
|
+
Example:
|
|
1861
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
1862
|
+
>>> line_string = LineString(points)
|
|
1863
|
+
>>> line_string.get_point_count() # 2
|
|
1864
|
+
"""
|
|
384
1865
|
def is_defined(self) -> bool:
|
|
385
|
-
|
|
1866
|
+
"""
|
|
1867
|
+
Check if the line string is defined.
|
|
1868
|
+
|
|
1869
|
+
Returns:
|
|
1870
|
+
bool: True if the line string is defined.
|
|
1871
|
+
|
|
1872
|
+
Example:
|
|
1873
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
1874
|
+
>>> line_string = LineString(points)
|
|
1875
|
+
>>> line_string.is_defined() # True
|
|
1876
|
+
"""
|
|
386
1877
|
def is_empty(self) -> bool:
|
|
387
|
-
|
|
1878
|
+
"""
|
|
1879
|
+
Check if the line string is empty.
|
|
1880
|
+
|
|
1881
|
+
Returns:
|
|
1882
|
+
bool: True if the line string contains no points.
|
|
1883
|
+
|
|
1884
|
+
Example:
|
|
1885
|
+
>>> line_string = LineString.empty()
|
|
1886
|
+
>>> line_string.is_empty() # True
|
|
1887
|
+
"""
|
|
388
1888
|
def is_near(self, line_string: LineString, tolerance: ostk.core.type.Real) -> bool:
|
|
389
|
-
|
|
1889
|
+
"""
|
|
1890
|
+
Check if another line string is near this one within a tolerance.
|
|
1891
|
+
|
|
1892
|
+
Args:
|
|
1893
|
+
line_string (LineString): The line string to compare against.
|
|
1894
|
+
tolerance (float): The maximum distance for points to be considered near.
|
|
1895
|
+
|
|
1896
|
+
Returns:
|
|
1897
|
+
bool: True if the line strings are near each other.
|
|
1898
|
+
|
|
1899
|
+
Example:
|
|
1900
|
+
>>> line_string = LineString(points)
|
|
1901
|
+
>>> line_string.is_near(LineString(points), 0.1) # True
|
|
1902
|
+
"""
|
|
390
1903
|
class Plane(ostk.mathematics.geometry.d3.Object):
|
|
391
1904
|
__hash__: typing.ClassVar[None] = None
|
|
392
1905
|
@staticmethod
|
|
393
1906
|
def undefined() -> Plane:
|
|
394
|
-
|
|
1907
|
+
"""
|
|
1908
|
+
Create an undefined plane.
|
|
1909
|
+
|
|
1910
|
+
Returns:
|
|
1911
|
+
Plane: An undefined plane.
|
|
1912
|
+
|
|
1913
|
+
Example:
|
|
1914
|
+
>>> undefined_plane = Plane.undefined()
|
|
1915
|
+
>>> undefined_plane.is_defined() # False
|
|
1916
|
+
"""
|
|
395
1917
|
def __eq__(self, arg0: Plane) -> bool:
|
|
396
1918
|
...
|
|
397
1919
|
def __init__(self, point: Point, normal_vector: numpy.ndarray[numpy.float64[3, 1]]) -> None:
|
|
398
|
-
|
|
1920
|
+
"""
|
|
1921
|
+
Create a 3D plane from a point and normal vector.
|
|
1922
|
+
|
|
1923
|
+
Args:
|
|
1924
|
+
point (Point): A point on the plane.
|
|
1925
|
+
normal_vector (np.array): The normal vector to the plane.
|
|
1926
|
+
|
|
1927
|
+
Example:
|
|
1928
|
+
>>> point = Point(0.0, 0.0, 0.0)
|
|
1929
|
+
>>> normal = np.array([0.0, 0.0, 1.0])
|
|
1930
|
+
>>> plane = Plane(point, normal)
|
|
1931
|
+
"""
|
|
399
1932
|
def __ne__(self, arg0: Plane) -> bool:
|
|
400
1933
|
...
|
|
401
1934
|
def __repr__(self) -> str:
|
|
@@ -403,75 +1936,352 @@ class Plane(ostk.mathematics.geometry.d3.Object):
|
|
|
403
1936
|
def __str__(self) -> str:
|
|
404
1937
|
...
|
|
405
1938
|
def apply_transformation(self, transformation: typing.Any) -> None:
|
|
406
|
-
|
|
1939
|
+
"""
|
|
1940
|
+
Apply a transformation to the plane.
|
|
1941
|
+
|
|
1942
|
+
Args:
|
|
1943
|
+
transformation (Transformation): The transformation to apply.
|
|
1944
|
+
|
|
1945
|
+
Returns:
|
|
1946
|
+
Plane: The transformed plane.
|
|
1947
|
+
|
|
1948
|
+
Example:
|
|
1949
|
+
>>> plane = Plane(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]))
|
|
1950
|
+
>>> transformation = Transformation.identity()
|
|
1951
|
+
>>> transformed = plane.apply_transformation(transformation)
|
|
1952
|
+
"""
|
|
407
1953
|
@typing.overload
|
|
408
1954
|
def contains(self, point: Point) -> bool:
|
|
409
|
-
|
|
1955
|
+
"""
|
|
1956
|
+
Check if the plane contains a point.
|
|
1957
|
+
|
|
1958
|
+
Args:
|
|
1959
|
+
point (Point): The point to check.
|
|
1960
|
+
|
|
1961
|
+
Returns:
|
|
1962
|
+
bool: True if the plane contains the point, False otherwise.
|
|
1963
|
+
|
|
1964
|
+
Example:
|
|
1965
|
+
>>> plane = Plane(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]))
|
|
1966
|
+
>>> plane.contains(Point(1.0, 1.0, 0.0)) # True (z=0 plane)
|
|
1967
|
+
"""
|
|
410
1968
|
@typing.overload
|
|
411
1969
|
def contains(self, point_set: PointSet) -> bool:
|
|
412
|
-
|
|
1970
|
+
"""
|
|
1971
|
+
Check if the plane contains a point set.
|
|
1972
|
+
|
|
1973
|
+
Args:
|
|
1974
|
+
point_set (PointSet): The point set to check.
|
|
1975
|
+
|
|
1976
|
+
Returns:
|
|
1977
|
+
bool: True if the plane contains all points in the set, False otherwise.
|
|
1978
|
+
|
|
1979
|
+
Example:
|
|
1980
|
+
>>> plane = Plane(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]))
|
|
1981
|
+
>>> points = PointSet([Point(1.0, 1.0, 0.0), Point(2.0, 2.0, 0.0)])
|
|
1982
|
+
>>> plane.contains(points) # True
|
|
1983
|
+
"""
|
|
413
1984
|
@typing.overload
|
|
414
1985
|
def contains(self, line: Line) -> bool:
|
|
415
|
-
|
|
1986
|
+
"""
|
|
1987
|
+
Check if the plane contains a line.
|
|
1988
|
+
|
|
1989
|
+
Args:
|
|
1990
|
+
line (Line): The line to check.
|
|
1991
|
+
|
|
1992
|
+
Returns:
|
|
1993
|
+
bool: True if the plane contains the entire line, False otherwise.
|
|
1994
|
+
|
|
1995
|
+
Example:
|
|
1996
|
+
>>> plane = Plane(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]))
|
|
1997
|
+
>>> line = Line(Point(0.0, 0.0, 0.0), np.array([1.0, 0.0, 0.0]))
|
|
1998
|
+
>>> plane.contains(line) # True (line lies in z=0 plane)
|
|
1999
|
+
"""
|
|
416
2000
|
@typing.overload
|
|
417
2001
|
def contains(self, ray: Ray) -> bool:
|
|
418
|
-
|
|
2002
|
+
"""
|
|
2003
|
+
Check if the plane contains a ray.
|
|
2004
|
+
|
|
2005
|
+
Args:
|
|
2006
|
+
ray (Ray): The ray to check.
|
|
2007
|
+
|
|
2008
|
+
Returns:
|
|
2009
|
+
bool: True if the plane contains the entire ray, False otherwise.
|
|
2010
|
+
|
|
2011
|
+
Example:
|
|
2012
|
+
>>> plane = Plane(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]))
|
|
2013
|
+
>>> ray = Ray(Point(0.0, 0.0, 0.0), np.array([1.0, 0.0, 0.0]))
|
|
2014
|
+
>>> plane.contains(ray) # True
|
|
2015
|
+
"""
|
|
419
2016
|
@typing.overload
|
|
420
2017
|
def contains(self, segment: Segment) -> bool:
|
|
421
|
-
|
|
2018
|
+
"""
|
|
2019
|
+
Check if the plane contains a segment.
|
|
2020
|
+
|
|
2021
|
+
Args:
|
|
2022
|
+
segment (Segment): The segment to check.
|
|
2023
|
+
|
|
2024
|
+
Returns:
|
|
2025
|
+
bool: True if the plane contains the entire segment, False otherwise.
|
|
2026
|
+
|
|
2027
|
+
Example:
|
|
2028
|
+
>>> plane = Plane(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]))
|
|
2029
|
+
>>> segment = Segment(Point(0.0, 0.0, 0.0), Point(1.0, 0.0, 0.0))
|
|
2030
|
+
>>> plane.contains(segment) # True
|
|
2031
|
+
"""
|
|
422
2032
|
def get_normal_vector(self) -> numpy.ndarray[numpy.float64[3, 1]]:
|
|
423
|
-
|
|
2033
|
+
"""
|
|
2034
|
+
Get the normal vector of the plane.
|
|
2035
|
+
|
|
2036
|
+
Returns:
|
|
2037
|
+
Vector3d: The normal vector to the plane.
|
|
2038
|
+
|
|
2039
|
+
Example:
|
|
2040
|
+
>>> plane = Plane(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]))
|
|
2041
|
+
>>> normal = plane.get_normal_vector() # [0.0, 0.0, 1.0]
|
|
2042
|
+
"""
|
|
424
2043
|
def get_point(self) -> Point:
|
|
425
|
-
|
|
2044
|
+
"""
|
|
2045
|
+
Get a reference point on the plane.
|
|
2046
|
+
|
|
2047
|
+
Returns:
|
|
2048
|
+
Point: A point on the plane.
|
|
2049
|
+
|
|
2050
|
+
Example:
|
|
2051
|
+
>>> plane = Plane(Point(1.0, 2.0, 3.0), np.array([0.0, 0.0, 1.0]))
|
|
2052
|
+
>>> point = plane.get_point()
|
|
2053
|
+
"""
|
|
426
2054
|
@typing.overload
|
|
427
2055
|
def intersection_with(self, point: Point) -> ...:
|
|
428
|
-
|
|
2056
|
+
"""
|
|
2057
|
+
Compute the intersection of the plane with a point.
|
|
2058
|
+
|
|
2059
|
+
Args:
|
|
2060
|
+
point (Point): The point to intersect with.
|
|
2061
|
+
|
|
2062
|
+
Returns:
|
|
2063
|
+
Intersection: The intersection result.
|
|
2064
|
+
|
|
2065
|
+
Example:
|
|
2066
|
+
>>> plane = Plane(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]))
|
|
2067
|
+
>>> intersection = plane.intersection_with(Point(1.0, 1.0, 0.0))
|
|
2068
|
+
"""
|
|
429
2069
|
@typing.overload
|
|
430
2070
|
def intersection_with(self, point_set: PointSet) -> ...:
|
|
431
|
-
|
|
2071
|
+
"""
|
|
2072
|
+
Compute the intersection of the plane with a point set.
|
|
2073
|
+
|
|
2074
|
+
Args:
|
|
2075
|
+
point_set (PointSet): The point set to intersect with.
|
|
2076
|
+
|
|
2077
|
+
Returns:
|
|
2078
|
+
Intersection: The intersection result.
|
|
2079
|
+
|
|
2080
|
+
Example:
|
|
2081
|
+
>>> plane = Plane(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]))
|
|
2082
|
+
>>> points = PointSet([Point(1.0, 1.0, 0.0), Point(2.0, 2.0, 1.0)])
|
|
2083
|
+
>>> intersection = plane.intersection_with(points)
|
|
2084
|
+
"""
|
|
432
2085
|
@typing.overload
|
|
433
2086
|
def intersection_with(self, line: Line) -> ...:
|
|
434
|
-
|
|
2087
|
+
"""
|
|
2088
|
+
Compute the intersection of the plane with a line.
|
|
2089
|
+
|
|
2090
|
+
Args:
|
|
2091
|
+
line (Line): The line to intersect with.
|
|
2092
|
+
|
|
2093
|
+
Returns:
|
|
2094
|
+
Intersection: The intersection result (point or line if coplanar).
|
|
2095
|
+
|
|
2096
|
+
Example:
|
|
2097
|
+
>>> plane = Plane(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]))
|
|
2098
|
+
>>> line = Line(Point(0.0, 0.0, -1.0), np.array([0.0, 0.0, 1.0]))
|
|
2099
|
+
>>> intersection = plane.intersection_with(line)
|
|
2100
|
+
"""
|
|
435
2101
|
@typing.overload
|
|
436
2102
|
def intersection_with(self, ray: Ray) -> ...:
|
|
437
|
-
|
|
2103
|
+
"""
|
|
2104
|
+
Compute the intersection of the plane with a ray.
|
|
2105
|
+
|
|
2106
|
+
Args:
|
|
2107
|
+
ray (Ray): The ray to intersect with.
|
|
2108
|
+
|
|
2109
|
+
Returns:
|
|
2110
|
+
Intersection: The intersection result.
|
|
2111
|
+
|
|
2112
|
+
Example:
|
|
2113
|
+
>>> plane = Plane(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]))
|
|
2114
|
+
>>> ray = Ray(Point(0.0, 0.0, -1.0), np.array([0.0, 0.0, 1.0]))
|
|
2115
|
+
>>> intersection = plane.intersection_with(ray)
|
|
2116
|
+
"""
|
|
438
2117
|
@typing.overload
|
|
439
2118
|
def intersection_with(self, segment: Segment) -> ...:
|
|
440
|
-
|
|
2119
|
+
"""
|
|
2120
|
+
Compute the intersection of the plane with a segment.
|
|
2121
|
+
|
|
2122
|
+
Args:
|
|
2123
|
+
segment (Segment): The segment to intersect with.
|
|
2124
|
+
|
|
2125
|
+
Returns:
|
|
2126
|
+
Intersection: The intersection result.
|
|
2127
|
+
|
|
2128
|
+
Example:
|
|
2129
|
+
>>> plane = Plane(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]))
|
|
2130
|
+
>>> segment = Segment(Point(0.0, 0.0, -1.0), Point(0.0, 0.0, 1.0))
|
|
2131
|
+
>>> intersection = plane.intersection_with(segment)
|
|
2132
|
+
"""
|
|
441
2133
|
@typing.overload
|
|
442
2134
|
def intersects(self, point: Point) -> bool:
|
|
443
|
-
|
|
2135
|
+
"""
|
|
2136
|
+
Check if the plane intersects with a point.
|
|
2137
|
+
|
|
2138
|
+
Args:
|
|
2139
|
+
point (Point): The point to check.
|
|
2140
|
+
|
|
2141
|
+
Returns:
|
|
2142
|
+
bool: True if the plane intersects the point, False otherwise.
|
|
2143
|
+
|
|
2144
|
+
Example:
|
|
2145
|
+
>>> plane = Plane(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]))
|
|
2146
|
+
>>> plane.intersects(Point(1.0, 1.0, 0.0)) # True
|
|
2147
|
+
"""
|
|
444
2148
|
@typing.overload
|
|
445
2149
|
def intersects(self, point_set: PointSet) -> bool:
|
|
446
|
-
|
|
2150
|
+
"""
|
|
2151
|
+
Check if the plane intersects with a point set.
|
|
2152
|
+
|
|
2153
|
+
Args:
|
|
2154
|
+
point_set (PointSet): The point set to check.
|
|
2155
|
+
|
|
2156
|
+
Returns:
|
|
2157
|
+
bool: True if the plane intersects the point set, False otherwise.
|
|
2158
|
+
|
|
2159
|
+
Example:
|
|
2160
|
+
>>> plane = Plane(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]))
|
|
2161
|
+
>>> points = PointSet([Point(1.0, 1.0, 0.0), Point(2.0, 2.0, 0.0)])
|
|
2162
|
+
>>> plane.intersects(points) # True
|
|
2163
|
+
"""
|
|
447
2164
|
@typing.overload
|
|
448
2165
|
def intersects(self, line: Line) -> bool:
|
|
449
|
-
|
|
2166
|
+
"""
|
|
2167
|
+
Check if the plane intersects with a line.
|
|
2168
|
+
|
|
2169
|
+
Args:
|
|
2170
|
+
line (Line): The line to check.
|
|
2171
|
+
|
|
2172
|
+
Returns:
|
|
2173
|
+
bool: True if the plane intersects the line, False otherwise.
|
|
2174
|
+
|
|
2175
|
+
Example:
|
|
2176
|
+
>>> plane = Plane(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]))
|
|
2177
|
+
>>> line = Line(Point(0.0, 0.0, -1.0), np.array([0.0, 0.0, 1.0]))
|
|
2178
|
+
>>> plane.intersects(line) # True
|
|
2179
|
+
"""
|
|
450
2180
|
@typing.overload
|
|
451
2181
|
def intersects(self, ray: Ray) -> bool:
|
|
452
|
-
|
|
2182
|
+
"""
|
|
2183
|
+
Check if the plane intersects with a ray.
|
|
2184
|
+
|
|
2185
|
+
Args:
|
|
2186
|
+
ray (Ray): The ray to check.
|
|
2187
|
+
|
|
2188
|
+
Returns:
|
|
2189
|
+
bool: True if the plane intersects the ray, False otherwise.
|
|
2190
|
+
|
|
2191
|
+
Example:
|
|
2192
|
+
>>> plane = Plane(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]))
|
|
2193
|
+
>>> ray = Ray(Point(0.0, 0.0, -1.0), np.array([0.0, 0.0, 1.0]))
|
|
2194
|
+
>>> plane.intersects(ray) # True
|
|
2195
|
+
"""
|
|
453
2196
|
@typing.overload
|
|
454
2197
|
def intersects(self, segment: Segment) -> bool:
|
|
455
|
-
|
|
2198
|
+
"""
|
|
2199
|
+
Check if the plane intersects with a segment.
|
|
2200
|
+
|
|
2201
|
+
Args:
|
|
2202
|
+
segment (Segment): The segment to check.
|
|
2203
|
+
|
|
2204
|
+
Returns:
|
|
2205
|
+
bool: True if the plane intersects the segment, False otherwise.
|
|
2206
|
+
|
|
2207
|
+
Example:
|
|
2208
|
+
>>> plane = Plane(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]))
|
|
2209
|
+
>>> segment = Segment(Point(0.0, 0.0, -1.0), Point(0.0, 0.0, 1.0))
|
|
2210
|
+
>>> plane.intersects(segment) # True
|
|
2211
|
+
"""
|
|
456
2212
|
def is_defined(self) -> bool:
|
|
457
|
-
|
|
2213
|
+
"""
|
|
2214
|
+
Check if the plane is defined.
|
|
2215
|
+
|
|
2216
|
+
Returns:
|
|
2217
|
+
bool: True if the plane is defined, False otherwise.
|
|
2218
|
+
|
|
2219
|
+
Example:
|
|
2220
|
+
>>> plane = Plane(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]))
|
|
2221
|
+
>>> plane.is_defined() # True
|
|
2222
|
+
"""
|
|
458
2223
|
class Point(ostk.mathematics.geometry.d3.Object):
|
|
459
2224
|
__hash__: typing.ClassVar[None] = None
|
|
460
2225
|
@staticmethod
|
|
461
2226
|
def origin() -> Point:
|
|
462
|
-
|
|
2227
|
+
"""
|
|
2228
|
+
Create a point at the origin (0, 0, 0).
|
|
2229
|
+
|
|
2230
|
+
Returns:
|
|
2231
|
+
Point: A point at coordinates (0, 0, 0).
|
|
2232
|
+
|
|
2233
|
+
Example:
|
|
2234
|
+
>>> origin = Point.origin()
|
|
2235
|
+
>>> origin.x() # 0.0
|
|
2236
|
+
>>> origin.y() # 0.0
|
|
2237
|
+
>>> origin.z() # 0.0
|
|
2238
|
+
"""
|
|
463
2239
|
@staticmethod
|
|
464
2240
|
def undefined() -> Point:
|
|
465
|
-
|
|
2241
|
+
"""
|
|
2242
|
+
Create an undefined point.
|
|
2243
|
+
|
|
2244
|
+
Returns:
|
|
2245
|
+
Point: An undefined point.
|
|
2246
|
+
|
|
2247
|
+
Example:
|
|
2248
|
+
>>> undefined_point = Point.undefined()
|
|
2249
|
+
>>> undefined_point.is_defined() # False
|
|
2250
|
+
"""
|
|
466
2251
|
@staticmethod
|
|
467
|
-
def vector(
|
|
468
|
-
|
|
2252
|
+
def vector(vector: numpy.ndarray[numpy.float64[3, 1]]) -> Point:
|
|
2253
|
+
"""
|
|
2254
|
+
Create a point from a 3D vector.
|
|
2255
|
+
|
|
2256
|
+
Args:
|
|
2257
|
+
vector (np.array): The vector to convert to a point.
|
|
2258
|
+
|
|
2259
|
+
Returns:
|
|
2260
|
+
Point: A point with coordinates from the vector.
|
|
2261
|
+
|
|
2262
|
+
Example:
|
|
2263
|
+
>>> vector = np.array([1.0, 2.0, 3.0])
|
|
2264
|
+
>>> point = Point.vector(vector) # Point(1.0, 2.0, 3.0)
|
|
2265
|
+
"""
|
|
469
2266
|
def __add__(self, arg0: numpy.ndarray[numpy.float64[3, 1]]) -> Point:
|
|
470
2267
|
...
|
|
471
2268
|
def __eq__(self, arg0: Point) -> bool:
|
|
472
2269
|
...
|
|
473
2270
|
def __init__(self, first_coordinate: ostk.core.type.Real, second_coordinate: ostk.core.type.Real, third_coordinate: ostk.core.type.Real) -> None:
|
|
474
|
-
|
|
2271
|
+
"""
|
|
2272
|
+
Create a 3D point with specified coordinates.
|
|
2273
|
+
|
|
2274
|
+
Args:
|
|
2275
|
+
first_coordinate (float): The x-coordinate.
|
|
2276
|
+
second_coordinate (float): The y-coordinate.
|
|
2277
|
+
third_coordinate (float): The z-coordinate.
|
|
2278
|
+
|
|
2279
|
+
Example:
|
|
2280
|
+
>>> point = Point(1.0, 2.0, 3.0)
|
|
2281
|
+
>>> point.x() # 1.0
|
|
2282
|
+
>>> point.y() # 2.0
|
|
2283
|
+
>>> point.z() # 3.0
|
|
2284
|
+
"""
|
|
475
2285
|
def __ne__(self, arg0: Point) -> bool:
|
|
476
2286
|
...
|
|
477
2287
|
def __repr__(self) -> str:
|
|
@@ -485,34 +2295,158 @@ class Point(ostk.mathematics.geometry.d3.Object):
|
|
|
485
2295
|
def __sub__(self, arg0: Point) -> numpy.ndarray[numpy.float64[3, 1]]:
|
|
486
2296
|
...
|
|
487
2297
|
def apply_transformation(self, transformation: typing.Any) -> None:
|
|
488
|
-
|
|
2298
|
+
"""
|
|
2299
|
+
Apply a transformation to the point.
|
|
2300
|
+
|
|
2301
|
+
Args:
|
|
2302
|
+
transformation (Transformation): The transformation to apply.
|
|
2303
|
+
|
|
2304
|
+
Returns:
|
|
2305
|
+
Point: The transformed point.
|
|
2306
|
+
|
|
2307
|
+
Example:
|
|
2308
|
+
>>> point = Point(1.0, 2.0, 3.0)
|
|
2309
|
+
>>> transformation = Transformation.identity()
|
|
2310
|
+
>>> transformed = point.apply_transformation(transformation)
|
|
2311
|
+
"""
|
|
489
2312
|
def as_vector(self) -> numpy.ndarray[numpy.float64[3, 1]]:
|
|
490
|
-
|
|
2313
|
+
"""
|
|
2314
|
+
Convert the point to a 3D vector.
|
|
2315
|
+
|
|
2316
|
+
Returns:
|
|
2317
|
+
Vector3d: The point as a 3D vector.
|
|
2318
|
+
|
|
2319
|
+
Example:
|
|
2320
|
+
>>> point = Point(1.0, 2.0, 3.0)
|
|
2321
|
+
>>> vector = point.as_vector() # np.array([1.0, 2.0, 3.0])
|
|
2322
|
+
"""
|
|
491
2323
|
def distance_to(self, point: Point) -> ostk.core.type.Real:
|
|
492
|
-
|
|
2324
|
+
"""
|
|
2325
|
+
Calculate the distance to another point.
|
|
2326
|
+
|
|
2327
|
+
Args:
|
|
2328
|
+
point (Point): The other point.
|
|
2329
|
+
|
|
2330
|
+
Returns:
|
|
2331
|
+
float: The distance between the points.
|
|
2332
|
+
|
|
2333
|
+
Example:
|
|
2334
|
+
>>> point1 = Point(0.0, 0.0, 0.0)
|
|
2335
|
+
>>> point2 = Point(3.0, 4.0, 0.0)
|
|
2336
|
+
>>> point1.distance_to(point2) # 5.0
|
|
2337
|
+
"""
|
|
493
2338
|
def is_defined(self) -> bool:
|
|
494
|
-
|
|
2339
|
+
"""
|
|
2340
|
+
Check if the point is defined.
|
|
2341
|
+
|
|
2342
|
+
Returns:
|
|
2343
|
+
bool: True if the point is defined, False otherwise.
|
|
2344
|
+
|
|
2345
|
+
Example:
|
|
2346
|
+
>>> point = Point(1.0, 2.0, 3.0)
|
|
2347
|
+
>>> point.is_defined() # True
|
|
2348
|
+
"""
|
|
495
2349
|
def is_near(self, point: Point, tolerance: ostk.core.type.Real) -> bool:
|
|
496
|
-
|
|
2350
|
+
"""
|
|
2351
|
+
Check if this point is near another point within tolerance.
|
|
2352
|
+
|
|
2353
|
+
Args:
|
|
2354
|
+
point (Point): The point to compare with.
|
|
2355
|
+
tolerance (float): The tolerance for comparison.
|
|
2356
|
+
|
|
2357
|
+
Returns:
|
|
2358
|
+
bool: True if points are within tolerance, False otherwise.
|
|
2359
|
+
|
|
2360
|
+
Example:
|
|
2361
|
+
>>> point1 = Point(1.0, 2.0, 3.0)
|
|
2362
|
+
>>> point2 = Point(1.1, 2.1, 3.1)
|
|
2363
|
+
>>> point1.is_near(point2, 0.2) # True
|
|
2364
|
+
"""
|
|
497
2365
|
def to_string(self, precision: ostk.core.type.Integer = ...) -> ostk.core.type.String:
|
|
498
|
-
|
|
2366
|
+
"""
|
|
2367
|
+
Convert the point to a string representation.
|
|
2368
|
+
|
|
2369
|
+
Args:
|
|
2370
|
+
precision (int, optional): Number of decimal places. Defaults to DEFAULT_PRECISION.
|
|
2371
|
+
|
|
2372
|
+
Returns:
|
|
2373
|
+
str: String representation of the point.
|
|
2374
|
+
|
|
2375
|
+
Example:
|
|
2376
|
+
>>> point = Point(1.123456, 2.345678, 3.567890)
|
|
2377
|
+
>>> point.to_string(3) # "[1.123, 2.346, 3.568]"
|
|
2378
|
+
"""
|
|
499
2379
|
def x(self) -> ostk.core.type.Real:
|
|
500
|
-
|
|
2380
|
+
"""
|
|
2381
|
+
Get the x-coordinate of the point.
|
|
2382
|
+
|
|
2383
|
+
Returns:
|
|
2384
|
+
float: The x-coordinate.
|
|
2385
|
+
|
|
2386
|
+
Example:
|
|
2387
|
+
>>> point = Point(1.0, 2.0, 3.0)
|
|
2388
|
+
>>> point.x() # 1.0
|
|
2389
|
+
"""
|
|
501
2390
|
def y(self) -> ostk.core.type.Real:
|
|
502
|
-
|
|
2391
|
+
"""
|
|
2392
|
+
Get the y-coordinate of the point.
|
|
2393
|
+
|
|
2394
|
+
Returns:
|
|
2395
|
+
float: The y-coordinate.
|
|
2396
|
+
|
|
2397
|
+
Example:
|
|
2398
|
+
>>> point = Point(1.0, 2.0, 3.0)
|
|
2399
|
+
>>> point.y() # 2.0
|
|
2400
|
+
"""
|
|
503
2401
|
def z(self) -> ostk.core.type.Real:
|
|
504
|
-
|
|
2402
|
+
"""
|
|
2403
|
+
Get the z-coordinate of the point.
|
|
2404
|
+
|
|
2405
|
+
Returns:
|
|
2406
|
+
float: The z-coordinate.
|
|
2407
|
+
|
|
2408
|
+
Example:
|
|
2409
|
+
>>> point = Point(1.0, 2.0, 3.0)
|
|
2410
|
+
>>> point.z() # 3.0
|
|
2411
|
+
"""
|
|
505
2412
|
class PointSet(ostk.mathematics.geometry.d3.Object):
|
|
2413
|
+
"""
|
|
2414
|
+
|
|
2415
|
+
A collection of 3D points.
|
|
2416
|
+
|
|
2417
|
+
A PointSet is an unordered collection of unique points in 3D space.
|
|
2418
|
+
|
|
2419
|
+
"""
|
|
506
2420
|
__hash__: typing.ClassVar[None] = None
|
|
507
2421
|
@staticmethod
|
|
508
2422
|
def empty() -> PointSet:
|
|
509
|
-
|
|
2423
|
+
"""
|
|
2424
|
+
Create an empty point set.
|
|
2425
|
+
|
|
2426
|
+
Returns:
|
|
2427
|
+
PointSet: An empty point set.
|
|
2428
|
+
|
|
2429
|
+
Example:
|
|
2430
|
+
>>> empty_set = PointSet.empty()
|
|
2431
|
+
>>> empty_set.is_empty() # True
|
|
2432
|
+
>>> empty_set.get_size() # 0
|
|
2433
|
+
"""
|
|
510
2434
|
def __eq__(self, arg0: PointSet) -> bool:
|
|
511
2435
|
...
|
|
512
2436
|
def __getitem__(self, arg0: int) -> Point:
|
|
513
2437
|
...
|
|
514
2438
|
def __init__(self, points: list[Point]) -> None:
|
|
515
|
-
|
|
2439
|
+
"""
|
|
2440
|
+
Construct a point set from an array of points.
|
|
2441
|
+
|
|
2442
|
+
Args:
|
|
2443
|
+
points (list[Point]): Array of 3D points.
|
|
2444
|
+
|
|
2445
|
+
Example:
|
|
2446
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
2447
|
+
>>> point_set = PointSet(points)
|
|
2448
|
+
>>> point_set.is_defined() # True
|
|
2449
|
+
"""
|
|
516
2450
|
def __iter__(self) -> typing.Iterator[Point]:
|
|
517
2451
|
...
|
|
518
2452
|
def __len__(self) -> int:
|
|
@@ -524,28 +2458,135 @@ class PointSet(ostk.mathematics.geometry.d3.Object):
|
|
|
524
2458
|
def __str__(self) -> str:
|
|
525
2459
|
...
|
|
526
2460
|
def apply_transformation(self, transformation: typing.Any) -> None:
|
|
527
|
-
|
|
2461
|
+
"""
|
|
2462
|
+
Apply a transformation to all points in the set.
|
|
2463
|
+
|
|
2464
|
+
Args:
|
|
2465
|
+
transformation (Transformation): The transformation to apply.
|
|
2466
|
+
|
|
2467
|
+
Example:
|
|
2468
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
2469
|
+
>>> point_set = PointSet(points)
|
|
2470
|
+
>>> transformation = Transformation.translation([1.0, 0.0])
|
|
2471
|
+
>>> point_set.apply_transformation(transformation)
|
|
2472
|
+
"""
|
|
528
2473
|
def distance_to(self, point: Point) -> ostk.core.type.Real:
|
|
529
|
-
|
|
2474
|
+
"""
|
|
2475
|
+
Calculate the minimum distance from the point set to a point.
|
|
2476
|
+
|
|
2477
|
+
Args:
|
|
2478
|
+
point (Point): The point to measure distance to.
|
|
2479
|
+
|
|
2480
|
+
Returns:
|
|
2481
|
+
float: The minimum distance to any point in the set.
|
|
2482
|
+
|
|
2483
|
+
Example:
|
|
2484
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
2485
|
+
>>> point_set = PointSet(points)
|
|
2486
|
+
>>> point_set.distance_to(Point(0.5, 0.5)) # 0.5
|
|
2487
|
+
"""
|
|
530
2488
|
def get_point_closest_to(self, point: Point) -> Point:
|
|
531
|
-
|
|
2489
|
+
"""
|
|
2490
|
+
Get the point in the set closest to a given point.
|
|
2491
|
+
|
|
2492
|
+
Args:
|
|
2493
|
+
point (Point): The reference point.
|
|
2494
|
+
|
|
2495
|
+
Returns:
|
|
2496
|
+
Point: The closest point in the set.
|
|
2497
|
+
|
|
2498
|
+
Example:
|
|
2499
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
2500
|
+
>>> point_set = PointSet(points)
|
|
2501
|
+
>>> point_set.get_point_closest_to(Point(0.5, 0.5)) # Point(0.5, 0.5)
|
|
2502
|
+
"""
|
|
532
2503
|
def get_size(self) -> int:
|
|
533
|
-
|
|
2504
|
+
"""
|
|
2505
|
+
Get the number of points in the set.
|
|
2506
|
+
|
|
2507
|
+
Returns:
|
|
2508
|
+
int: The number of points.
|
|
2509
|
+
|
|
2510
|
+
Example:
|
|
2511
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
2512
|
+
>>> point_set = PointSet(points)
|
|
2513
|
+
>>> point_set.get_size() # 2
|
|
2514
|
+
"""
|
|
534
2515
|
def is_defined(self) -> bool:
|
|
535
|
-
|
|
2516
|
+
"""
|
|
2517
|
+
Check if the point set is defined.
|
|
2518
|
+
|
|
2519
|
+
Returns:
|
|
2520
|
+
bool: True if the point set is defined.
|
|
2521
|
+
|
|
2522
|
+
Example:
|
|
2523
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
2524
|
+
>>> point_set = PointSet(points)
|
|
2525
|
+
>>> point_set.is_defined() # True
|
|
2526
|
+
"""
|
|
536
2527
|
def is_empty(self) -> bool:
|
|
537
|
-
|
|
2528
|
+
"""
|
|
2529
|
+
Check if the point set is empty.
|
|
2530
|
+
|
|
2531
|
+
Returns:
|
|
2532
|
+
bool: True if the point set contains no points.
|
|
2533
|
+
"""
|
|
538
2534
|
def is_near(self, point_set: PointSet, tolerance: ostk.core.type.Real) -> bool:
|
|
539
|
-
|
|
2535
|
+
"""
|
|
2536
|
+
Check if another point set is near this one within a tolerance.
|
|
2537
|
+
|
|
2538
|
+
Args:
|
|
2539
|
+
point_set (PointSet): The point set to compare against.
|
|
2540
|
+
tolerance (float): The maximum distance for points to be considered near.
|
|
2541
|
+
|
|
2542
|
+
Returns:
|
|
2543
|
+
bool: True if the point sets are near each other.
|
|
2544
|
+
|
|
2545
|
+
Example:
|
|
2546
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
2547
|
+
>>> point_set = PointSet(points)
|
|
2548
|
+
>>> point_set.is_near(PointSet(points), 0.1) # True
|
|
2549
|
+
"""
|
|
540
2550
|
class Polygon(ostk.mathematics.geometry.d3.Object):
|
|
2551
|
+
"""
|
|
2552
|
+
|
|
2553
|
+
A polygon in 3D space.
|
|
2554
|
+
|
|
2555
|
+
A Polygon is a planar figure defined by a 2D polygon and its position and orientation in 3D space.
|
|
2556
|
+
|
|
2557
|
+
"""
|
|
541
2558
|
__hash__: typing.ClassVar[None] = None
|
|
542
2559
|
@staticmethod
|
|
543
2560
|
def undefined() -> Polygon:
|
|
544
|
-
|
|
2561
|
+
"""
|
|
2562
|
+
Create an undefined polygon.
|
|
2563
|
+
|
|
2564
|
+
Returns:
|
|
2565
|
+
Polygon: An undefined polygon.
|
|
2566
|
+
|
|
2567
|
+
Example:
|
|
2568
|
+
>>> undefined_polygon = Polygon.undefined()
|
|
2569
|
+
>>> undefined_polygon.is_defined() # False
|
|
2570
|
+
"""
|
|
545
2571
|
def __eq__(self, arg0: Polygon) -> bool:
|
|
546
2572
|
...
|
|
547
2573
|
def __init__(self, polygon: ostk.mathematics.geometry.d2.object.Polygon, origin: Point, x_axis: numpy.ndarray[numpy.float64[3, 1]], y_axis: numpy.ndarray[numpy.float64[3, 1]]) -> None:
|
|
548
|
-
|
|
2574
|
+
"""
|
|
2575
|
+
Construct a 3D polygon from a 2D polygon and coordinate frame.
|
|
2576
|
+
|
|
2577
|
+
Args:
|
|
2578
|
+
polygon (Polygon2d): The 2D polygon.
|
|
2579
|
+
origin (Point): The origin of the polygon in 3D space.
|
|
2580
|
+
x_axis (numpy.ndarray): The x-axis direction of the polygon's local frame.
|
|
2581
|
+
y_axis (numpy.ndarray): The y-axis direction of the polygon's local frame.
|
|
2582
|
+
|
|
2583
|
+
Example:
|
|
2584
|
+
>>> polygon2d = Polygon2d([Point2d(0.0, 0.0), Point2d(1.0, 0.0), Point2d(1.0, 1.0), Point2d(0.0, 1.0)])
|
|
2585
|
+
>>> origin = Point(0.0, 0.0, 0.0)
|
|
2586
|
+
>>> x_axis = np.array([1.0, 0.0, 0.0])
|
|
2587
|
+
>>> y_axis = np.array([0.0, 1.0, 0.0])
|
|
2588
|
+
>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
|
|
2589
|
+
"""
|
|
549
2590
|
def __ne__(self, arg0: Polygon) -> bool:
|
|
550
2591
|
...
|
|
551
2592
|
def __repr__(self) -> str:
|
|
@@ -553,40 +2594,195 @@ class Polygon(ostk.mathematics.geometry.d3.Object):
|
|
|
553
2594
|
def __str__(self) -> str:
|
|
554
2595
|
...
|
|
555
2596
|
def apply_transformation(self, transformation: typing.Any) -> None:
|
|
556
|
-
|
|
2597
|
+
"""
|
|
2598
|
+
Apply a transformation to the polygon in place.
|
|
2599
|
+
|
|
2600
|
+
Args:
|
|
2601
|
+
transformation (Transformation): The transformation to apply.
|
|
2602
|
+
|
|
2603
|
+
Example:
|
|
2604
|
+
>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
|
|
2605
|
+
>>> transformation = Transformation.identity()
|
|
2606
|
+
>>> polygon.apply_transformation(transformation)
|
|
2607
|
+
"""
|
|
557
2608
|
def get_edge_at(self, index: int) -> Segment:
|
|
558
|
-
|
|
2609
|
+
"""
|
|
2610
|
+
Get the edge at a given index.
|
|
2611
|
+
|
|
2612
|
+
Args:
|
|
2613
|
+
index (int): The index of the edge.
|
|
2614
|
+
|
|
2615
|
+
Returns:
|
|
2616
|
+
Segment: The edge segment.
|
|
2617
|
+
|
|
2618
|
+
Example:
|
|
2619
|
+
>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
|
|
2620
|
+
>>> polygon.get_edge_at(0)
|
|
2621
|
+
"""
|
|
559
2622
|
def get_edge_count(self) -> int:
|
|
560
|
-
|
|
2623
|
+
"""
|
|
2624
|
+
Get the number of edges in the polygon.
|
|
2625
|
+
|
|
2626
|
+
Returns:
|
|
2627
|
+
int: The number of edges.
|
|
2628
|
+
|
|
2629
|
+
Example:
|
|
2630
|
+
>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
|
|
2631
|
+
>>> polygon.get_edge_count()
|
|
2632
|
+
"""
|
|
561
2633
|
def get_normal_vector(self) -> numpy.ndarray[numpy.float64[3, 1]]:
|
|
562
|
-
|
|
2634
|
+
"""
|
|
2635
|
+
Get the normal vector of the polygon's plane.
|
|
2636
|
+
|
|
2637
|
+
Returns:
|
|
2638
|
+
numpy.ndarray: The normal vector.
|
|
2639
|
+
|
|
2640
|
+
Example:
|
|
2641
|
+
>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
|
|
2642
|
+
>>> polygon.get_normal_vector()
|
|
2643
|
+
"""
|
|
563
2644
|
def get_origin(self) -> Point:
|
|
564
|
-
|
|
2645
|
+
"""
|
|
2646
|
+
Get the origin point of the polygon.
|
|
2647
|
+
|
|
2648
|
+
Returns:
|
|
2649
|
+
Point: The origin point.
|
|
2650
|
+
|
|
2651
|
+
Example:
|
|
2652
|
+
>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
|
|
2653
|
+
>>> polygon.get_origin()
|
|
2654
|
+
"""
|
|
565
2655
|
def get_polygon2d(self) -> ostk.mathematics.geometry.d2.object.Polygon:
|
|
566
|
-
|
|
2656
|
+
"""
|
|
2657
|
+
Get the 2D polygon representation.
|
|
2658
|
+
|
|
2659
|
+
Returns:
|
|
2660
|
+
Polygon2d: The 2D polygon.
|
|
2661
|
+
|
|
2662
|
+
Example:
|
|
2663
|
+
>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
|
|
2664
|
+
>>> polygon.get_polygon2d()
|
|
2665
|
+
"""
|
|
567
2666
|
def get_vertex_at(self, index: int) -> Point:
|
|
568
|
-
|
|
2667
|
+
"""
|
|
2668
|
+
Get the vertex at a given index.
|
|
2669
|
+
|
|
2670
|
+
Args:
|
|
2671
|
+
index (int): The index of the vertex.
|
|
2672
|
+
|
|
2673
|
+
Returns:
|
|
2674
|
+
Point: The vertex point.
|
|
2675
|
+
|
|
2676
|
+
Example:
|
|
2677
|
+
>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
|
|
2678
|
+
>>> polygon.get_vertex_at(0)
|
|
2679
|
+
"""
|
|
569
2680
|
def get_vertex_count(self) -> int:
|
|
570
|
-
|
|
2681
|
+
"""
|
|
2682
|
+
Get the number of vertices in the polygon.
|
|
2683
|
+
|
|
2684
|
+
Returns:
|
|
2685
|
+
int: The number of vertices.
|
|
2686
|
+
|
|
2687
|
+
Example:
|
|
2688
|
+
>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
|
|
2689
|
+
>>> polygon.get_vertex_count()
|
|
2690
|
+
"""
|
|
571
2691
|
def get_vertices(self) -> list[Point]:
|
|
572
|
-
|
|
2692
|
+
"""
|
|
2693
|
+
Get all vertices of the polygon.
|
|
2694
|
+
|
|
2695
|
+
Returns:
|
|
2696
|
+
list[Point]: Array of vertex points.
|
|
2697
|
+
|
|
2698
|
+
Example:
|
|
2699
|
+
>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
|
|
2700
|
+
>>> polygon.get_vertices()
|
|
2701
|
+
"""
|
|
573
2702
|
def get_x_axis(self) -> numpy.ndarray[numpy.float64[3, 1]]:
|
|
574
|
-
|
|
2703
|
+
"""
|
|
2704
|
+
Get the x-axis direction of the polygon's local frame.
|
|
2705
|
+
|
|
2706
|
+
Returns:
|
|
2707
|
+
numpy.ndarray: The x-axis vector.
|
|
2708
|
+
|
|
2709
|
+
Example:
|
|
2710
|
+
>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
|
|
2711
|
+
>>> polygon.get_x_axis()
|
|
2712
|
+
"""
|
|
575
2713
|
def get_y_axis(self) -> numpy.ndarray[numpy.float64[3, 1]]:
|
|
576
|
-
|
|
2714
|
+
"""
|
|
2715
|
+
Get the y-axis direction of the polygon's local frame.
|
|
2716
|
+
|
|
2717
|
+
Returns:
|
|
2718
|
+
numpy.ndarray: The y-axis vector.
|
|
2719
|
+
|
|
2720
|
+
Example:
|
|
2721
|
+
>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
|
|
2722
|
+
>>> polygon.get_y_axis()
|
|
2723
|
+
"""
|
|
577
2724
|
def is_defined(self) -> bool:
|
|
578
|
-
|
|
2725
|
+
"""
|
|
2726
|
+
Check if the polygon is defined.
|
|
2727
|
+
|
|
2728
|
+
Returns:
|
|
2729
|
+
bool: True if the polygon is defined.
|
|
2730
|
+
|
|
2731
|
+
Example:
|
|
2732
|
+
>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
|
|
2733
|
+
>>> polygon.is_defined()
|
|
2734
|
+
"""
|
|
579
2735
|
def is_near(self, polygon: Polygon, tolerance: ostk.core.type.Real) -> bool:
|
|
580
|
-
|
|
2736
|
+
"""
|
|
2737
|
+
Check if another polygon is near this one within a tolerance.
|
|
2738
|
+
|
|
2739
|
+
Args:
|
|
2740
|
+
polygon (Polygon): The polygon to compare against.
|
|
2741
|
+
tolerance (float): The maximum distance for polygons to be considered near.
|
|
2742
|
+
|
|
2743
|
+
Returns:
|
|
2744
|
+
bool: True if the polygons are near each other.
|
|
2745
|
+
|
|
2746
|
+
Example:
|
|
2747
|
+
>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
|
|
2748
|
+
>>> polygon.is_near(polygon, 0.0)
|
|
2749
|
+
"""
|
|
581
2750
|
class Pyramid(ostk.mathematics.geometry.d3.Object):
|
|
2751
|
+
"""
|
|
2752
|
+
|
|
2753
|
+
A pyramid in 3D space.
|
|
2754
|
+
|
|
2755
|
+
A Pyramid is defined by a polygonal base and an apex point, with triangular lateral faces connecting the base edges to the apex.
|
|
2756
|
+
|
|
2757
|
+
"""
|
|
582
2758
|
__hash__: typing.ClassVar[None] = None
|
|
583
2759
|
@staticmethod
|
|
584
2760
|
def undefined() -> Pyramid:
|
|
585
|
-
|
|
2761
|
+
"""
|
|
2762
|
+
Create an undefined pyramid.
|
|
2763
|
+
|
|
2764
|
+
Returns:
|
|
2765
|
+
Pyramid: An undefined pyramid.
|
|
2766
|
+
|
|
2767
|
+
Example:
|
|
2768
|
+
>>> undefined_pyramid = Pyramid.undefined()
|
|
2769
|
+
>>> undefined_pyramid.is_defined() # False
|
|
2770
|
+
"""
|
|
586
2771
|
def __eq__(self, arg0: Pyramid) -> bool:
|
|
587
2772
|
...
|
|
588
2773
|
def __init__(self, base: Polygon, apex: Point) -> None:
|
|
589
|
-
|
|
2774
|
+
"""
|
|
2775
|
+
Construct a pyramid from a base polygon and apex point.
|
|
2776
|
+
|
|
2777
|
+
Args:
|
|
2778
|
+
base (Polygon): The polygonal base of the pyramid.
|
|
2779
|
+
apex (Point): The apex point of the pyramid.
|
|
2780
|
+
|
|
2781
|
+
Example:
|
|
2782
|
+
>>> base = Polygon([Point2d(0.0, 0.0), Point2d(1.0, 0.0), Point2d(1.0, 1.0), Point2d(0.0, 1.0)])
|
|
2783
|
+
>>> apex = Point(0.0, 0.0, 1.0)
|
|
2784
|
+
>>> pyramid = Pyramid(base, apex)
|
|
2785
|
+
"""
|
|
590
2786
|
def __ne__(self, arg0: Pyramid) -> bool:
|
|
591
2787
|
...
|
|
592
2788
|
def __repr__(self) -> str:
|
|
@@ -594,50 +2790,266 @@ class Pyramid(ostk.mathematics.geometry.d3.Object):
|
|
|
594
2790
|
def __str__(self) -> str:
|
|
595
2791
|
...
|
|
596
2792
|
def apply_transformation(self, transformation: typing.Any) -> None:
|
|
597
|
-
|
|
2793
|
+
"""
|
|
2794
|
+
Apply a transformation to the pyramid.
|
|
2795
|
+
|
|
2796
|
+
Args:
|
|
2797
|
+
transformation (Transformation): The transformation to apply.
|
|
2798
|
+
|
|
2799
|
+
Example:
|
|
2800
|
+
>>> base = Polygon([Point2d(0.0, 0.0), Point2d(1.0, 0.0), Point2d(1.0, 1.0), Point2d(0.0, 1.0)])
|
|
2801
|
+
>>> apex = Point(0.0, 0.0, 1.0)
|
|
2802
|
+
>>> pyramid = Pyramid(base, apex)
|
|
2803
|
+
>>> transformation = Transformation.identity()
|
|
2804
|
+
>>> pyramid.apply_transformation(transformation)
|
|
2805
|
+
"""
|
|
598
2806
|
@typing.overload
|
|
599
2807
|
def contains(self, point: Point) -> bool:
|
|
600
|
-
|
|
2808
|
+
"""
|
|
2809
|
+
Check if the pyramid contains a point.
|
|
2810
|
+
|
|
2811
|
+
Args:
|
|
2812
|
+
point (Point): The point to check.
|
|
2813
|
+
|
|
2814
|
+
Returns:
|
|
2815
|
+
bool: True if the pyramid contains the point.
|
|
2816
|
+
|
|
2817
|
+
Example:
|
|
2818
|
+
>>> base = Polygon([Point2d(0.0, 0.0), Point2d(1.0, 0.0), Point2d(1.0, 1.0), Point2d(0.0, 1.0)])
|
|
2819
|
+
>>> apex = Point(0.0, 0.0, 1.0)
|
|
2820
|
+
>>> pyramid = Pyramid(base, apex)
|
|
2821
|
+
>>> pyramid.contains(Point(0.5, 0.5, 0.5))
|
|
2822
|
+
"""
|
|
601
2823
|
@typing.overload
|
|
602
2824
|
def contains(self, point_set: PointSet) -> bool:
|
|
603
|
-
|
|
2825
|
+
"""
|
|
2826
|
+
Check if the pyramid contains all points in a point set.
|
|
2827
|
+
|
|
2828
|
+
Args:
|
|
2829
|
+
point_set (PointSet): The point set to check.
|
|
2830
|
+
|
|
2831
|
+
Returns:
|
|
2832
|
+
bool: True if the pyramid contains all points.
|
|
2833
|
+
|
|
2834
|
+
Example:
|
|
2835
|
+
>>> base = Polygon([Point2d(0.0, 0.0), Point2d(1.0, 0.0), Point2d(1.0, 1.0), Point2d(0.0, 1.0)])
|
|
2836
|
+
>>> apex = Point(0.0, 0.0, 1.0)
|
|
2837
|
+
>>> pyramid = Pyramid(base, apex)
|
|
2838
|
+
>>> pyramid.contains(PointSet([Point(0.5, 0.5, 0.5), Point(0.6, 0.6, 0.6)]))
|
|
2839
|
+
"""
|
|
604
2840
|
@typing.overload
|
|
605
2841
|
def contains(self, segment: Segment) -> bool:
|
|
606
|
-
|
|
2842
|
+
"""
|
|
2843
|
+
Check if the pyramid contains a segment.
|
|
2844
|
+
|
|
2845
|
+
Args:
|
|
2846
|
+
segment (Segment): The segment to check.
|
|
2847
|
+
|
|
2848
|
+
Returns:
|
|
2849
|
+
bool: True if the pyramid contains the segment.
|
|
2850
|
+
|
|
2851
|
+
Example:
|
|
2852
|
+
>>> base = Polygon([Point2d(0.0, 0.0), Point2d(1.0, 0.0), Point2d(1.0, 1.0), Point2d(0.0, 1.0)])
|
|
2853
|
+
>>> apex = Point(0.0, 0.0, 1.0)
|
|
2854
|
+
>>> pyramid = Pyramid(base, apex)
|
|
2855
|
+
>>> pyramid.contains(Segment(Point(0.5, 0.5, 0.5), Point(0.6, 0.6, 0.6)))
|
|
2856
|
+
"""
|
|
607
2857
|
@typing.overload
|
|
608
2858
|
def contains(self, ellipsoid: Ellipsoid) -> bool:
|
|
609
|
-
|
|
2859
|
+
"""
|
|
2860
|
+
Check if the pyramid contains an ellipsoid.
|
|
2861
|
+
|
|
2862
|
+
Args:
|
|
2863
|
+
ellipsoid (Ellipsoid): The ellipsoid to check.
|
|
2864
|
+
|
|
2865
|
+
Returns:
|
|
2866
|
+
bool: True if the pyramid contains the ellipsoid.
|
|
2867
|
+
|
|
2868
|
+
Example:
|
|
2869
|
+
>>> base = Polygon([Point2d(0.0, 0.0), Point2d(1.0, 0.0), Point2d(1.0, 1.0), Point2d(0.0, 1.0)])
|
|
2870
|
+
>>> apex = Point(0.0, 0.0, 1.0)
|
|
2871
|
+
>>> pyramid = Pyramid(base, apex)
|
|
2872
|
+
>>> pyramid.contains(Ellipsoid(Point(0.0, 0.0, 0.0), 1.0, 1.0, 1.0))
|
|
2873
|
+
"""
|
|
610
2874
|
def get_apex(self) -> Point:
|
|
611
|
-
|
|
2875
|
+
"""
|
|
2876
|
+
Get the apex point of the pyramid.
|
|
2877
|
+
|
|
2878
|
+
Returns:
|
|
2879
|
+
Point: The apex point.
|
|
2880
|
+
|
|
2881
|
+
Example:
|
|
2882
|
+
>>> base = Polygon([Point2d(0.0, 0.0), Point2d(1.0, 0.0), Point2d(1.0, 1.0), Point2d(0.0, 1.0)])
|
|
2883
|
+
>>> apex = Point(0.0, 0.0, 1.0)
|
|
2884
|
+
>>> pyramid = Pyramid(base, apex)
|
|
2885
|
+
>>> pyramid.get_apex()
|
|
2886
|
+
"""
|
|
612
2887
|
def get_base(self) -> Polygon:
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
2888
|
+
"""
|
|
2889
|
+
Get the base polygon of the pyramid.
|
|
2890
|
+
|
|
2891
|
+
Returns:
|
|
2892
|
+
Polygon: The base polygon.
|
|
2893
|
+
|
|
2894
|
+
Example:
|
|
2895
|
+
>>> base = Polygon([Point2d(0.0, 0.0), Point2d(1.0, 0.0), Point2d(1.0, 1.0), Point2d(0.0, 1.0)])
|
|
2896
|
+
>>> apex = Point(0.0, 0.0, 1.0)
|
|
2897
|
+
>>> pyramid = Pyramid(base, apex)
|
|
2898
|
+
>>> pyramid.get_base()
|
|
2899
|
+
"""
|
|
2900
|
+
def get_lateral_face_at(self, index: int) -> Polygon:
|
|
2901
|
+
"""
|
|
2902
|
+
Get the lateral face at a given index.
|
|
2903
|
+
|
|
2904
|
+
Args:
|
|
2905
|
+
index (int): The index of the lateral face.
|
|
2906
|
+
|
|
2907
|
+
Returns:
|
|
2908
|
+
Polygon: The lateral face polygon.
|
|
2909
|
+
|
|
2910
|
+
Example:
|
|
2911
|
+
>>> base = Polygon([Point2d(0.0, 0.0), Point2d(1.0, 0.0), Point2d(1.0, 1.0), Point2d(0.0, 1.0)])
|
|
2912
|
+
>>> apex = Point(0.0, 0.0, 1.0)
|
|
2913
|
+
>>> pyramid = Pyramid(base, apex)
|
|
2914
|
+
>>> pyramid.get_lateral_face_at(0)
|
|
2915
|
+
"""
|
|
616
2916
|
def get_lateral_face_count(self) -> int:
|
|
617
|
-
|
|
2917
|
+
"""
|
|
2918
|
+
Get the number of lateral faces.
|
|
2919
|
+
|
|
2920
|
+
Returns:
|
|
2921
|
+
int: The number of lateral faces.
|
|
2922
|
+
|
|
2923
|
+
Example:
|
|
2924
|
+
>>> base = Polygon([Point2d(0.0, 0.0), Point2d(1.0, 0.0), Point2d(1.0, 1.0), Point2d(0.0, 1.0)])
|
|
2925
|
+
>>> apex = Point(0.0, 0.0, 1.0)
|
|
2926
|
+
>>> pyramid = Pyramid(base, apex)
|
|
2927
|
+
>>> pyramid.get_lateral_face_count()
|
|
2928
|
+
"""
|
|
618
2929
|
def get_rays_of_lateral_face_at(self, lateral_face_index: int, ray_count: int = 2) -> list[Ray]:
|
|
619
|
-
|
|
2930
|
+
"""
|
|
2931
|
+
Get rays from the apex through a specific lateral face.
|
|
2932
|
+
|
|
2933
|
+
Args:
|
|
2934
|
+
lateral_face_index (int): The index of the lateral face.
|
|
2935
|
+
ray_count (int): The number of rays to generate (default: 2).
|
|
2936
|
+
|
|
2937
|
+
Returns:
|
|
2938
|
+
list[Ray]: Array of rays.
|
|
2939
|
+
|
|
2940
|
+
Example:
|
|
2941
|
+
>>> base = Polygon([Point2d(0.0, 0.0), Point2d(1.0, 0.0), Point2d(1.0, 1.0), Point2d(0.0, 1.0)])
|
|
2942
|
+
>>> apex = Point(0.0, 0.0, 1.0)
|
|
2943
|
+
>>> pyramid = Pyramid(base, apex)
|
|
2944
|
+
>>> pyramid.get_rays_of_lateral_face_at(0)
|
|
2945
|
+
"""
|
|
620
2946
|
def get_rays_of_lateral_faces(self, ray_count: int = 0) -> list[Ray]:
|
|
621
|
-
|
|
2947
|
+
"""
|
|
2948
|
+
Get rays from the apex through all lateral faces.
|
|
2949
|
+
|
|
2950
|
+
Args:
|
|
2951
|
+
ray_count (int, optional): The number of rays per face. Defaults to 0.
|
|
2952
|
+
|
|
2953
|
+
Returns:
|
|
2954
|
+
list[Ray]: Array of rays.
|
|
2955
|
+
|
|
2956
|
+
Example:
|
|
2957
|
+
>>> base = Polygon([Point2d(0.0, 0.0), Point2d(1.0, 0.0), Point2d(1.0, 1.0), Point2d(0.0, 1.0)])
|
|
2958
|
+
>>> apex = Point(0.0, 0.0, 1.0)
|
|
2959
|
+
>>> pyramid = Pyramid(base, apex)
|
|
2960
|
+
>>> pyramid.get_rays_of_lateral_faces(ray_count=1)
|
|
2961
|
+
"""
|
|
622
2962
|
@typing.overload
|
|
623
2963
|
def intersection_with(self, sphere: Sphere, only_in_sight: bool = False, discretization_level: int = 40) -> ...:
|
|
624
|
-
|
|
2964
|
+
"""
|
|
2965
|
+
Compute the intersection of the pyramid with a sphere.
|
|
2966
|
+
|
|
2967
|
+
Args:
|
|
2968
|
+
sphere (Sphere): The sphere to intersect with.
|
|
2969
|
+
only_in_sight (bool): Only compute intersection in sight of the apex.
|
|
2970
|
+
discretization_level (int): The level of discretization for the computation.
|
|
2971
|
+
|
|
2972
|
+
Returns:
|
|
2973
|
+
Intersection: The intersection result.
|
|
2974
|
+
|
|
2975
|
+
Example:
|
|
2976
|
+
>>> base = Polygon([Point2d(0.0, 0.0), Point2d(1.0, 0.0), Point2d(1.0, 1.0), Point2d(0.0, 1.0)])
|
|
2977
|
+
>>> apex = Point(0.0, 0.0, 1.0)
|
|
2978
|
+
>>> pyramid = Pyramid(base, apex)
|
|
2979
|
+
>>> pyramid.intersection_with(Sphere(Point(0.0, 0.0, 0.0), 1.0))
|
|
2980
|
+
"""
|
|
625
2981
|
@typing.overload
|
|
626
2982
|
def intersection_with(self, ellipsoid: Ellipsoid, only_in_sight: bool = False, discretization_level: int = 40) -> ...:
|
|
627
|
-
|
|
2983
|
+
"""
|
|
2984
|
+
Compute the intersection of the pyramid with an ellipsoid.
|
|
2985
|
+
|
|
2986
|
+
Args:
|
|
2987
|
+
ellipsoid (Ellipsoid): The ellipsoid to intersect with.
|
|
2988
|
+
only_in_sight (bool): Only compute intersection in sight of the apex.
|
|
2989
|
+
discretization_level (int): The level of discretization for the computation.
|
|
2990
|
+
|
|
2991
|
+
Returns:
|
|
2992
|
+
Intersection: The intersection result.
|
|
2993
|
+
|
|
2994
|
+
Example:
|
|
2995
|
+
>>> base = Polygon([Point2d(0.0, 0.0), Point2d(1.0, 0.0), Point2d(1.0, 1.0), Point2d(0.0, 1.0)])
|
|
2996
|
+
>>> apex = Point(0.0, 0.0, 1.0)
|
|
2997
|
+
>>> pyramid = Pyramid(base, apex)
|
|
2998
|
+
>>> pyramid.intersection_with(Ellipsoid(Point(0.0, 0.0, 0.0), 1.0, 1.0, 1.0))
|
|
2999
|
+
"""
|
|
628
3000
|
def intersects(self, ellipsoid: Ellipsoid, discretization_level: int = 40) -> bool:
|
|
629
|
-
|
|
3001
|
+
"""
|
|
3002
|
+
Check if the pyramid intersects an ellipsoid.
|
|
3003
|
+
|
|
3004
|
+
Args:
|
|
3005
|
+
ellipsoid (Ellipsoid): The ellipsoid to check intersection with.
|
|
3006
|
+
discretization_level (int): The level of discretization for the check.
|
|
3007
|
+
|
|
3008
|
+
Returns:
|
|
3009
|
+
bool: True if the pyramid intersects the ellipsoid.
|
|
3010
|
+
"""
|
|
630
3011
|
def is_defined(self) -> bool:
|
|
631
|
-
|
|
3012
|
+
"""
|
|
3013
|
+
Check if the pyramid is defined.
|
|
3014
|
+
|
|
3015
|
+
Returns:
|
|
3016
|
+
bool: True if the pyramid is defined.
|
|
3017
|
+
|
|
3018
|
+
Example:
|
|
3019
|
+
>>> base = Polygon([Point2d(0.0, 0.0), Point2d(1.0, 0.0), Point2d(1.0, 1.0), Point2d(0.0, 1.0)])
|
|
3020
|
+
>>> apex = Point(0.0, 0.0, 1.0)
|
|
3021
|
+
>>> pyramid = Pyramid(base, apex)
|
|
3022
|
+
>>> pyramid.is_defined()
|
|
3023
|
+
"""
|
|
632
3024
|
class Ray(ostk.mathematics.geometry.d3.Object):
|
|
633
3025
|
__hash__: typing.ClassVar[None] = None
|
|
634
3026
|
@staticmethod
|
|
635
3027
|
def undefined() -> Ray:
|
|
636
|
-
|
|
3028
|
+
"""
|
|
3029
|
+
Create an undefined ray.
|
|
3030
|
+
|
|
3031
|
+
Returns:
|
|
3032
|
+
Ray: An undefined ray object.
|
|
3033
|
+
|
|
3034
|
+
Example:
|
|
3035
|
+
>>> undefined_ray = Ray.undefined()
|
|
3036
|
+
>>> undefined_ray.is_defined() # False
|
|
3037
|
+
"""
|
|
637
3038
|
def __eq__(self, arg0: Ray) -> bool:
|
|
638
3039
|
...
|
|
639
3040
|
def __init__(self, origin: Point, direction: numpy.ndarray[numpy.float64[3, 1]]) -> None:
|
|
640
|
-
|
|
3041
|
+
"""
|
|
3042
|
+
Create a 3D ray with specified origin and direction.
|
|
3043
|
+
|
|
3044
|
+
Args:
|
|
3045
|
+
origin (Point): The origin point of the ray.
|
|
3046
|
+
direction (np.array): The direction vector of the ray.
|
|
3047
|
+
|
|
3048
|
+
Example:
|
|
3049
|
+
>>> origin = Point(0.0, 0.0, 0.0)
|
|
3050
|
+
>>> direction = np.array([1.0, 0.0, 0.0])
|
|
3051
|
+
>>> ray = Ray(origin, direction)
|
|
3052
|
+
"""
|
|
641
3053
|
def __ne__(self, arg0: Ray) -> bool:
|
|
642
3054
|
...
|
|
643
3055
|
def __repr__(self) -> str:
|
|
@@ -645,28 +3057,132 @@ class Ray(ostk.mathematics.geometry.d3.Object):
|
|
|
645
3057
|
def __str__(self) -> str:
|
|
646
3058
|
...
|
|
647
3059
|
def apply_transformation(self, transformation: typing.Any) -> None:
|
|
648
|
-
|
|
3060
|
+
"""
|
|
3061
|
+
Apply a transformation to the ray.
|
|
3062
|
+
|
|
3063
|
+
Args:
|
|
3064
|
+
transformation (Transformation): The transformation to apply.
|
|
3065
|
+
|
|
3066
|
+
Example:
|
|
3067
|
+
>>> ray = Ray(Point(0.0, 0.0, 0.0), np.array([1.0, 0.0, 0.0]))
|
|
3068
|
+
>>> transformation = Transformation.translation([1.0, 0.0])
|
|
3069
|
+
>>> ray.apply_transformation(transformation)
|
|
3070
|
+
"""
|
|
649
3071
|
@typing.overload
|
|
650
3072
|
def contains(self, point: Point) -> bool:
|
|
651
|
-
|
|
3073
|
+
"""
|
|
3074
|
+
Check if the ray contains a point.
|
|
3075
|
+
|
|
3076
|
+
Args:
|
|
3077
|
+
point (Point): The point to check.
|
|
3078
|
+
|
|
3079
|
+
Returns:
|
|
3080
|
+
bool: True if the ray contains the point, False otherwise.
|
|
3081
|
+
|
|
3082
|
+
Example:
|
|
3083
|
+
>>> ray = Ray(Point(0.0, 0.0, 0.0), np.array([1.0, 0.0, 0.0]))
|
|
3084
|
+
>>> ray.contains(Point(2.0, 0.0, 0.0)) # True (point on ray)
|
|
3085
|
+
"""
|
|
652
3086
|
@typing.overload
|
|
653
3087
|
def contains(self, point_set: PointSet) -> bool:
|
|
654
|
-
|
|
3088
|
+
"""
|
|
3089
|
+
Check if the ray contains a point set.
|
|
3090
|
+
|
|
3091
|
+
Args:
|
|
3092
|
+
point_set (PointSet): The point set to check.
|
|
3093
|
+
|
|
3094
|
+
Returns:
|
|
3095
|
+
bool: True if the ray contains the point set, False otherwise.
|
|
3096
|
+
"""
|
|
655
3097
|
def distance_to(self, point: Point) -> ostk.core.type.Real:
|
|
656
|
-
|
|
3098
|
+
"""
|
|
3099
|
+
Calculate the distance from the ray to a point.
|
|
3100
|
+
|
|
3101
|
+
Args:
|
|
3102
|
+
point (Point): The point to calculate distance to.
|
|
3103
|
+
|
|
3104
|
+
Returns:
|
|
3105
|
+
float: The minimum distance from the ray to the point.
|
|
3106
|
+
|
|
3107
|
+
Example:
|
|
3108
|
+
>>> ray = Ray(Point(0.0, 0.0, 0.0), np.array([1.0, 0.0, 0.0]))
|
|
3109
|
+
>>> distance = ray.distance_to(Point(1.0, 1.0, 0.0)) # 1.0
|
|
3110
|
+
"""
|
|
657
3111
|
def get_direction(self) -> numpy.ndarray[numpy.float64[3, 1]]:
|
|
658
|
-
|
|
3112
|
+
"""
|
|
3113
|
+
Get the direction vector of the ray.
|
|
3114
|
+
|
|
3115
|
+
Returns:
|
|
3116
|
+
Vector3d: The normalized direction vector of the ray.
|
|
3117
|
+
|
|
3118
|
+
Example:
|
|
3119
|
+
>>> ray = Ray(Point(0.0, 0.0, 0.0), np.array([1.0, 0.0, 0.0]))
|
|
3120
|
+
>>> direction = ray.get_direction() # [1.0, 0.0, 0.0]
|
|
3121
|
+
"""
|
|
659
3122
|
def get_origin(self) -> Point:
|
|
660
|
-
|
|
3123
|
+
"""
|
|
3124
|
+
Get the origin point of the ray.
|
|
3125
|
+
|
|
3126
|
+
Returns:
|
|
3127
|
+
Point: The origin point of the ray.
|
|
3128
|
+
|
|
3129
|
+
Example:
|
|
3130
|
+
>>> ray = Ray(Point(1.0, 2.0, 3.0), np.array([1.0, 0.0, 0.0]))
|
|
3131
|
+
>>> origin = ray.get_origin() # Point(1.0, 2.0, 3.0)
|
|
3132
|
+
"""
|
|
661
3133
|
@typing.overload
|
|
662
3134
|
def intersection_with(self, plane: typing.Any) -> ...:
|
|
663
|
-
|
|
3135
|
+
"""
|
|
3136
|
+
Compute the intersection of the ray with a plane.
|
|
3137
|
+
|
|
3138
|
+
Args:
|
|
3139
|
+
plane (Plane): The plane to intersect with.
|
|
3140
|
+
|
|
3141
|
+
Returns:
|
|
3142
|
+
Intersection: The intersection of the ray with the plane.
|
|
3143
|
+
|
|
3144
|
+
Example:
|
|
3145
|
+
>>> ray = Ray(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, -1.0]))
|
|
3146
|
+
>>> plane = Plane(Point(0.0, 0.0, 0.0), np.array([0.0, 0.0, 1.0]))
|
|
3147
|
+
>>> intersection = ray.intersection_with(plane)
|
|
3148
|
+
>>> intersection.get_point() # Point(0.0, 0.0, 0.0)
|
|
3149
|
+
"""
|
|
664
3150
|
@typing.overload
|
|
665
3151
|
def intersection_with(self, sphere: typing.Any, only_in_sight: bool = False) -> ...:
|
|
666
|
-
|
|
3152
|
+
"""
|
|
3153
|
+
Compute the intersection of the ray with a sphere.
|
|
3154
|
+
|
|
3155
|
+
Args:
|
|
3156
|
+
sphere (Sphere): The sphere to intersect with.
|
|
3157
|
+
only_in_sight (bool, optional): If true, only return intersection points that are in sight. Defaults to True.
|
|
3158
|
+
|
|
3159
|
+
Returns:
|
|
3160
|
+
Intersection: The intersection of the ray with the sphere.
|
|
3161
|
+
|
|
3162
|
+
Example:
|
|
3163
|
+
>>> ray = Ray(Point(0.0, 0.0, 0.0), np.array([1.0, 0.0, 0.0]))
|
|
3164
|
+
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0)
|
|
3165
|
+
>>> intersection = ray.intersection_with(sphere)
|
|
3166
|
+
>>> intersection.get_point() # Point(0.0, 0.0, 0.0)
|
|
3167
|
+
"""
|
|
667
3168
|
@typing.overload
|
|
668
3169
|
def intersection_with(self, ellipsoid: typing.Any, only_in_sight: bool = False) -> ...:
|
|
669
|
-
|
|
3170
|
+
"""
|
|
3171
|
+
Compute the intersection of the ray with an ellipsoid.
|
|
3172
|
+
|
|
3173
|
+
Args:
|
|
3174
|
+
ellipsoid (Ellipsoid): The ellipsoid to intersect with.
|
|
3175
|
+
only_in_sight (bool, optional): If true, only return intersection points that are in sight. Defaults to True.
|
|
3176
|
+
|
|
3177
|
+
Returns:
|
|
3178
|
+
Intersection: The intersection of the ray with the ellipsoid.
|
|
3179
|
+
|
|
3180
|
+
Example:
|
|
3181
|
+
>>> ray = Ray(Point(0.0, 0.0, 0.0), np.array([1.0, 0.0, 0.0]))
|
|
3182
|
+
>>> ellipsoid = Ellipsoid(Point(0.0, 0.0, 0.0), 1.0, 1.0, 1.0)
|
|
3183
|
+
>>> intersection = ray.intersection_with(ellipsoid)
|
|
3184
|
+
>>> intersection.get_point() # Point(0.0, 0.0, 0.0)
|
|
3185
|
+
"""
|
|
670
3186
|
@typing.overload
|
|
671
3187
|
def intersects(self, point: Point) -> bool:
|
|
672
3188
|
...
|
|
@@ -680,16 +3196,45 @@ class Ray(ostk.mathematics.geometry.d3.Object):
|
|
|
680
3196
|
def intersects(self, ellipsoid: typing.Any) -> bool:
|
|
681
3197
|
...
|
|
682
3198
|
def is_defined(self) -> bool:
|
|
683
|
-
|
|
3199
|
+
"""
|
|
3200
|
+
Check if the ray is defined.
|
|
3201
|
+
|
|
3202
|
+
Returns:
|
|
3203
|
+
bool: True if the ray is defined, False otherwise.
|
|
3204
|
+
|
|
3205
|
+
Example:
|
|
3206
|
+
>>> ray = Ray(Point(0.0, 0.0, 0.0), np.array([1.0, 0.0, 0.0]))
|
|
3207
|
+
>>> ray.is_defined() # True
|
|
3208
|
+
"""
|
|
684
3209
|
class Segment(ostk.mathematics.geometry.d3.Object):
|
|
685
3210
|
__hash__: typing.ClassVar[None] = None
|
|
686
3211
|
@staticmethod
|
|
687
3212
|
def undefined() -> Segment:
|
|
688
|
-
|
|
3213
|
+
"""
|
|
3214
|
+
Create an undefined segment.
|
|
3215
|
+
|
|
3216
|
+
Returns:
|
|
3217
|
+
Segment: An undefined segment object.
|
|
3218
|
+
|
|
3219
|
+
Example:
|
|
3220
|
+
>>> undefined_segment = Segment.undefined()
|
|
3221
|
+
>>> undefined_segment.is_defined() # False
|
|
3222
|
+
"""
|
|
689
3223
|
def __eq__(self, arg0: Segment) -> bool:
|
|
690
3224
|
...
|
|
691
3225
|
def __init__(self, first_point: Point, second_point: Point) -> None:
|
|
692
|
-
|
|
3226
|
+
"""
|
|
3227
|
+
Create a 3D segment between two points.
|
|
3228
|
+
|
|
3229
|
+
Args:
|
|
3230
|
+
first_point (Point): The first endpoint of the segment.
|
|
3231
|
+
second_point (Point): The second endpoint of the segment.
|
|
3232
|
+
|
|
3233
|
+
Example:
|
|
3234
|
+
>>> point1 = Point(0.0, 0.0, 0.0)
|
|
3235
|
+
>>> point2 = Point(1.0, 1.0, 1.0)
|
|
3236
|
+
>>> segment = Segment(point1, point2)
|
|
3237
|
+
"""
|
|
693
3238
|
def __ne__(self, arg0: Segment) -> bool:
|
|
694
3239
|
...
|
|
695
3240
|
def __repr__(self) -> str:
|
|
@@ -697,54 +3242,256 @@ class Segment(ostk.mathematics.geometry.d3.Object):
|
|
|
697
3242
|
def __str__(self) -> str:
|
|
698
3243
|
...
|
|
699
3244
|
def apply_transformation(self, transformation: typing.Any) -> None:
|
|
700
|
-
|
|
3245
|
+
"""
|
|
3246
|
+
Apply a transformation to the segment in place.
|
|
3247
|
+
|
|
3248
|
+
Args:
|
|
3249
|
+
transformation (Transformation): The transformation to apply.
|
|
3250
|
+
|
|
3251
|
+
Example:
|
|
3252
|
+
>>> segment = Segment(Point(0.0, 0.0, 0.0), Point(1.0, 1.0, 1.0))
|
|
3253
|
+
>>> transformation = Translation([1.0, 1.0, 1.0])
|
|
3254
|
+
>>> segment.apply_transformation(transformation)
|
|
3255
|
+
"""
|
|
701
3256
|
def contains(self, point: Point) -> bool:
|
|
702
|
-
|
|
3257
|
+
"""
|
|
3258
|
+
Check if the segment contains a point.
|
|
3259
|
+
|
|
3260
|
+
Args:
|
|
3261
|
+
point (Point): The point to check.
|
|
3262
|
+
|
|
3263
|
+
Returns:
|
|
3264
|
+
bool: True if the segment contains the point, False otherwise.
|
|
3265
|
+
|
|
3266
|
+
Example:
|
|
3267
|
+
>>> segment = Segment(Point(0.0, 0.0, 0.0), Point(2.0, 0.0, 0.0))
|
|
3268
|
+
>>> segment.contains(Point(1.0, 0.0, 0.0)) # True (midpoint)
|
|
3269
|
+
"""
|
|
703
3270
|
@typing.overload
|
|
704
3271
|
def distance_to(self, point: Point) -> ostk.core.type.Real:
|
|
705
|
-
|
|
3272
|
+
"""
|
|
3273
|
+
Calculate the distance from the segment to a point.
|
|
3274
|
+
|
|
3275
|
+
Args:
|
|
3276
|
+
point (Point): The point to calculate distance to.
|
|
3277
|
+
|
|
3278
|
+
Returns:
|
|
3279
|
+
float: The distance from the segment to the point.
|
|
3280
|
+
|
|
3281
|
+
Example:
|
|
3282
|
+
>>> segment = Segment(Point(0.0, 0.0, 0.0), Point(2.0, 0.0, 0.0))
|
|
3283
|
+
>>> distance = segment.distance_to(Point(1.0, 0.0, 0.0)) # 1.0
|
|
3284
|
+
"""
|
|
706
3285
|
@typing.overload
|
|
707
3286
|
def distance_to(self, point_set: PointSet) -> ostk.core.type.Real:
|
|
708
|
-
|
|
3287
|
+
"""
|
|
3288
|
+
Calculate the distance from the segment to a point set.
|
|
3289
|
+
|
|
3290
|
+
Args:
|
|
3291
|
+
point_set (PointSet): The point set to calculate distance to.
|
|
3292
|
+
|
|
3293
|
+
Returns:
|
|
3294
|
+
float: The distance from the segment to the point set.
|
|
3295
|
+
|
|
3296
|
+
Example:
|
|
3297
|
+
>>> segment = Segment(Point(0.0, 0.0, 0.0), Point(2.0, 0.0, 0.0))
|
|
3298
|
+
>>> points = PointSet([Point(1.0, 0.0, 0.0), Point(3.0, 0.0, 0.0)])
|
|
3299
|
+
>>> distance = segment.distance_to(points) # 1.0
|
|
3300
|
+
"""
|
|
709
3301
|
def get_center(self) -> Point:
|
|
710
|
-
|
|
3302
|
+
"""
|
|
3303
|
+
Get the center point of the segment.
|
|
3304
|
+
|
|
3305
|
+
Returns:
|
|
3306
|
+
Point: The midpoint of the segment.
|
|
3307
|
+
|
|
3308
|
+
Example:
|
|
3309
|
+
>>> segment = Segment(Point(0.0, 0.0, 0.0), Point(2.0, 2.0, 2.0))
|
|
3310
|
+
>>> center = segment.get_center() # Point(1.0, 1.0, 1.0)
|
|
3311
|
+
"""
|
|
711
3312
|
def get_direction(self) -> numpy.ndarray[numpy.float64[3, 1]]:
|
|
712
|
-
|
|
3313
|
+
"""
|
|
3314
|
+
Get the direction vector of the segment.
|
|
3315
|
+
|
|
3316
|
+
Returns:
|
|
3317
|
+
Vector3d: The normalized direction vector from first to second point.
|
|
3318
|
+
|
|
3319
|
+
Example:
|
|
3320
|
+
>>> segment = Segment(Point(0.0, 0.0, 0.0), Point(1.0, 0.0, 0.0))
|
|
3321
|
+
>>> direction = segment.get_direction() # [1.0, 0.0, 0.0]
|
|
3322
|
+
"""
|
|
713
3323
|
def get_first_point(self) -> Point:
|
|
714
|
-
|
|
3324
|
+
"""
|
|
3325
|
+
Get the first endpoint of the segment.
|
|
3326
|
+
|
|
3327
|
+
Returns:
|
|
3328
|
+
Point: The first endpoint of the segment.
|
|
3329
|
+
|
|
3330
|
+
Example:
|
|
3331
|
+
>>> segment = Segment(Point(1.0, 2.0, 3.0), Point(4.0, 5.0, 6.0))
|
|
3332
|
+
>>> first_point = segment.get_first_point() # Point(1.0, 2.0, 3.0)
|
|
3333
|
+
"""
|
|
715
3334
|
def get_length(self) -> ostk.core.type.Real:
|
|
716
|
-
|
|
3335
|
+
"""
|
|
3336
|
+
Get the length of the segment.
|
|
3337
|
+
|
|
3338
|
+
Returns:
|
|
3339
|
+
float: The distance between the two endpoints.
|
|
3340
|
+
|
|
3341
|
+
Example:
|
|
3342
|
+
>>> segment = Segment(Point(0.0, 0.0, 0.0), Point(3.0, 4.0, 0.0))
|
|
3343
|
+
>>> length = segment.get_length() # 5.0
|
|
3344
|
+
"""
|
|
717
3345
|
def get_second_point(self) -> Point:
|
|
718
|
-
|
|
3346
|
+
"""
|
|
3347
|
+
Get the second endpoint of the segment.
|
|
3348
|
+
|
|
3349
|
+
Returns:
|
|
3350
|
+
Point: The second endpoint of the segment.
|
|
3351
|
+
|
|
3352
|
+
Example:
|
|
3353
|
+
>>> segment = Segment(Point(1.0, 2.0, 3.0), Point(4.0, 5.0, 6.0))
|
|
3354
|
+
>>> second_point = segment.get_second_point() # Point(4.0, 5.0, 6.0)
|
|
3355
|
+
"""
|
|
719
3356
|
def intersection_with(self, plane: typing.Any) -> ...:
|
|
720
|
-
|
|
3357
|
+
"""
|
|
3358
|
+
Calculate the intersection of the segment with a plane.
|
|
3359
|
+
|
|
3360
|
+
Args:
|
|
3361
|
+
plane (Plane): The plane to calculate intersection with.
|
|
3362
|
+
|
|
3363
|
+
Returns:
|
|
3364
|
+
Intersection: The intersection of the segment with the plane.
|
|
3365
|
+
|
|
3366
|
+
Example:
|
|
3367
|
+
>>> segment = Segment(Point(0.0, 0.0, 0.0), Point(2.0, 0.0, 0.0))
|
|
3368
|
+
>>> plane = Plane(Point(1.0, 0.0, 0.0), Vector3d(0.0, 0.0, 1.0))
|
|
3369
|
+
>>> intersection = segment.intersection_with(plane)
|
|
3370
|
+
>>> intersection.get_point() # Point(1.0, 0.0, 0.0)
|
|
3371
|
+
"""
|
|
721
3372
|
@typing.overload
|
|
722
3373
|
def intersects(self, plane: typing.Any) -> bool:
|
|
723
|
-
|
|
3374
|
+
"""
|
|
3375
|
+
Check if the segment intersects a plane.
|
|
3376
|
+
|
|
3377
|
+
Args:
|
|
3378
|
+
plane (Plane): The plane to check intersection with.
|
|
3379
|
+
|
|
3380
|
+
Returns:
|
|
3381
|
+
bool: True if the segment intersects the plane.
|
|
3382
|
+
|
|
3383
|
+
Example:
|
|
3384
|
+
>>> segment = Segment(Point(0.0, 0.0, 0.0), Point(2.0, 0.0, 0.0))
|
|
3385
|
+
>>> segment.intersects(Plane(Point(1.0, 0.0, 0.0), Vector3d(0.0, 0.0, 1.0))) # True
|
|
3386
|
+
"""
|
|
724
3387
|
@typing.overload
|
|
725
3388
|
def intersects(self, sphere: typing.Any) -> bool:
|
|
726
|
-
|
|
3389
|
+
"""
|
|
3390
|
+
Check if the segment intersects a sphere.
|
|
3391
|
+
|
|
3392
|
+
Args:
|
|
3393
|
+
sphere (Sphere): The sphere to check intersection with.
|
|
3394
|
+
|
|
3395
|
+
Returns:
|
|
3396
|
+
bool: True if the segment intersects the sphere.
|
|
3397
|
+
|
|
3398
|
+
Example:
|
|
3399
|
+
>>> segment = Segment(Point(0.0, 0.0, 0.0), Point(2.0, 0.0, 0.0))
|
|
3400
|
+
>>> segment.intersects(Sphere(Point(1.0, 0.0, 0.0), 1.0)) # True
|
|
3401
|
+
"""
|
|
727
3402
|
@typing.overload
|
|
728
3403
|
def intersects(self, ellipsoid: typing.Any) -> bool:
|
|
729
|
-
|
|
3404
|
+
"""
|
|
3405
|
+
Check if the segment intersects an ellipsoid.
|
|
3406
|
+
|
|
3407
|
+
Args:
|
|
3408
|
+
ellipsoid (Ellipsoid): The ellipsoid to check intersection with.
|
|
3409
|
+
|
|
3410
|
+
Returns:
|
|
3411
|
+
bool: True if the segment intersects the ellipsoid.
|
|
3412
|
+
|
|
3413
|
+
Example:
|
|
3414
|
+
>>> segment = Segment(Point(0.0, 0.0, 0.0), Point(2.0, 0.0, 0.0))
|
|
3415
|
+
>>> segment.intersects(Ellipsoid(Point(1.0, 0.0, 0.0), 1.0, 1.0, 1.0)) # True
|
|
3416
|
+
"""
|
|
730
3417
|
def is_defined(self) -> bool:
|
|
731
|
-
|
|
3418
|
+
"""
|
|
3419
|
+
Check if the segment is defined.
|
|
3420
|
+
|
|
3421
|
+
Returns:
|
|
3422
|
+
bool: True if the segment is defined, False otherwise.
|
|
3423
|
+
|
|
3424
|
+
Example:
|
|
3425
|
+
>>> segment = Segment(Point(0.0, 0.0, 0.0), Point(1.0, 1.0, 1.0))
|
|
3426
|
+
>>> segment.is_defined() # True
|
|
3427
|
+
"""
|
|
732
3428
|
def is_degenerate(self) -> bool:
|
|
733
|
-
|
|
3429
|
+
"""
|
|
3430
|
+
Check if the segment is degenerate (both endpoints are the same).
|
|
3431
|
+
|
|
3432
|
+
Returns:
|
|
3433
|
+
bool: True if the segment is degenerate, False otherwise.
|
|
3434
|
+
|
|
3435
|
+
Example:
|
|
3436
|
+
>>> point = Point(0.0, 0.0, 0.0)
|
|
3437
|
+
>>> degenerate_segment = Segment(point, point)
|
|
3438
|
+
>>> degenerate_segment.is_degenerate() # True
|
|
3439
|
+
"""
|
|
734
3440
|
def to_line(self) -> Line:
|
|
735
|
-
|
|
3441
|
+
"""
|
|
3442
|
+
Convert the segment to a line.
|
|
3443
|
+
|
|
3444
|
+
Returns:
|
|
3445
|
+
Line: A line passing through the segment's endpoints.
|
|
3446
|
+
|
|
3447
|
+
Example:
|
|
3448
|
+
>>> segment = Segment(Point(0.0, 0.0, 0.0), Point(1.0, 1.0, 1.0))
|
|
3449
|
+
>>> line = segment.to_line()
|
|
3450
|
+
"""
|
|
736
3451
|
class Sphere(ostk.mathematics.geometry.d3.Object):
|
|
737
3452
|
__hash__: typing.ClassVar[None] = None
|
|
738
3453
|
@staticmethod
|
|
739
3454
|
def undefined() -> Sphere:
|
|
740
|
-
|
|
3455
|
+
"""
|
|
3456
|
+
Create an undefined sphere.
|
|
3457
|
+
|
|
3458
|
+
Returns:
|
|
3459
|
+
Sphere: An undefined sphere.
|
|
3460
|
+
|
|
3461
|
+
Example:
|
|
3462
|
+
>>> undefined_sphere = Sphere.undefined()
|
|
3463
|
+
>>> undefined_sphere.is_defined() # False
|
|
3464
|
+
"""
|
|
741
3465
|
@staticmethod
|
|
742
3466
|
def unit(center: Point) -> Sphere:
|
|
743
|
-
|
|
3467
|
+
"""
|
|
3468
|
+
Create a unit sphere (radius = 1) at a given center.
|
|
3469
|
+
|
|
3470
|
+
Args:
|
|
3471
|
+
center (Point): The center point of the unit sphere.
|
|
3472
|
+
|
|
3473
|
+
Returns:
|
|
3474
|
+
Sphere: A unit sphere centered at the given point.
|
|
3475
|
+
|
|
3476
|
+
Example:
|
|
3477
|
+
>>> center = Point(1.0, 2.0, 3.0)
|
|
3478
|
+
>>> unit_sphere = Sphere.unit(center)
|
|
3479
|
+
>>> unit_sphere.get_radius() # 1.0
|
|
3480
|
+
"""
|
|
744
3481
|
def __eq__(self, arg0: Sphere) -> bool:
|
|
745
3482
|
...
|
|
746
3483
|
def __init__(self, center: Point, radius: ostk.core.type.Real) -> None:
|
|
747
|
-
|
|
3484
|
+
"""
|
|
3485
|
+
Create a 3D sphere with center and radius.
|
|
3486
|
+
|
|
3487
|
+
Args:
|
|
3488
|
+
center (Point): The center point of the sphere.
|
|
3489
|
+
radius (float): The radius of the sphere.
|
|
3490
|
+
|
|
3491
|
+
Example:
|
|
3492
|
+
>>> center = Point(0.0, 0.0, 0.0)
|
|
3493
|
+
>>> sphere = Sphere(center, 1.0)
|
|
3494
|
+
"""
|
|
748
3495
|
def __ne__(self, arg0: Sphere) -> bool:
|
|
749
3496
|
...
|
|
750
3497
|
def __repr__(self) -> str:
|
|
@@ -752,44 +3499,211 @@ class Sphere(ostk.mathematics.geometry.d3.Object):
|
|
|
752
3499
|
def __str__(self) -> str:
|
|
753
3500
|
...
|
|
754
3501
|
def apply_transformation(self, transformation: typing.Any) -> None:
|
|
755
|
-
|
|
3502
|
+
"""
|
|
3503
|
+
Apply a transformation to the sphere in place.
|
|
3504
|
+
|
|
3505
|
+
Args:
|
|
3506
|
+
transformation (Transformation): The transformation to apply.
|
|
3507
|
+
|
|
3508
|
+
Example:
|
|
3509
|
+
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0)
|
|
3510
|
+
>>> transformation = Translation([1.0, 0.0, 0.0])
|
|
3511
|
+
>>> sphere.apply_transformation(transformation)
|
|
3512
|
+
"""
|
|
756
3513
|
@typing.overload
|
|
757
3514
|
def contains(self, point: Point) -> bool:
|
|
758
|
-
|
|
3515
|
+
"""
|
|
3516
|
+
Check if the sphere contains a point.
|
|
3517
|
+
|
|
3518
|
+
Args:
|
|
3519
|
+
point (Point): The point to check.
|
|
3520
|
+
|
|
3521
|
+
Returns:
|
|
3522
|
+
bool: True if the sphere contains the point, False otherwise.
|
|
3523
|
+
|
|
3524
|
+
Example:
|
|
3525
|
+
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0)
|
|
3526
|
+
>>> sphere.contains(Point(0.5, 0.5, 0.5)) # True
|
|
3527
|
+
"""
|
|
759
3528
|
@typing.overload
|
|
760
3529
|
def contains(self, point_set: PointSet) -> bool:
|
|
761
|
-
|
|
3530
|
+
"""
|
|
3531
|
+
Check if the sphere contains a point set.
|
|
3532
|
+
|
|
3533
|
+
Args:
|
|
3534
|
+
point_set (PointSet): The point set to check.
|
|
3535
|
+
|
|
3536
|
+
Returns:
|
|
3537
|
+
bool: True if the sphere contains the point set, False otherwise.
|
|
3538
|
+
|
|
3539
|
+
Example:
|
|
3540
|
+
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0)
|
|
3541
|
+
>>> sphere.contains(PointSet([Point(0.5, 0.5, 0.5), Point(1.0, 1.0, 1.0)])) # True
|
|
3542
|
+
"""
|
|
762
3543
|
def get_center(self) -> Point:
|
|
763
|
-
|
|
3544
|
+
"""
|
|
3545
|
+
Get the center point of the sphere.
|
|
3546
|
+
|
|
3547
|
+
Returns:
|
|
3548
|
+
Point: The center point of the sphere.
|
|
3549
|
+
|
|
3550
|
+
Example:
|
|
3551
|
+
>>> sphere = Sphere(Point(1.0, 2.0, 3.0), 1.0)
|
|
3552
|
+
>>> center = sphere.get_center() # Point(1.0, 2.0, 3.0)
|
|
3553
|
+
"""
|
|
764
3554
|
def get_radius(self) -> ostk.core.type.Real:
|
|
765
|
-
|
|
3555
|
+
"""
|
|
3556
|
+
Get the radius of the sphere.
|
|
3557
|
+
|
|
3558
|
+
Returns:
|
|
3559
|
+
float: The radius of the sphere.
|
|
3560
|
+
|
|
3561
|
+
Example:
|
|
3562
|
+
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 2.5)
|
|
3563
|
+
>>> radius = sphere.get_radius() # 2.5
|
|
3564
|
+
"""
|
|
766
3565
|
@typing.overload
|
|
767
3566
|
def intersection_with(self, line: Line) -> ...:
|
|
768
|
-
|
|
3567
|
+
"""
|
|
3568
|
+
Check if the sphere intersects a line.
|
|
3569
|
+
|
|
3570
|
+
Args:
|
|
3571
|
+
line (Line): The line to check intersection with.
|
|
3572
|
+
|
|
3573
|
+
Returns:
|
|
3574
|
+
bool: True if the sphere intersects the line.
|
|
3575
|
+
|
|
3576
|
+
Example:
|
|
3577
|
+
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0)
|
|
3578
|
+
>>> sphere.intersection_with(Line(Point(1.0, 0.0, 0.0), Point(0.0, 1.0, 0.0))) # True
|
|
3579
|
+
"""
|
|
769
3580
|
@typing.overload
|
|
770
3581
|
def intersection_with(self, ray: Ray, only_in_sight: bool = False) -> ...:
|
|
771
|
-
|
|
3582
|
+
"""
|
|
3583
|
+
Check if the sphere intersects a ray.
|
|
3584
|
+
|
|
3585
|
+
Args:
|
|
3586
|
+
ray (Ray): The ray to check intersection with.
|
|
3587
|
+
only_in_sight (bool, optional): If true, only return intersection points that are in sight. Defaults to False.
|
|
3588
|
+
|
|
3589
|
+
Returns:
|
|
3590
|
+
bool: True if the sphere intersects the ray.
|
|
3591
|
+
|
|
3592
|
+
Example:
|
|
3593
|
+
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0)
|
|
3594
|
+
>>> sphere.intersection_with(Ray(Point(1.0, 0.0, 0.0), Point(0.0, 1.0, 0.0))) # True
|
|
3595
|
+
"""
|
|
772
3596
|
@typing.overload
|
|
773
3597
|
def intersects(self, point: Point) -> bool:
|
|
774
|
-
|
|
3598
|
+
"""
|
|
3599
|
+
Check if the sphere intersects a point.
|
|
3600
|
+
|
|
3601
|
+
Args:
|
|
3602
|
+
point (Point): The point to check intersection with.
|
|
3603
|
+
|
|
3604
|
+
Returns:
|
|
3605
|
+
bool: True if the sphere intersects the point.
|
|
3606
|
+
|
|
3607
|
+
Example:
|
|
3608
|
+
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0)
|
|
3609
|
+
>>> sphere.intersects(Point(1.0, 0.0, 0.0)) # True
|
|
3610
|
+
"""
|
|
775
3611
|
@typing.overload
|
|
776
3612
|
def intersects(self, point_set: PointSet) -> bool:
|
|
777
|
-
|
|
3613
|
+
"""
|
|
3614
|
+
Check if the sphere intersects a point set.
|
|
3615
|
+
|
|
3616
|
+
Args:
|
|
3617
|
+
point_set (PointSet): The point set to check intersection with.
|
|
3618
|
+
|
|
3619
|
+
Returns:
|
|
3620
|
+
bool: True if the sphere intersects the point set.
|
|
3621
|
+
|
|
3622
|
+
Example:
|
|
3623
|
+
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0)
|
|
3624
|
+
>>> sphere.intersects(PointSet([Point(1.0, 0.0, 0.0), Point(0.0, 1.0, 0.0)])) # True
|
|
3625
|
+
"""
|
|
778
3626
|
@typing.overload
|
|
779
3627
|
def intersects(self, line: Line) -> bool:
|
|
780
|
-
|
|
3628
|
+
"""
|
|
3629
|
+
Check if the sphere intersects a line.
|
|
3630
|
+
|
|
3631
|
+
Args:
|
|
3632
|
+
line (Line): The line to check intersection with.
|
|
3633
|
+
|
|
3634
|
+
Returns:
|
|
3635
|
+
bool: True if the sphere intersects the line.
|
|
3636
|
+
|
|
3637
|
+
Example:
|
|
3638
|
+
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0)
|
|
3639
|
+
>>> sphere.intersects(Line(Point(1.0, 0.0, 0.0), Point(0.0, 1.0, 0.0))) # True
|
|
3640
|
+
"""
|
|
781
3641
|
@typing.overload
|
|
782
3642
|
def intersects(self, ray: Ray) -> bool:
|
|
783
|
-
|
|
3643
|
+
"""
|
|
3644
|
+
Check if the sphere intersects a ray.
|
|
3645
|
+
|
|
3646
|
+
Args:
|
|
3647
|
+
ray (Ray): The ray to check intersection with.
|
|
3648
|
+
|
|
3649
|
+
Returns:
|
|
3650
|
+
bool: True if the sphere intersects the ray.
|
|
3651
|
+
|
|
3652
|
+
Example:
|
|
3653
|
+
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0)
|
|
3654
|
+
>>> sphere.intersects(Ray(Point(1.0, 0.0, 0.0), Point(0.0, 1.0, 0.0))) # True
|
|
3655
|
+
"""
|
|
784
3656
|
@typing.overload
|
|
785
3657
|
def intersects(self, segment: Segment) -> bool:
|
|
786
|
-
|
|
3658
|
+
"""
|
|
3659
|
+
Check if the sphere intersects a segment.
|
|
3660
|
+
|
|
3661
|
+
Args:
|
|
3662
|
+
segment (Segment): The segment to check intersection with.
|
|
3663
|
+
|
|
3664
|
+
Returns:
|
|
3665
|
+
bool: True if the sphere intersects the segment.
|
|
3666
|
+
|
|
3667
|
+
Example:
|
|
3668
|
+
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0)
|
|
3669
|
+
>>> sphere.intersects(Segment(Point(1.0, 0.0, 0.0), Point(0.0, 1.0, 0.0))) # True
|
|
3670
|
+
"""
|
|
787
3671
|
@typing.overload
|
|
788
3672
|
def intersects(self, plane: Plane) -> bool:
|
|
789
|
-
|
|
3673
|
+
"""
|
|
3674
|
+
Check if the sphere intersects a plane.
|
|
3675
|
+
|
|
3676
|
+
Args:
|
|
3677
|
+
plane (Plane): The plane to check intersection with.
|
|
3678
|
+
|
|
3679
|
+
Returns:
|
|
3680
|
+
bool: True if the sphere intersects the plane.
|
|
3681
|
+
|
|
3682
|
+
Example:
|
|
3683
|
+
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0)
|
|
3684
|
+
>>> sphere.intersects(Plane(Point(1.0, 0.0, 0.0), Vector3d(0.0, 0.0, 1.0))) # True
|
|
3685
|
+
"""
|
|
790
3686
|
def is_defined(self) -> bool:
|
|
791
|
-
|
|
3687
|
+
"""
|
|
3688
|
+
Check if the sphere is defined.
|
|
3689
|
+
|
|
3690
|
+
Returns:
|
|
3691
|
+
bool: True if the sphere is defined, False otherwise.
|
|
3692
|
+
|
|
3693
|
+
Example:
|
|
3694
|
+
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0)
|
|
3695
|
+
>>> sphere.is_defined() # True
|
|
3696
|
+
"""
|
|
792
3697
|
def is_unitary(self) -> bool:
|
|
793
|
-
|
|
3698
|
+
"""
|
|
3699
|
+
Check if the sphere is a unit sphere (radius = 1).
|
|
3700
|
+
|
|
3701
|
+
Returns:
|
|
3702
|
+
bool: True if the sphere has unit radius, False otherwise.
|
|
3703
|
+
|
|
3704
|
+
Example:
|
|
3705
|
+
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0)
|
|
3706
|
+
>>> sphere.is_unitary() # True
|
|
3707
|
+
"""
|
|
794
3708
|
def set_point_3_array(arg0: list[Point]) -> None:
|
|
795
3709
|
...
|