open-space-toolkit-mathematics 4.6.0__py39-none-manylinux2014_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- open_space_toolkit_mathematics-4.6.0.dist-info/METADATA +28 -0
- open_space_toolkit_mathematics-4.6.0.dist-info/RECORD +68 -0
- open_space_toolkit_mathematics-4.6.0.dist-info/WHEEL +5 -0
- open_space_toolkit_mathematics-4.6.0.dist-info/top_level.txt +1 -0
- open_space_toolkit_mathematics-4.6.0.dist-info/zip-safe +1 -0
- ostk/__init__.py +1 -0
- ostk/mathematics/OpenSpaceToolkitMathematicsPy.cpython-39-aarch64-linux-gnu.so +0 -0
- ostk/mathematics/__init__.py +5 -0
- ostk/mathematics/__init__.pyi +11 -0
- ostk/mathematics/curve_fitting/__init__.pyi +155 -0
- ostk/mathematics/curve_fitting/interpolator.pyi +243 -0
- ostk/mathematics/geometry/__init__.pyi +504 -0
- ostk/mathematics/geometry/d2/__init__.pyi +809 -0
- ostk/mathematics/geometry/d2/object.pyi +1779 -0
- ostk/mathematics/geometry/d3/__init__.pyi +1032 -0
- ostk/mathematics/geometry/d3/object.pyi +3709 -0
- ostk/mathematics/geometry/d3/transformation/__init__.pyi +3 -0
- ostk/mathematics/geometry/d3/transformation/rotation.pyi +1358 -0
- ostk/mathematics/libopen-space-toolkit-mathematics.so.4 +0 -0
- ostk/mathematics/object.pyi +387 -0
- ostk/mathematics/solver.pyi +342 -0
- ostk/mathematics/test/__init__.py +1 -0
- ostk/mathematics/test/curve_fitting/__init__.py +1 -0
- ostk/mathematics/test/curve_fitting/interpolator/__init__.py +1 -0
- ostk/mathematics/test/curve_fitting/interpolator/test_barycentric_rational.py +44 -0
- ostk/mathematics/test/curve_fitting/interpolator/test_cubic_spline.py +55 -0
- ostk/mathematics/test/curve_fitting/interpolator/test_interpolator.py +71 -0
- ostk/mathematics/test/curve_fitting/interpolator/test_linear.py +45 -0
- ostk/mathematics/test/geometry/__init__.py +1 -0
- ostk/mathematics/test/geometry/d2/__init__.py +1 -0
- ostk/mathematics/test/geometry/d2/conftest.py +79 -0
- ostk/mathematics/test/geometry/d2/object/__init__.py +1 -0
- ostk/mathematics/test/geometry/d2/object/test_composite.py +93 -0
- ostk/mathematics/test/geometry/d2/object/test_line.py +57 -0
- ostk/mathematics/test/geometry/d2/object/test_linestring.py +174 -0
- ostk/mathematics/test/geometry/d2/object/test_multipolygon.py +94 -0
- ostk/mathematics/test/geometry/d2/object/test_point.py +213 -0
- ostk/mathematics/test/geometry/d2/object/test_point_set.py +100 -0
- ostk/mathematics/test/geometry/d2/object/test_polygon.py +370 -0
- ostk/mathematics/test/geometry/d2/object/test_segment.py +104 -0
- ostk/mathematics/test/geometry/d2/test_object.py +25 -0
- ostk/mathematics/test/geometry/d2/test_transformation.py +84 -0
- ostk/mathematics/test/geometry/d3/__init__.py +1 -0
- ostk/mathematics/test/geometry/d3/object/__init__.py +1 -0
- ostk/mathematics/test/geometry/d3/object/test_composite.py +262 -0
- ostk/mathematics/test/geometry/d3/object/test_cuboid.py +20 -0
- ostk/mathematics/test/geometry/d3/object/test_line.py +68 -0
- ostk/mathematics/test/geometry/d3/object/test_linestring.py +168 -0
- ostk/mathematics/test/geometry/d3/object/test_point.py +234 -0
- ostk/mathematics/test/geometry/d3/object/test_point_set.py +113 -0
- ostk/mathematics/test/geometry/d3/object/test_polygon.py +141 -0
- ostk/mathematics/test/geometry/d3/object/test_segment.py +120 -0
- ostk/mathematics/test/geometry/d3/objects/test_cuboid.py +20 -0
- ostk/mathematics/test/geometry/d3/test_intersection.py +3 -0
- ostk/mathematics/test/geometry/d3/test_object.py +3 -0
- ostk/mathematics/test/geometry/d3/test_transformation.py +3 -0
- ostk/mathematics/test/geometry/d3/transformation/__init__.py +1 -0
- ostk/mathematics/test/geometry/d3/transformation/rotation/__init__.py +1 -0
- ostk/mathematics/test/geometry/d3/transformation/rotation/test_euler_angle.py +138 -0
- ostk/mathematics/test/geometry/d3/transformation/rotation/test_quaternion.py +189 -0
- ostk/mathematics/test/geometry/d3/transformation/rotation/test_rotation_matrix.py +40 -0
- ostk/mathematics/test/geometry/d3/transformation/rotation/test_rotation_vector.py +47 -0
- ostk/mathematics/test/geometry/test_angle.py +345 -0
- ostk/mathematics/test/object/__init__.py +1 -0
- ostk/mathematics/test/object/test_interval.py +515 -0
- ostk/mathematics/test/object/test_vector.py +5 -0
- ostk/mathematics/test/solver/test_numerical_solver.py +176 -0
- ostk/mathematics/test/test_object.py +24 -0
|
@@ -0,0 +1,1779 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
import numpy
|
|
3
|
+
import ostk.core.type
|
|
4
|
+
import ostk.mathematics.geometry.d2
|
|
5
|
+
import typing
|
|
6
|
+
__all__ = ['Composite', 'Line', 'LineString', 'MultiPolygon', 'Point', 'PointSet', 'Polygon', 'Segment', 'set_point_2_array', 'set_point_array']
|
|
7
|
+
class Composite(ostk.mathematics.geometry.d2.Object):
|
|
8
|
+
__hash__: typing.ClassVar[None] = None
|
|
9
|
+
@staticmethod
|
|
10
|
+
def empty() -> Composite:
|
|
11
|
+
"""
|
|
12
|
+
Create an empty 2D composite (containing no objects).
|
|
13
|
+
|
|
14
|
+
Returns:
|
|
15
|
+
Composite: An empty composite object.
|
|
16
|
+
|
|
17
|
+
Example:
|
|
18
|
+
>>> empty_composite = Composite.empty()
|
|
19
|
+
>>> empty_composite.is_empty() # True
|
|
20
|
+
>>> empty_composite.get_object_count() # 0
|
|
21
|
+
"""
|
|
22
|
+
@staticmethod
|
|
23
|
+
def undefined() -> Composite:
|
|
24
|
+
"""
|
|
25
|
+
Create an undefined 2D composite.
|
|
26
|
+
|
|
27
|
+
Returns:
|
|
28
|
+
Composite: An undefined composite object.
|
|
29
|
+
|
|
30
|
+
Example:
|
|
31
|
+
>>> undefined_composite = Composite.undefined()
|
|
32
|
+
>>> undefined_composite.is_defined() # False
|
|
33
|
+
"""
|
|
34
|
+
def __add__(self, arg0: Composite) -> Composite:
|
|
35
|
+
...
|
|
36
|
+
def __eq__(self, arg0: Composite) -> bool:
|
|
37
|
+
...
|
|
38
|
+
def __iadd__(self, arg0: Composite) -> Composite:
|
|
39
|
+
...
|
|
40
|
+
def __init__(self, object: ostk.mathematics.geometry.d2.Object) -> None:
|
|
41
|
+
"""
|
|
42
|
+
Create a 2D composite object from a single geometric object.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
object (Object): The 2D geometric object to wrap in the composite.
|
|
46
|
+
|
|
47
|
+
Example:
|
|
48
|
+
>>> point = Point(1.0, 2.0)
|
|
49
|
+
>>> composite = Composite(point)
|
|
50
|
+
"""
|
|
51
|
+
def __ne__(self, arg0: Composite) -> bool:
|
|
52
|
+
...
|
|
53
|
+
def __repr__(self) -> str:
|
|
54
|
+
...
|
|
55
|
+
def __str__(self) -> str:
|
|
56
|
+
...
|
|
57
|
+
def access_object_at(self, index: int) -> ostk.mathematics.geometry.d2.Object:
|
|
58
|
+
"""
|
|
59
|
+
Access the object at a specific index in the 2D composite.
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
index (int): The index of the object to access.
|
|
63
|
+
|
|
64
|
+
Returns:
|
|
65
|
+
Object: Reference to the object at the specified index.
|
|
66
|
+
|
|
67
|
+
Raises:
|
|
68
|
+
IndexError: If the index is out of bounds.
|
|
69
|
+
|
|
70
|
+
Example:
|
|
71
|
+
>>> composite = Composite(Point(1.0, 2.0))
|
|
72
|
+
>>> obj = composite.access_object_at(0)
|
|
73
|
+
"""
|
|
74
|
+
@typing.overload
|
|
75
|
+
def any_contains(self, object: ostk.mathematics.geometry.d2.Object) -> bool:
|
|
76
|
+
"""
|
|
77
|
+
Check if any object in the 2D composite contains another geometric object.
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
object (Object): The 2D object to check containment for.
|
|
81
|
+
|
|
82
|
+
Returns:
|
|
83
|
+
bool: True if any object in the composite contains the object, False otherwise.
|
|
84
|
+
|
|
85
|
+
Example:
|
|
86
|
+
>>> polygon1 = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)])
|
|
87
|
+
>>> polygon2 = Polygon([Point(2.0, 2.0), Point(3.0, 2.0), Point(3.0, 3.0)])
|
|
88
|
+
>>> composite = Composite(polygon1) + Composite(polygon2)
|
|
89
|
+
>>> point = Point(0.5, 0.5)
|
|
90
|
+
>>> composite.any_contains(point) # True
|
|
91
|
+
"""
|
|
92
|
+
@typing.overload
|
|
93
|
+
def any_contains(self, composite: Composite) -> bool:
|
|
94
|
+
"""
|
|
95
|
+
Check if any object in the 2D composite contains another composite.
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
composite (Composite): The composite to check containment for.
|
|
99
|
+
|
|
100
|
+
Returns:
|
|
101
|
+
bool: True if any object in this composite contains the other composite, False otherwise.
|
|
102
|
+
|
|
103
|
+
Example:
|
|
104
|
+
>>> outer_polygon = Polygon([Point(0.0, 0.0), Point(3.0, 0.0), Point(3.0, 3.0)])
|
|
105
|
+
>>> composite1 = Composite(outer_polygon)
|
|
106
|
+
>>> inner_composite = Composite(Point(1.5, 1.5))
|
|
107
|
+
>>> composite1.any_contains(inner_composite) # True
|
|
108
|
+
"""
|
|
109
|
+
def apply_transformation(self, transformation: typing.Any) -> None:
|
|
110
|
+
"""
|
|
111
|
+
Apply a transformation to all objects in the 2D composite in place.
|
|
112
|
+
|
|
113
|
+
Args:
|
|
114
|
+
transformation (Transformation): The 2D transformation to apply.
|
|
115
|
+
|
|
116
|
+
Example:
|
|
117
|
+
>>> composite = Composite(Point(1.0, 2.0))
|
|
118
|
+
>>> transformation = Translation([1.0, 1.0])
|
|
119
|
+
>>> composite.apply_transformation(transformation)
|
|
120
|
+
"""
|
|
121
|
+
def as_composite(self) -> Composite:
|
|
122
|
+
"""
|
|
123
|
+
Convert the composite to a 2D Composite object.
|
|
124
|
+
|
|
125
|
+
Returns:
|
|
126
|
+
Composite: The composite object contained in the composite.
|
|
127
|
+
|
|
128
|
+
Raises:
|
|
129
|
+
RuntimeError: If the composite does not contain a Composite.
|
|
130
|
+
|
|
131
|
+
Example:
|
|
132
|
+
>>> inner_composite = Composite(Point(1.0, 2.0))
|
|
133
|
+
>>> outer_composite = Composite(inner_composite)
|
|
134
|
+
>>> extracted_composite = outer_composite.as_composite()
|
|
135
|
+
"""
|
|
136
|
+
def as_line(self) -> Line:
|
|
137
|
+
"""
|
|
138
|
+
Convert the composite to a 2D Line object.
|
|
139
|
+
|
|
140
|
+
Returns:
|
|
141
|
+
Line: The line object contained in the composite.
|
|
142
|
+
|
|
143
|
+
Raises:
|
|
144
|
+
RuntimeError: If the composite does not contain a Line.
|
|
145
|
+
|
|
146
|
+
Example:
|
|
147
|
+
>>> line = Line(Point(0.0, 0.0), np.array([1.0, 1.0]))
|
|
148
|
+
>>> composite = Composite(line)
|
|
149
|
+
>>> extracted_line = composite.as_line()
|
|
150
|
+
"""
|
|
151
|
+
def as_line_string(self) -> LineString:
|
|
152
|
+
"""
|
|
153
|
+
Convert the composite to a 2D LineString object.
|
|
154
|
+
|
|
155
|
+
Returns:
|
|
156
|
+
LineString: The line string object contained in the composite.
|
|
157
|
+
|
|
158
|
+
Raises:
|
|
159
|
+
RuntimeError: If the composite does not contain a LineString.
|
|
160
|
+
|
|
161
|
+
Example:
|
|
162
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0), Point(2.0, 2.0)]
|
|
163
|
+
>>> line_string = LineString(points)
|
|
164
|
+
>>> composite = Composite(line_string)
|
|
165
|
+
>>> extracted_line_string = composite.as_line_string()
|
|
166
|
+
"""
|
|
167
|
+
def as_point(self) -> Point:
|
|
168
|
+
"""
|
|
169
|
+
Convert the composite to a 2D Point object.
|
|
170
|
+
|
|
171
|
+
Returns:
|
|
172
|
+
Point: The point object contained in the composite.
|
|
173
|
+
|
|
174
|
+
Raises:
|
|
175
|
+
RuntimeError: If the composite does not contain a Point.
|
|
176
|
+
|
|
177
|
+
Example:
|
|
178
|
+
>>> composite = Composite(Point(1.0, 2.0))
|
|
179
|
+
>>> point = composite.as_point()
|
|
180
|
+
"""
|
|
181
|
+
def as_point_set(self) -> PointSet:
|
|
182
|
+
"""
|
|
183
|
+
Convert the composite to a 2D PointSet object.
|
|
184
|
+
|
|
185
|
+
Returns:
|
|
186
|
+
PointSet: The point set object contained in the composite.
|
|
187
|
+
|
|
188
|
+
Raises:
|
|
189
|
+
RuntimeError: If the composite does not contain a PointSet.
|
|
190
|
+
|
|
191
|
+
Example:
|
|
192
|
+
>>> point_set = PointSet([Point(1.0, 2.0), Point(3.0, 4.0)])
|
|
193
|
+
>>> composite = Composite(point_set)
|
|
194
|
+
>>> extracted_set = composite.as_point_set()
|
|
195
|
+
"""
|
|
196
|
+
def as_polygon(self) -> Polygon:
|
|
197
|
+
"""
|
|
198
|
+
Convert the composite to a 2D Polygon object.
|
|
199
|
+
|
|
200
|
+
Returns:
|
|
201
|
+
Polygon: The polygon object contained in the composite.
|
|
202
|
+
|
|
203
|
+
Raises:
|
|
204
|
+
RuntimeError: If the composite does not contain a Polygon.
|
|
205
|
+
|
|
206
|
+
Example:
|
|
207
|
+
>>> vertices = [Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)]
|
|
208
|
+
>>> polygon = Polygon(vertices)
|
|
209
|
+
>>> composite = Composite(polygon)
|
|
210
|
+
>>> extracted_polygon = composite.as_polygon()
|
|
211
|
+
"""
|
|
212
|
+
def as_segment(self) -> Segment:
|
|
213
|
+
"""
|
|
214
|
+
Convert the composite to a 2D Segment object.
|
|
215
|
+
|
|
216
|
+
Returns:
|
|
217
|
+
Segment: The segment object contained in the composite.
|
|
218
|
+
|
|
219
|
+
Raises:
|
|
220
|
+
RuntimeError: If the composite does not contain a Segment.
|
|
221
|
+
|
|
222
|
+
Example:
|
|
223
|
+
>>> segment = Segment(Point(0.0, 0.0), Point(1.0, 1.0))
|
|
224
|
+
>>> composite = Composite(segment)
|
|
225
|
+
>>> extracted_segment = composite.as_segment()
|
|
226
|
+
"""
|
|
227
|
+
@typing.overload
|
|
228
|
+
def contains(self, object: ostk.mathematics.geometry.d2.Object) -> bool:
|
|
229
|
+
"""
|
|
230
|
+
Check if the 2D composite contains another geometric object.
|
|
231
|
+
|
|
232
|
+
Args:
|
|
233
|
+
object (Object): The 2D object to check containment for.
|
|
234
|
+
|
|
235
|
+
Returns:
|
|
236
|
+
bool: True if the composite contains the object, False otherwise.
|
|
237
|
+
|
|
238
|
+
Example:
|
|
239
|
+
>>> composite = Composite(Polygon([Point(0.0, 0.0), Point(2.0, 0.0), Point(2.0, 2.0)]))
|
|
240
|
+
>>> point = Point(1.0, 1.0)
|
|
241
|
+
>>> composite.contains(point) # True
|
|
242
|
+
"""
|
|
243
|
+
@typing.overload
|
|
244
|
+
def contains(self, composite: Composite) -> bool:
|
|
245
|
+
"""
|
|
246
|
+
Check if the 2D composite contains another composite.
|
|
247
|
+
|
|
248
|
+
Args:
|
|
249
|
+
composite (Composite): The composite to check containment for.
|
|
250
|
+
|
|
251
|
+
Returns:
|
|
252
|
+
bool: True if this composite contains the other composite, False otherwise.
|
|
253
|
+
|
|
254
|
+
Example:
|
|
255
|
+
>>> outer_composite = Composite(Polygon([Point(0.0, 0.0), Point(3.0, 0.0), Point(3.0, 3.0)]))
|
|
256
|
+
>>> inner_composite = Composite(Polygon([Point(1.0, 1.0), Point(2.0, 1.0), Point(2.0, 2.0)]))
|
|
257
|
+
>>> outer_composite.contains(inner_composite) # True
|
|
258
|
+
"""
|
|
259
|
+
def get_object_count(self) -> int:
|
|
260
|
+
"""
|
|
261
|
+
Get the number of objects contained in the 2D composite.
|
|
262
|
+
|
|
263
|
+
Returns:
|
|
264
|
+
int: The number of objects in the composite.
|
|
265
|
+
|
|
266
|
+
Example:
|
|
267
|
+
>>> composite = Composite(Point(1.0, 2.0))
|
|
268
|
+
>>> count = composite.get_object_count() # 1
|
|
269
|
+
"""
|
|
270
|
+
@typing.overload
|
|
271
|
+
def intersects(self, object: ostk.mathematics.geometry.d2.Object) -> bool:
|
|
272
|
+
"""
|
|
273
|
+
Check if the 2D composite intersects with another geometric object.
|
|
274
|
+
|
|
275
|
+
Args:
|
|
276
|
+
object (Object): The 2D object to check intersection with.
|
|
277
|
+
|
|
278
|
+
Returns:
|
|
279
|
+
bool: True if the composite intersects the object, False otherwise.
|
|
280
|
+
|
|
281
|
+
Example:
|
|
282
|
+
>>> composite = Composite(Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)]))
|
|
283
|
+
>>> point = Point(0.5, 0.5)
|
|
284
|
+
>>> composite.intersects(point) # True
|
|
285
|
+
"""
|
|
286
|
+
@typing.overload
|
|
287
|
+
def intersects(self, composite: Composite) -> bool:
|
|
288
|
+
"""
|
|
289
|
+
Check if the 2D composite intersects with another composite.
|
|
290
|
+
|
|
291
|
+
Args:
|
|
292
|
+
composite (Composite): The composite to check intersection with.
|
|
293
|
+
|
|
294
|
+
Returns:
|
|
295
|
+
bool: True if the composites intersect, False otherwise.
|
|
296
|
+
|
|
297
|
+
Example:
|
|
298
|
+
>>> composite1 = Composite(Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)]))
|
|
299
|
+
>>> composite2 = Composite(Polygon([Point(0.5, 0.5), Point(1.5, 0.5), Point(1.5, 1.5)]))
|
|
300
|
+
>>> composite1.intersects(composite2) # True
|
|
301
|
+
"""
|
|
302
|
+
def is_composite(self) -> bool:
|
|
303
|
+
"""
|
|
304
|
+
Check if the composite contains another 2D Composite object.
|
|
305
|
+
|
|
306
|
+
Returns:
|
|
307
|
+
bool: True if the composite contains a Composite, False otherwise.
|
|
308
|
+
|
|
309
|
+
Example:
|
|
310
|
+
>>> inner_composite = Composite(Point(1.0, 2.0))
|
|
311
|
+
>>> outer_composite = Composite(inner_composite)
|
|
312
|
+
>>> outer_composite.is_composite() # True
|
|
313
|
+
"""
|
|
314
|
+
def is_defined(self) -> bool:
|
|
315
|
+
"""
|
|
316
|
+
Check if the 2D composite is defined.
|
|
317
|
+
|
|
318
|
+
Returns:
|
|
319
|
+
bool: True if the composite is defined, False otherwise.
|
|
320
|
+
|
|
321
|
+
Example:
|
|
322
|
+
>>> composite = Composite(Point(1.0, 2.0))
|
|
323
|
+
>>> composite.is_defined() # True
|
|
324
|
+
"""
|
|
325
|
+
def is_empty(self) -> bool:
|
|
326
|
+
"""
|
|
327
|
+
Check if the 2D composite is empty (contains no objects).
|
|
328
|
+
|
|
329
|
+
Returns:
|
|
330
|
+
bool: True if the composite is empty, False otherwise.
|
|
331
|
+
|
|
332
|
+
Example:
|
|
333
|
+
>>> empty_composite = Composite.empty()
|
|
334
|
+
>>> empty_composite.is_empty() # True
|
|
335
|
+
"""
|
|
336
|
+
def is_line(self) -> bool:
|
|
337
|
+
"""
|
|
338
|
+
Check if the composite contains a 2D Line object.
|
|
339
|
+
|
|
340
|
+
Returns:
|
|
341
|
+
bool: True if the composite contains a Line, False otherwise.
|
|
342
|
+
|
|
343
|
+
Example:
|
|
344
|
+
>>> line = Line(Point(0.0, 0.0), np.array([1.0, 1.0]))
|
|
345
|
+
>>> composite = Composite(line)
|
|
346
|
+
>>> composite.is_line() # True
|
|
347
|
+
"""
|
|
348
|
+
def is_line_string(self) -> bool:
|
|
349
|
+
"""
|
|
350
|
+
Check if the composite contains a 2D LineString object.
|
|
351
|
+
|
|
352
|
+
Returns:
|
|
353
|
+
bool: True if the composite contains a LineString, False otherwise.
|
|
354
|
+
|
|
355
|
+
Example:
|
|
356
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0), Point(2.0, 2.0)]
|
|
357
|
+
>>> line_string = LineString(points)
|
|
358
|
+
>>> composite = Composite(line_string)
|
|
359
|
+
>>> composite.is_line_string() # True
|
|
360
|
+
"""
|
|
361
|
+
def is_point(self) -> bool:
|
|
362
|
+
"""
|
|
363
|
+
Check if the composite contains a 2D Point object.
|
|
364
|
+
|
|
365
|
+
Returns:
|
|
366
|
+
bool: True if the composite contains a Point, False otherwise.
|
|
367
|
+
|
|
368
|
+
Example:
|
|
369
|
+
>>> composite = Composite(Point(1.0, 2.0))
|
|
370
|
+
>>> composite.is_point() # True
|
|
371
|
+
"""
|
|
372
|
+
def is_point_set(self) -> bool:
|
|
373
|
+
"""
|
|
374
|
+
Check if the composite contains a 2D PointSet object.
|
|
375
|
+
|
|
376
|
+
Returns:
|
|
377
|
+
bool: True if the composite contains a PointSet, False otherwise.
|
|
378
|
+
|
|
379
|
+
Example:
|
|
380
|
+
>>> point_set = PointSet([Point(1.0, 2.0), Point(3.0, 4.0)])
|
|
381
|
+
>>> composite = Composite(point_set)
|
|
382
|
+
>>> composite.is_point_set() # True
|
|
383
|
+
"""
|
|
384
|
+
def is_polygon(self) -> bool:
|
|
385
|
+
"""
|
|
386
|
+
Check if the composite contains a 2D Polygon object.
|
|
387
|
+
|
|
388
|
+
Returns:
|
|
389
|
+
bool: True if the composite contains a Polygon, False otherwise.
|
|
390
|
+
|
|
391
|
+
Example:
|
|
392
|
+
>>> vertices = [Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)]
|
|
393
|
+
>>> polygon = Polygon(vertices)
|
|
394
|
+
>>> composite = Composite(polygon)
|
|
395
|
+
>>> composite.is_polygon() # True
|
|
396
|
+
"""
|
|
397
|
+
def is_segment(self) -> bool:
|
|
398
|
+
"""
|
|
399
|
+
Check if the composite contains a 2D Segment object.
|
|
400
|
+
|
|
401
|
+
Returns:
|
|
402
|
+
bool: True if the composite contains a Segment, False otherwise.
|
|
403
|
+
|
|
404
|
+
Example:
|
|
405
|
+
>>> segment = Segment(Point(0.0, 0.0), Point(1.0, 1.0))
|
|
406
|
+
>>> composite = Composite(segment)
|
|
407
|
+
>>> composite.is_segment() # True
|
|
408
|
+
"""
|
|
409
|
+
class Line(ostk.mathematics.geometry.d2.Object):
|
|
410
|
+
__hash__: typing.ClassVar[None] = None
|
|
411
|
+
@staticmethod
|
|
412
|
+
def points(first_point: Point, second_point: Point) -> Line:
|
|
413
|
+
"""
|
|
414
|
+
Create a line passing through two points.
|
|
415
|
+
|
|
416
|
+
Args:
|
|
417
|
+
first_point (Point): The first point.
|
|
418
|
+
second_point (Point): The second point.
|
|
419
|
+
|
|
420
|
+
Returns:
|
|
421
|
+
Line: A line passing through both points.
|
|
422
|
+
|
|
423
|
+
Example:
|
|
424
|
+
>>> point1 = Point(0.0, 0.0)
|
|
425
|
+
>>> point2 = Point(1.0, 1.0)
|
|
426
|
+
>>> line = Line.points(point1, point2)
|
|
427
|
+
"""
|
|
428
|
+
@staticmethod
|
|
429
|
+
def undefined() -> Line:
|
|
430
|
+
"""
|
|
431
|
+
Create an undefined line.
|
|
432
|
+
|
|
433
|
+
Returns:
|
|
434
|
+
Line: An undefined line.
|
|
435
|
+
|
|
436
|
+
Example:
|
|
437
|
+
>>> undefined_line = Line.undefined()
|
|
438
|
+
>>> undefined_line.is_defined() # False
|
|
439
|
+
"""
|
|
440
|
+
def __eq__(self, arg0: Line) -> bool:
|
|
441
|
+
...
|
|
442
|
+
def __init__(self, point: Point, direction: numpy.ndarray[numpy.float64[2, 1]]) -> None:
|
|
443
|
+
"""
|
|
444
|
+
Create a 2D line with a point and direction vector.
|
|
445
|
+
|
|
446
|
+
Args:
|
|
447
|
+
point (Point): A point on the line.
|
|
448
|
+
direction (np.array): The direction vector of the line.
|
|
449
|
+
|
|
450
|
+
Example:
|
|
451
|
+
>>> point = Point(0.0, 0.0)
|
|
452
|
+
>>> direction = np.array([1.0, 1.0])
|
|
453
|
+
>>> line = Line(point, direction)
|
|
454
|
+
"""
|
|
455
|
+
def __ne__(self, arg0: Line) -> bool:
|
|
456
|
+
...
|
|
457
|
+
def __repr__(self) -> str:
|
|
458
|
+
...
|
|
459
|
+
def __str__(self) -> str:
|
|
460
|
+
...
|
|
461
|
+
def apply_transformation(self, transformation: typing.Any) -> None:
|
|
462
|
+
"""
|
|
463
|
+
Apply a transformation to the line in place.
|
|
464
|
+
|
|
465
|
+
Args:
|
|
466
|
+
transformation (Transformation): The transformation to apply.
|
|
467
|
+
|
|
468
|
+
Example:
|
|
469
|
+
>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
|
|
470
|
+
>>> transformation = Translation([1.0, 1.0])
|
|
471
|
+
>>> line.apply_transformation(transformation)
|
|
472
|
+
"""
|
|
473
|
+
@typing.overload
|
|
474
|
+
def contains(self, point: Point) -> bool:
|
|
475
|
+
"""
|
|
476
|
+
Check if the line contains a point.
|
|
477
|
+
|
|
478
|
+
Args:
|
|
479
|
+
point (Point): The point to check.
|
|
480
|
+
|
|
481
|
+
Returns:
|
|
482
|
+
bool: True if the line contains the point, False otherwise.
|
|
483
|
+
|
|
484
|
+
Example:
|
|
485
|
+
>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 1.0))
|
|
486
|
+
>>> line.contains(Point(0.5, 0.5)) # True
|
|
487
|
+
"""
|
|
488
|
+
@typing.overload
|
|
489
|
+
def contains(self, point_set: PointSet) -> bool:
|
|
490
|
+
"""
|
|
491
|
+
Check if the line contains all points in a point set.
|
|
492
|
+
|
|
493
|
+
Args:
|
|
494
|
+
point_set (PointSet): The set of points to check.
|
|
495
|
+
|
|
496
|
+
Returns:
|
|
497
|
+
bool: True if the line contains all points in the set, False otherwise.
|
|
498
|
+
|
|
499
|
+
Example:
|
|
500
|
+
>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 1.0))
|
|
501
|
+
>>> points = PointSet([Point(0.5, 0.5), Point(0.25, 0.25)])
|
|
502
|
+
>>> line.contains(points)
|
|
503
|
+
"""
|
|
504
|
+
def distance_to(self, point: Point) -> ostk.core.type.Real:
|
|
505
|
+
"""
|
|
506
|
+
Calculate the distance from the line to a point.
|
|
507
|
+
|
|
508
|
+
Args:
|
|
509
|
+
point (Point): The point to calculate distance to.
|
|
510
|
+
|
|
511
|
+
Returns:
|
|
512
|
+
float: The distance from the line to the point.
|
|
513
|
+
|
|
514
|
+
Example:
|
|
515
|
+
>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
|
|
516
|
+
>>> distance = line.distance_to(Point(0.5, 1.0)) # 1.0
|
|
517
|
+
"""
|
|
518
|
+
def get_direction(self) -> numpy.ndarray[numpy.float64[2, 1]]:
|
|
519
|
+
"""
|
|
520
|
+
Get the direction vector of the line.
|
|
521
|
+
|
|
522
|
+
Returns:
|
|
523
|
+
Vector2d: The direction vector of the line.
|
|
524
|
+
|
|
525
|
+
Example:
|
|
526
|
+
>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 1.0))
|
|
527
|
+
>>> direction = line.get_direction()
|
|
528
|
+
"""
|
|
529
|
+
def get_origin(self) -> Point:
|
|
530
|
+
"""
|
|
531
|
+
Get the origin point of the line.
|
|
532
|
+
|
|
533
|
+
Returns:
|
|
534
|
+
Point: The origin point of the line.
|
|
535
|
+
|
|
536
|
+
Example:
|
|
537
|
+
>>> line = Line.points(Point(1.0, 2.0), Point(3.0, 4.0))
|
|
538
|
+
>>> origin = line.get_origin()
|
|
539
|
+
"""
|
|
540
|
+
def intersects(self, point: Point) -> bool:
|
|
541
|
+
"""
|
|
542
|
+
Check if the line intersects with a point.
|
|
543
|
+
|
|
544
|
+
Args:
|
|
545
|
+
point (Point): The point to check intersection with.
|
|
546
|
+
|
|
547
|
+
Returns:
|
|
548
|
+
bool: True if the line intersects with the point, False otherwise.
|
|
549
|
+
|
|
550
|
+
Example:
|
|
551
|
+
>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 1.0))
|
|
552
|
+
>>> line.intersects(Point(0.5, 0.5)) # True
|
|
553
|
+
"""
|
|
554
|
+
def is_defined(self) -> bool:
|
|
555
|
+
"""
|
|
556
|
+
Check if the line is defined.
|
|
557
|
+
|
|
558
|
+
Returns:
|
|
559
|
+
bool: True if the line is defined, False otherwise.
|
|
560
|
+
|
|
561
|
+
Example:
|
|
562
|
+
>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 1.0))
|
|
563
|
+
>>> line.is_defined() # True
|
|
564
|
+
"""
|
|
565
|
+
class LineString(ostk.mathematics.geometry.d2.Object):
|
|
566
|
+
__hash__: typing.ClassVar[None] = None
|
|
567
|
+
@staticmethod
|
|
568
|
+
def empty() -> LineString:
|
|
569
|
+
"""
|
|
570
|
+
Create an empty line string.
|
|
571
|
+
|
|
572
|
+
Returns:
|
|
573
|
+
LineString: An empty line string.
|
|
574
|
+
|
|
575
|
+
Example:
|
|
576
|
+
>>> empty_line = LineString.empty()
|
|
577
|
+
>>> empty_line.is_empty() # True
|
|
578
|
+
"""
|
|
579
|
+
def __eq__(self, arg0: LineString) -> bool:
|
|
580
|
+
...
|
|
581
|
+
def __getitem__(self, index: int) -> Point:
|
|
582
|
+
"""
|
|
583
|
+
Access a point by index (Python indexing support).
|
|
584
|
+
|
|
585
|
+
Args:
|
|
586
|
+
index (int): The index of the point to access.
|
|
587
|
+
|
|
588
|
+
Returns:
|
|
589
|
+
Point: The point at the specified index.
|
|
590
|
+
|
|
591
|
+
Raises:
|
|
592
|
+
IndexError: If the index is out of range.
|
|
593
|
+
|
|
594
|
+
Example:
|
|
595
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
596
|
+
>>> line_string = LineString(points)
|
|
597
|
+
>>> first_point = line_string[0] # Point(0.0, 0.0)
|
|
598
|
+
"""
|
|
599
|
+
def __init__(self, points: list[Point]) -> None:
|
|
600
|
+
"""
|
|
601
|
+
Create a 2D line string from a sequence of points.
|
|
602
|
+
|
|
603
|
+
Args:
|
|
604
|
+
points (list): A list of Point objects defining the line string.
|
|
605
|
+
|
|
606
|
+
Example:
|
|
607
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0), Point(2.0, 0.0)]
|
|
608
|
+
>>> line_string = LineString(points)
|
|
609
|
+
"""
|
|
610
|
+
def __iter__(self) -> typing.Iterator[Point]:
|
|
611
|
+
"""
|
|
612
|
+
Make the line string iterable (Python for loop support).
|
|
613
|
+
|
|
614
|
+
Returns:
|
|
615
|
+
iterator: An iterator over the points in the line string.
|
|
616
|
+
|
|
617
|
+
Example:
|
|
618
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
619
|
+
>>> line_string = LineString(points)
|
|
620
|
+
>>> for point in line_string:
|
|
621
|
+
... print(point)
|
|
622
|
+
"""
|
|
623
|
+
def __len__(self) -> int:
|
|
624
|
+
"""
|
|
625
|
+
Get the number of points in the line string (Python len() function).
|
|
626
|
+
|
|
627
|
+
Returns:
|
|
628
|
+
int: The number of points.
|
|
629
|
+
|
|
630
|
+
Example:
|
|
631
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
632
|
+
>>> line_string = LineString(points)
|
|
633
|
+
>>> len(line_string) # 2
|
|
634
|
+
"""
|
|
635
|
+
def __ne__(self, arg0: LineString) -> bool:
|
|
636
|
+
...
|
|
637
|
+
def __repr__(self) -> str:
|
|
638
|
+
...
|
|
639
|
+
def __str__(self) -> str:
|
|
640
|
+
...
|
|
641
|
+
def apply_transformation(self, transformation: typing.Any) -> None:
|
|
642
|
+
"""
|
|
643
|
+
Apply a transformation to the line string in place.
|
|
644
|
+
|
|
645
|
+
Args:
|
|
646
|
+
transformation (Transformation): The transformation to apply.
|
|
647
|
+
|
|
648
|
+
Example:
|
|
649
|
+
>>> line_string = LineString(points)
|
|
650
|
+
>>> transformation = Transformation.translation([1.0, 0.0])
|
|
651
|
+
>>> line_string.apply_transformation(transformation)
|
|
652
|
+
"""
|
|
653
|
+
def get_point_closest_to(self, point: Point) -> Point:
|
|
654
|
+
"""
|
|
655
|
+
Get the point on the line string closest to a given point.
|
|
656
|
+
|
|
657
|
+
Args:
|
|
658
|
+
point (Point): The reference point.
|
|
659
|
+
|
|
660
|
+
Returns:
|
|
661
|
+
Point: The closest point on the line string.
|
|
662
|
+
|
|
663
|
+
Example:
|
|
664
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0), Point(2.0, 0.0)]
|
|
665
|
+
>>> line_string = LineString(points)
|
|
666
|
+
>>> closest = line_string.get_point_closest_to(Point(0.5, 0.5))
|
|
667
|
+
"""
|
|
668
|
+
def get_point_count(self) -> int:
|
|
669
|
+
"""
|
|
670
|
+
Get the number of points in the line string.
|
|
671
|
+
|
|
672
|
+
Returns:
|
|
673
|
+
int: The number of points.
|
|
674
|
+
|
|
675
|
+
Example:
|
|
676
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0), Point(2.0, 0.0)]
|
|
677
|
+
>>> line_string = LineString(points)
|
|
678
|
+
>>> line_string.get_point_count() # 3
|
|
679
|
+
"""
|
|
680
|
+
def is_defined(self) -> bool:
|
|
681
|
+
"""
|
|
682
|
+
Check if the line string is defined.
|
|
683
|
+
|
|
684
|
+
Returns:
|
|
685
|
+
bool: True if the line string is defined, False otherwise.
|
|
686
|
+
|
|
687
|
+
Example:
|
|
688
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
689
|
+
>>> line_string = LineString(points)
|
|
690
|
+
>>> line_string.is_defined() # True
|
|
691
|
+
"""
|
|
692
|
+
def is_empty(self) -> bool:
|
|
693
|
+
"""
|
|
694
|
+
Check if the line string is empty (has no points).
|
|
695
|
+
|
|
696
|
+
Returns:
|
|
697
|
+
bool: True if the line string is empty, False otherwise.
|
|
698
|
+
|
|
699
|
+
Example:
|
|
700
|
+
>>> empty_line = LineString.empty()
|
|
701
|
+
>>> empty_line.is_empty() # True
|
|
702
|
+
"""
|
|
703
|
+
def is_near(self, line_string: LineString, tolerance: ostk.core.type.Real) -> bool:
|
|
704
|
+
"""
|
|
705
|
+
Check if the line string is near another line string.
|
|
706
|
+
|
|
707
|
+
Args:
|
|
708
|
+
line_string (LineString): The line string to check.
|
|
709
|
+
tolerance (float): The tolerance.
|
|
710
|
+
|
|
711
|
+
Returns:
|
|
712
|
+
bool: True if the line string is near another line string, False otherwise.
|
|
713
|
+
|
|
714
|
+
Example:
|
|
715
|
+
>>> line_string = LineString(points)
|
|
716
|
+
>>> line_string.is_near(LineString(points), 0.1) # True
|
|
717
|
+
"""
|
|
718
|
+
def to_string(self, format: ostk.mathematics.geometry.d2.Object.Format = ..., precision: ostk.core.type.Integer = ...) -> ostk.core.type.String:
|
|
719
|
+
"""
|
|
720
|
+
Convert the line string to a string representation.
|
|
721
|
+
|
|
722
|
+
Args:
|
|
723
|
+
format (Object.Format, optional): The output format. Defaults to Standard.
|
|
724
|
+
precision (int, optional): The precision for floating point numbers. Defaults to undefined.
|
|
725
|
+
|
|
726
|
+
Returns:
|
|
727
|
+
str: String representation of the line string.
|
|
728
|
+
|
|
729
|
+
Example:
|
|
730
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
731
|
+
>>> line_string = LineString(points)
|
|
732
|
+
>>> line_string.to_string()
|
|
733
|
+
"""
|
|
734
|
+
class MultiPolygon(ostk.mathematics.geometry.d2.Object):
|
|
735
|
+
__hash__: typing.ClassVar[None] = None
|
|
736
|
+
@staticmethod
|
|
737
|
+
def polygon(polygon: Polygon) -> MultiPolygon:
|
|
738
|
+
"""
|
|
739
|
+
Create a multi-polygon from a single polygon.
|
|
740
|
+
|
|
741
|
+
Args:
|
|
742
|
+
polygon (Polygon): The polygon to wrap in a multi-polygon.
|
|
743
|
+
|
|
744
|
+
Returns:
|
|
745
|
+
MultiPolygon: A multi-polygon containing the single polygon.
|
|
746
|
+
|
|
747
|
+
Example:
|
|
748
|
+
>>> polygon = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)])
|
|
749
|
+
>>> multi_polygon = MultiPolygon.polygon(polygon)
|
|
750
|
+
>>> multi_polygon.get_polygon_count() # 1
|
|
751
|
+
"""
|
|
752
|
+
@staticmethod
|
|
753
|
+
def undefined() -> MultiPolygon:
|
|
754
|
+
"""
|
|
755
|
+
Create an undefined multi-polygon.
|
|
756
|
+
|
|
757
|
+
Returns:
|
|
758
|
+
MultiPolygon: An undefined multi-polygon object.
|
|
759
|
+
|
|
760
|
+
Example:
|
|
761
|
+
>>> undefined_multi_polygon = MultiPolygon.undefined()
|
|
762
|
+
>>> undefined_multi_polygon.is_defined() # False
|
|
763
|
+
"""
|
|
764
|
+
def __eq__(self, arg0: MultiPolygon) -> bool:
|
|
765
|
+
...
|
|
766
|
+
def __init__(self, polygons: list[Polygon]) -> None:
|
|
767
|
+
"""
|
|
768
|
+
Create a multi-polygon from an array of polygons.
|
|
769
|
+
|
|
770
|
+
Args:
|
|
771
|
+
polygons (list): List of Polygon objects to combine into a multi-polygon.
|
|
772
|
+
|
|
773
|
+
Example:
|
|
774
|
+
>>> polygon1 = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)])
|
|
775
|
+
>>> polygon2 = Polygon([Point(2.0, 2.0), Point(3.0, 2.0), Point(3.0, 3.0)])
|
|
776
|
+
>>> multi_polygon = MultiPolygon([polygon1, polygon2])
|
|
777
|
+
"""
|
|
778
|
+
def __ne__(self, arg0: MultiPolygon) -> bool:
|
|
779
|
+
...
|
|
780
|
+
def __repr__(self) -> str:
|
|
781
|
+
...
|
|
782
|
+
def __str__(self) -> str:
|
|
783
|
+
...
|
|
784
|
+
def apply_transformation(self, transformation: typing.Any) -> None:
|
|
785
|
+
"""
|
|
786
|
+
Apply a transformation to all polygons in the multi-polygon in place.
|
|
787
|
+
|
|
788
|
+
Args:
|
|
789
|
+
transformation (Transformation): The 2D transformation to apply.
|
|
790
|
+
|
|
791
|
+
Example:
|
|
792
|
+
>>> polygon = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)])
|
|
793
|
+
>>> multi_polygon = MultiPolygon([polygon])
|
|
794
|
+
>>> transformation = Translation([1.0, 1.0])
|
|
795
|
+
>>> multi_polygon.apply_transformation(transformation)
|
|
796
|
+
"""
|
|
797
|
+
@typing.overload
|
|
798
|
+
def contains(self, point: Point) -> bool:
|
|
799
|
+
"""
|
|
800
|
+
Check if the multi-polygon contains a point.
|
|
801
|
+
|
|
802
|
+
Args:
|
|
803
|
+
point (Point): The point to check for containment.
|
|
804
|
+
|
|
805
|
+
Returns:
|
|
806
|
+
bool: True if any polygon in the multi-polygon contains the point, False otherwise.
|
|
807
|
+
|
|
808
|
+
Example:
|
|
809
|
+
>>> polygon = Polygon([Point(0.0, 0.0), Point(2.0, 0.0), Point(2.0, 2.0)])
|
|
810
|
+
>>> multi_polygon = MultiPolygon([polygon])
|
|
811
|
+
>>> multi_polygon.contains(Point(1.0, 1.0)) # True
|
|
812
|
+
>>> multi_polygon.contains(Point(3.0, 3.0)) # False
|
|
813
|
+
"""
|
|
814
|
+
@typing.overload
|
|
815
|
+
def contains(self, point_set: PointSet) -> bool:
|
|
816
|
+
"""
|
|
817
|
+
Check if the multi-polygon contains all points in a point set.
|
|
818
|
+
|
|
819
|
+
Args:
|
|
820
|
+
point_set (PointSet): The point set to check for containment.
|
|
821
|
+
|
|
822
|
+
Returns:
|
|
823
|
+
bool: True if the multi-polygon contains all points in the set, False otherwise.
|
|
824
|
+
|
|
825
|
+
Example:
|
|
826
|
+
>>> polygon = Polygon([Point(0.0, 0.0), Point(3.0, 0.0), Point(3.0, 3.0)])
|
|
827
|
+
>>> multi_polygon = MultiPolygon([polygon])
|
|
828
|
+
>>> points = PointSet([Point(1.0, 1.0), Point(2.0, 2.0)])
|
|
829
|
+
>>> multi_polygon.contains(points) # True
|
|
830
|
+
"""
|
|
831
|
+
def get_convex_hull(self) -> Polygon:
|
|
832
|
+
"""
|
|
833
|
+
Compute the convex hull of all polygons in the multi-polygon.
|
|
834
|
+
|
|
835
|
+
Returns:
|
|
836
|
+
Polygon: A polygon representing the convex hull of all vertices.
|
|
837
|
+
|
|
838
|
+
Example:
|
|
839
|
+
>>> polygon1 = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)])
|
|
840
|
+
>>> polygon2 = Polygon([Point(2.0, 2.0), Point(3.0, 2.0), Point(3.0, 3.0)])
|
|
841
|
+
>>> multi_polygon = MultiPolygon([polygon1, polygon2])
|
|
842
|
+
>>> convex_hull = multi_polygon.get_convex_hull()
|
|
843
|
+
"""
|
|
844
|
+
def get_polygon_count(self) -> int:
|
|
845
|
+
"""
|
|
846
|
+
Get the number of polygons in the multi-polygon.
|
|
847
|
+
|
|
848
|
+
Returns:
|
|
849
|
+
int: The number of polygons contained in the multi-polygon.
|
|
850
|
+
|
|
851
|
+
Example:
|
|
852
|
+
>>> polygon1 = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)])
|
|
853
|
+
>>> polygon2 = Polygon([Point(2.0, 2.0), Point(3.0, 2.0), Point(3.0, 3.0)])
|
|
854
|
+
>>> multi_polygon = MultiPolygon([polygon1, polygon2])
|
|
855
|
+
>>> multi_polygon.get_polygon_count() # 2
|
|
856
|
+
"""
|
|
857
|
+
def get_polygons(self) -> list[Polygon]:
|
|
858
|
+
"""
|
|
859
|
+
Get all polygons contained in the multi-polygon.
|
|
860
|
+
|
|
861
|
+
Returns:
|
|
862
|
+
list: List of Polygon objects contained in the multi-polygon.
|
|
863
|
+
|
|
864
|
+
Example:
|
|
865
|
+
>>> polygon1 = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)])
|
|
866
|
+
>>> polygon2 = Polygon([Point(2.0, 2.0), Point(3.0, 2.0), Point(3.0, 3.0)])
|
|
867
|
+
>>> multi_polygon = MultiPolygon([polygon1, polygon2])
|
|
868
|
+
>>> polygons = multi_polygon.get_polygons()
|
|
869
|
+
>>> len(polygons) # 2
|
|
870
|
+
"""
|
|
871
|
+
def is_defined(self) -> bool:
|
|
872
|
+
"""
|
|
873
|
+
Check if the multi-polygon is defined.
|
|
874
|
+
|
|
875
|
+
Returns:
|
|
876
|
+
bool: True if the multi-polygon is defined, False otherwise.
|
|
877
|
+
|
|
878
|
+
Example:
|
|
879
|
+
>>> polygon = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)])
|
|
880
|
+
>>> multi_polygon = MultiPolygon([polygon])
|
|
881
|
+
>>> multi_polygon.is_defined() # True
|
|
882
|
+
"""
|
|
883
|
+
def to_string(self, format: ostk.mathematics.geometry.d2.Object.Format = ..., precision: ostk.core.type.Integer = ...) -> ostk.core.type.String:
|
|
884
|
+
"""
|
|
885
|
+
Convert the multi-polygon to a string representation.
|
|
886
|
+
|
|
887
|
+
Args:
|
|
888
|
+
format (Object.Format, optional): The output format. Defaults to Standard.
|
|
889
|
+
precision (int, optional): The precision for floating point numbers. Defaults to undefined.
|
|
890
|
+
|
|
891
|
+
Returns:
|
|
892
|
+
str: String representation of the multi-polygon.
|
|
893
|
+
|
|
894
|
+
Example:
|
|
895
|
+
>>> polygon = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)])
|
|
896
|
+
>>> multi_polygon = MultiPolygon([polygon])
|
|
897
|
+
>>> multi_polygon.to_string()
|
|
898
|
+
"""
|
|
899
|
+
def union_with(self, multipolygon: MultiPolygon) -> MultiPolygon:
|
|
900
|
+
"""
|
|
901
|
+
Compute the union of this multi-polygon with another multi-polygon.
|
|
902
|
+
|
|
903
|
+
Args:
|
|
904
|
+
multipolygon (MultiPolygon): The multi-polygon to union with.
|
|
905
|
+
|
|
906
|
+
Returns:
|
|
907
|
+
MultiPolygon: A new multi-polygon representing the union.
|
|
908
|
+
|
|
909
|
+
Example:
|
|
910
|
+
>>> polygon1 = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)])
|
|
911
|
+
>>> polygon2 = Polygon([Point(0.5, 0.5), Point(1.5, 0.5), Point(1.5, 1.5)])
|
|
912
|
+
>>> multi1 = MultiPolygon([polygon1])
|
|
913
|
+
>>> multi2 = MultiPolygon([polygon2])
|
|
914
|
+
>>> union_result = multi1.union_with(multi2)
|
|
915
|
+
"""
|
|
916
|
+
class Point(ostk.mathematics.geometry.d2.Object):
|
|
917
|
+
__hash__: typing.ClassVar[None] = None
|
|
918
|
+
@staticmethod
|
|
919
|
+
def origin() -> Point:
|
|
920
|
+
"""
|
|
921
|
+
Create a point at the origin (0, 0).
|
|
922
|
+
|
|
923
|
+
Returns:
|
|
924
|
+
Point: A point at coordinates (0, 0).
|
|
925
|
+
|
|
926
|
+
Example:
|
|
927
|
+
>>> origin = Point.origin()
|
|
928
|
+
>>> origin.x() # 0.0
|
|
929
|
+
>>> origin.y() # 0.0
|
|
930
|
+
"""
|
|
931
|
+
@staticmethod
|
|
932
|
+
def undefined() -> Point:
|
|
933
|
+
"""
|
|
934
|
+
Create an undefined point.
|
|
935
|
+
|
|
936
|
+
Returns:
|
|
937
|
+
Point: An undefined point.
|
|
938
|
+
|
|
939
|
+
Example:
|
|
940
|
+
>>> undefined_point = Point.undefined()
|
|
941
|
+
>>> undefined_point.is_defined() # False
|
|
942
|
+
"""
|
|
943
|
+
@staticmethod
|
|
944
|
+
def vector(vector: numpy.ndarray[numpy.float64[2, 1]]) -> Point:
|
|
945
|
+
"""
|
|
946
|
+
Create a point from a 2D vector.
|
|
947
|
+
|
|
948
|
+
Args:
|
|
949
|
+
vector (np.array): The vector to convert to a point.
|
|
950
|
+
|
|
951
|
+
Returns:
|
|
952
|
+
Point: A point with coordinates from the vector.
|
|
953
|
+
|
|
954
|
+
Example:
|
|
955
|
+
>>> vector = np.array([1.0, 2.0])
|
|
956
|
+
>>> point = Point.vector(vector) # Point(1.0, 2.0)
|
|
957
|
+
"""
|
|
958
|
+
def __add__(self, arg0: numpy.ndarray[numpy.float64[2, 1]]) -> Point:
|
|
959
|
+
...
|
|
960
|
+
def __eq__(self, arg0: Point) -> bool:
|
|
961
|
+
...
|
|
962
|
+
def __init__(self, x: ostk.core.type.Real, y: ostk.core.type.Real) -> None:
|
|
963
|
+
"""
|
|
964
|
+
Create a 2D point with specified coordinates.
|
|
965
|
+
|
|
966
|
+
Args:
|
|
967
|
+
x (float): The x-coordinate.
|
|
968
|
+
y (float): The y-coordinate.
|
|
969
|
+
|
|
970
|
+
Example:
|
|
971
|
+
>>> point = Point(1.0, 2.0)
|
|
972
|
+
>>> point.x() # 1.0
|
|
973
|
+
>>> point.y() # 2.0
|
|
974
|
+
"""
|
|
975
|
+
def __ne__(self, arg0: Point) -> bool:
|
|
976
|
+
...
|
|
977
|
+
def __repr__(self) -> str:
|
|
978
|
+
...
|
|
979
|
+
def __str__(self) -> str:
|
|
980
|
+
...
|
|
981
|
+
@typing.overload
|
|
982
|
+
def __sub__(self, arg0: Point) -> numpy.ndarray[numpy.float64[2, 1]]:
|
|
983
|
+
...
|
|
984
|
+
@typing.overload
|
|
985
|
+
def __sub__(self, arg0: numpy.ndarray[numpy.float64[2, 1]]) -> Point:
|
|
986
|
+
...
|
|
987
|
+
def apply_transformation(self, transformation: typing.Any) -> None:
|
|
988
|
+
"""
|
|
989
|
+
Apply a transformation to the point in place.
|
|
990
|
+
|
|
991
|
+
Args:
|
|
992
|
+
transformation (Transformation): The transformation to apply.
|
|
993
|
+
|
|
994
|
+
Example:
|
|
995
|
+
>>> point = Point(1.0, 2.0)
|
|
996
|
+
>>> transformation = Translation([1.0, 1.0])
|
|
997
|
+
>>> point.apply_transformation(transformation)
|
|
998
|
+
"""
|
|
999
|
+
def as_vector(self) -> numpy.ndarray[numpy.float64[2, 1]]:
|
|
1000
|
+
"""
|
|
1001
|
+
Convert the point to a 2D vector.
|
|
1002
|
+
|
|
1003
|
+
Returns:
|
|
1004
|
+
Vector2d: The point as a 2D vector.
|
|
1005
|
+
|
|
1006
|
+
Example:
|
|
1007
|
+
>>> point = Point(1.0, 2.0)
|
|
1008
|
+
>>> vector = point.as_vector() # np.array([1.0, 2.0])
|
|
1009
|
+
"""
|
|
1010
|
+
def distance_to(self, point: Point) -> ostk.core.type.Real:
|
|
1011
|
+
"""
|
|
1012
|
+
Calculate the distance to another point.
|
|
1013
|
+
|
|
1014
|
+
Args:
|
|
1015
|
+
point (Point): The other point.
|
|
1016
|
+
|
|
1017
|
+
Returns:
|
|
1018
|
+
float: The distance between the points.
|
|
1019
|
+
|
|
1020
|
+
Example:
|
|
1021
|
+
>>> point1 = Point(0.0, 0.0)
|
|
1022
|
+
>>> point2 = Point(3.0, 4.0)
|
|
1023
|
+
>>> point1.distance_to(point2) # 5.0
|
|
1024
|
+
"""
|
|
1025
|
+
def is_defined(self) -> bool:
|
|
1026
|
+
"""
|
|
1027
|
+
Check if the point is defined.
|
|
1028
|
+
|
|
1029
|
+
Returns:
|
|
1030
|
+
bool: True if the point is defined, False otherwise.
|
|
1031
|
+
|
|
1032
|
+
Example:
|
|
1033
|
+
>>> point = Point(1.0, 2.0)
|
|
1034
|
+
>>> point.is_defined() # True
|
|
1035
|
+
"""
|
|
1036
|
+
def is_near(self, point: Point, tolerance: ostk.core.type.Real) -> bool:
|
|
1037
|
+
"""
|
|
1038
|
+
Check if this point is near another point within a tolerance.
|
|
1039
|
+
|
|
1040
|
+
Args:
|
|
1041
|
+
point (Point): The point to compare with.
|
|
1042
|
+
tolerance (float): The tolerance for comparison.
|
|
1043
|
+
|
|
1044
|
+
Returns:
|
|
1045
|
+
bool: True if points are within tolerance, False otherwise.
|
|
1046
|
+
|
|
1047
|
+
Example:
|
|
1048
|
+
>>> point1 = Point(1.0, 2.0)
|
|
1049
|
+
>>> point2 = Point(1.1, 2.1)
|
|
1050
|
+
>>> point1.is_near(point2, 0.2) # True
|
|
1051
|
+
"""
|
|
1052
|
+
def to_string(self, format: ostk.mathematics.geometry.d2.Object.Format = ..., precision: ostk.core.type.Integer = ...) -> ostk.core.type.String:
|
|
1053
|
+
"""
|
|
1054
|
+
Convert the point to a string representation.
|
|
1055
|
+
|
|
1056
|
+
Args:
|
|
1057
|
+
format (Object.Format, optional): The output format. Defaults to Standard.
|
|
1058
|
+
precision (int, optional): The precision for floating point numbers. Defaults to undefined.
|
|
1059
|
+
|
|
1060
|
+
Returns:
|
|
1061
|
+
str: String representation of the point.
|
|
1062
|
+
|
|
1063
|
+
Example:
|
|
1064
|
+
>>> point = Point(1.0, 2.0)
|
|
1065
|
+
>>> point.to_string() # "(1.0, 2.0)"
|
|
1066
|
+
"""
|
|
1067
|
+
def x(self) -> ostk.core.type.Real:
|
|
1068
|
+
"""
|
|
1069
|
+
Get the x-coordinate of the point.
|
|
1070
|
+
|
|
1071
|
+
Returns:
|
|
1072
|
+
float: The x-coordinate.
|
|
1073
|
+
|
|
1074
|
+
Example:
|
|
1075
|
+
>>> point = Point(1.0, 2.0)
|
|
1076
|
+
>>> point.x() # 1.0
|
|
1077
|
+
"""
|
|
1078
|
+
def y(self) -> ostk.core.type.Real:
|
|
1079
|
+
"""
|
|
1080
|
+
Get the y-coordinate of the point.
|
|
1081
|
+
|
|
1082
|
+
Returns:
|
|
1083
|
+
float: The y-coordinate.
|
|
1084
|
+
|
|
1085
|
+
Example:
|
|
1086
|
+
>>> point = Point(1.0, 2.0)
|
|
1087
|
+
>>> point.y() # 2.0
|
|
1088
|
+
"""
|
|
1089
|
+
class PointSet(ostk.mathematics.geometry.d2.Object):
|
|
1090
|
+
__hash__: typing.ClassVar[None] = None
|
|
1091
|
+
@staticmethod
|
|
1092
|
+
def empty() -> PointSet:
|
|
1093
|
+
"""
|
|
1094
|
+
Create an empty point set.
|
|
1095
|
+
|
|
1096
|
+
Returns:
|
|
1097
|
+
PointSet: An empty point set containing no points.
|
|
1098
|
+
|
|
1099
|
+
Example:
|
|
1100
|
+
>>> empty_set = PointSet.empty()
|
|
1101
|
+
>>> empty_set.is_empty() # True
|
|
1102
|
+
>>> empty_set.get_size() # 0
|
|
1103
|
+
"""
|
|
1104
|
+
def __eq__(self, arg0: PointSet) -> bool:
|
|
1105
|
+
...
|
|
1106
|
+
def __getitem__(self, arg0: int) -> Point:
|
|
1107
|
+
"""
|
|
1108
|
+
Access a point by index (Python indexing support).
|
|
1109
|
+
|
|
1110
|
+
Args:
|
|
1111
|
+
index (int): The index of the point to access.
|
|
1112
|
+
|
|
1113
|
+
Returns:
|
|
1114
|
+
Point: The point at the specified index.
|
|
1115
|
+
|
|
1116
|
+
Raises:
|
|
1117
|
+
IndexError: If the index is out of range.
|
|
1118
|
+
|
|
1119
|
+
Example:
|
|
1120
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
1121
|
+
>>> point_set = PointSet(points)
|
|
1122
|
+
>>> first_point = point_set[0] # Point(0.0, 0.0)
|
|
1123
|
+
"""
|
|
1124
|
+
def __init__(self, points: list[Point]) -> None:
|
|
1125
|
+
"""
|
|
1126
|
+
Create a 2D point set from an array of points.
|
|
1127
|
+
|
|
1128
|
+
Args:
|
|
1129
|
+
points (list[Point]): List of Point objects to include in the set.
|
|
1130
|
+
|
|
1131
|
+
Example:
|
|
1132
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0), Point(2.0, 2.0)]
|
|
1133
|
+
>>> point_set = PointSet(points)
|
|
1134
|
+
"""
|
|
1135
|
+
def __iter__(self) -> typing.Iterator[Point]:
|
|
1136
|
+
"""
|
|
1137
|
+
Make the point set iterable (Python for loop support).
|
|
1138
|
+
|
|
1139
|
+
Returns:
|
|
1140
|
+
iterator: An iterator over the points in the set.
|
|
1141
|
+
|
|
1142
|
+
Example:
|
|
1143
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
1144
|
+
>>> point_set = PointSet(points)
|
|
1145
|
+
>>> for point in point_set:
|
|
1146
|
+
... print(point)
|
|
1147
|
+
"""
|
|
1148
|
+
def __len__(self) -> int:
|
|
1149
|
+
"""
|
|
1150
|
+
Get the number of points in the set (Python len() function).
|
|
1151
|
+
|
|
1152
|
+
Returns:
|
|
1153
|
+
int: The number of points in the set.
|
|
1154
|
+
|
|
1155
|
+
Example:
|
|
1156
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
1157
|
+
>>> point_set = PointSet(points)
|
|
1158
|
+
>>> len(point_set) # 2
|
|
1159
|
+
"""
|
|
1160
|
+
def __ne__(self, arg0: PointSet) -> bool:
|
|
1161
|
+
...
|
|
1162
|
+
def __repr__(self) -> str:
|
|
1163
|
+
...
|
|
1164
|
+
def __str__(self) -> str:
|
|
1165
|
+
...
|
|
1166
|
+
def apply_transformation(self, transformation: typing.Any) -> None:
|
|
1167
|
+
"""
|
|
1168
|
+
Apply a transformation to all points in the set.
|
|
1169
|
+
|
|
1170
|
+
Args:
|
|
1171
|
+
transformation (Transformation): The 2D transformation to apply.
|
|
1172
|
+
|
|
1173
|
+
Example:
|
|
1174
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
1175
|
+
>>> point_set = PointSet(points)
|
|
1176
|
+
>>> transformation = Translation([1.0, 1.0])
|
|
1177
|
+
>>> point_set.apply_transformation(transformation)
|
|
1178
|
+
"""
|
|
1179
|
+
def distance_to(self, point: Point) -> ostk.core.type.Real:
|
|
1180
|
+
"""
|
|
1181
|
+
Calculate the distance from the point set to a point.
|
|
1182
|
+
|
|
1183
|
+
Args:
|
|
1184
|
+
point (Point): The point to calculate distance to.
|
|
1185
|
+
|
|
1186
|
+
Returns:
|
|
1187
|
+
float: The minimum distance from any point in the set to the given point.
|
|
1188
|
+
|
|
1189
|
+
Example:
|
|
1190
|
+
>>> points = [Point(0.0, 0.0), Point(2.0, 0.0)]
|
|
1191
|
+
>>> point_set = PointSet(points)
|
|
1192
|
+
>>> distance = point_set.distance_to(Point(1.0, 0.0)) # 1.0
|
|
1193
|
+
"""
|
|
1194
|
+
def get_point_closest_to(self, point: Point) -> Point:
|
|
1195
|
+
"""
|
|
1196
|
+
Get the point in the set that is closest to a given point.
|
|
1197
|
+
|
|
1198
|
+
Args:
|
|
1199
|
+
point (Point): The reference point.
|
|
1200
|
+
|
|
1201
|
+
Returns:
|
|
1202
|
+
Point: The closest point in the set to the given point.
|
|
1203
|
+
|
|
1204
|
+
Example:
|
|
1205
|
+
>>> points = [Point(0.0, 0.0), Point(2.0, 0.0), Point(4.0, 0.0)]
|
|
1206
|
+
>>> point_set = PointSet(points)
|
|
1207
|
+
>>> closest = point_set.get_point_closest_to(Point(1.5, 0.0)) # Point(2.0, 0.0)
|
|
1208
|
+
"""
|
|
1209
|
+
def get_size(self) -> int:
|
|
1210
|
+
"""
|
|
1211
|
+
Get the number of points in the set.
|
|
1212
|
+
|
|
1213
|
+
Returns:
|
|
1214
|
+
int: The number of points in the set.
|
|
1215
|
+
|
|
1216
|
+
Example:
|
|
1217
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0), Point(2.0, 2.0)]
|
|
1218
|
+
>>> point_set = PointSet(points)
|
|
1219
|
+
>>> point_set.get_size() # 3
|
|
1220
|
+
"""
|
|
1221
|
+
def is_defined(self) -> bool:
|
|
1222
|
+
"""
|
|
1223
|
+
Check if the point set is defined.
|
|
1224
|
+
|
|
1225
|
+
Returns:
|
|
1226
|
+
bool: True if the point set is defined, False otherwise.
|
|
1227
|
+
|
|
1228
|
+
Example:
|
|
1229
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
1230
|
+
>>> point_set = PointSet(points)
|
|
1231
|
+
>>> point_set.is_defined() # True
|
|
1232
|
+
"""
|
|
1233
|
+
def is_empty(self) -> bool:
|
|
1234
|
+
"""
|
|
1235
|
+
Check if the point set is empty (contains no points).
|
|
1236
|
+
|
|
1237
|
+
Returns:
|
|
1238
|
+
bool: True if the point set is empty, False otherwise.
|
|
1239
|
+
|
|
1240
|
+
Example:
|
|
1241
|
+
>>> empty_set = PointSet.empty()
|
|
1242
|
+
>>> empty_set.is_empty() # True
|
|
1243
|
+
>>> points = [Point(0.0, 0.0)]
|
|
1244
|
+
>>> point_set = PointSet(points)
|
|
1245
|
+
>>> point_set.is_empty() # False
|
|
1246
|
+
"""
|
|
1247
|
+
def is_near(self, point_set: PointSet, tolerance: ostk.core.type.Real) -> bool:
|
|
1248
|
+
"""
|
|
1249
|
+
Check if this point set is near another point set within tolerance.
|
|
1250
|
+
|
|
1251
|
+
Args:
|
|
1252
|
+
point_set (PointSet): The point set to compare with.
|
|
1253
|
+
tolerance (float): The tolerance for comparison.
|
|
1254
|
+
|
|
1255
|
+
Returns:
|
|
1256
|
+
bool: True if point sets are within tolerance, False otherwise.
|
|
1257
|
+
|
|
1258
|
+
Example:
|
|
1259
|
+
>>> points1 = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
1260
|
+
>>> points2 = [Point(0.1, 0.1), Point(1.1, 1.1)]
|
|
1261
|
+
>>> set1 = PointSet(points1)
|
|
1262
|
+
>>> set2 = PointSet(points2)
|
|
1263
|
+
>>> set1.is_near(set2, 0.2) # True
|
|
1264
|
+
"""
|
|
1265
|
+
def to_string(self, format: ostk.mathematics.geometry.d2.Object.Format = ..., precision: ostk.core.type.Integer = ...) -> ostk.core.type.String:
|
|
1266
|
+
"""
|
|
1267
|
+
Convert the point set to a string representation.
|
|
1268
|
+
|
|
1269
|
+
Args:
|
|
1270
|
+
format (Object.Format, optional): The output format. Defaults to Standard.
|
|
1271
|
+
precision (int, optional): The precision for floating point numbers. Defaults to undefined.
|
|
1272
|
+
|
|
1273
|
+
Returns:
|
|
1274
|
+
str: String representation of the point set.
|
|
1275
|
+
|
|
1276
|
+
Example:
|
|
1277
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
|
|
1278
|
+
>>> point_set = PointSet(points)
|
|
1279
|
+
>>> point_set.to_string()
|
|
1280
|
+
"""
|
|
1281
|
+
class Polygon(ostk.mathematics.geometry.d2.Object):
|
|
1282
|
+
__hash__: typing.ClassVar[None] = None
|
|
1283
|
+
@staticmethod
|
|
1284
|
+
def undefined() -> Polygon:
|
|
1285
|
+
"""
|
|
1286
|
+
Create an undefined polygon.
|
|
1287
|
+
|
|
1288
|
+
Returns:
|
|
1289
|
+
Polygon: An undefined polygon.
|
|
1290
|
+
|
|
1291
|
+
Example:
|
|
1292
|
+
>>> undefined_polygon = Polygon.undefined()
|
|
1293
|
+
>>> undefined_polygon.is_defined() # False
|
|
1294
|
+
"""
|
|
1295
|
+
def __eq__(self, arg0: Polygon) -> bool:
|
|
1296
|
+
...
|
|
1297
|
+
@typing.overload
|
|
1298
|
+
def __init__(self, outer_ring: list[Point], inner_rings: list[list[Point]]) -> None:
|
|
1299
|
+
"""
|
|
1300
|
+
Create a polygon with outer ring and inner rings (holes).
|
|
1301
|
+
|
|
1302
|
+
Args:
|
|
1303
|
+
outer_ring (list[Point]): List of points defining the outer boundary.
|
|
1304
|
+
inner_rings (list[list[Point]]): List of lists of points defining holes.
|
|
1305
|
+
|
|
1306
|
+
Example:
|
|
1307
|
+
>>> outer = [Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0), Point(0.0, 1.0)]
|
|
1308
|
+
>>> inner = [[Point(0.2, 0.2), Point(0.8, 0.2), Point(0.8, 0.8), Point(0.2, 0.8)]]
|
|
1309
|
+
>>> polygon = Polygon(outer, inner)
|
|
1310
|
+
"""
|
|
1311
|
+
@typing.overload
|
|
1312
|
+
def __init__(self, outer_ring: list[Point]) -> None:
|
|
1313
|
+
"""
|
|
1314
|
+
Create a simple polygon with just an outer ring.
|
|
1315
|
+
|
|
1316
|
+
Args:
|
|
1317
|
+
outer_ring (list[Point]): List of points defining the polygon boundary.
|
|
1318
|
+
|
|
1319
|
+
Example:
|
|
1320
|
+
>>> points = [Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0), Point(0.0, 1.0)]
|
|
1321
|
+
>>> polygon = Polygon(points)
|
|
1322
|
+
"""
|
|
1323
|
+
def __ne__(self, arg0: Polygon) -> bool:
|
|
1324
|
+
...
|
|
1325
|
+
def __repr__(self) -> str:
|
|
1326
|
+
...
|
|
1327
|
+
def __str__(self) -> str:
|
|
1328
|
+
...
|
|
1329
|
+
def apply_transformation(self, transformation: typing.Any) -> None:
|
|
1330
|
+
"""
|
|
1331
|
+
Apply a transformation to the polygon in place.
|
|
1332
|
+
|
|
1333
|
+
Args:
|
|
1334
|
+
transformation (Transformation): The transformation to apply.
|
|
1335
|
+
|
|
1336
|
+
Example:
|
|
1337
|
+
>>> polygon = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0), Point(0.0, 1.0)])
|
|
1338
|
+
>>> transformation = Translation([1.0, 1.0])
|
|
1339
|
+
>>> polygon.apply_transformation(transformation)
|
|
1340
|
+
"""
|
|
1341
|
+
@typing.overload
|
|
1342
|
+
def contains(self, point: Point) -> bool:
|
|
1343
|
+
"""
|
|
1344
|
+
Check if the polygon contains a point.
|
|
1345
|
+
|
|
1346
|
+
Args:
|
|
1347
|
+
point (Point): The point to check.
|
|
1348
|
+
|
|
1349
|
+
Returns:
|
|
1350
|
+
bool: True if the polygon contains the point, False otherwise.
|
|
1351
|
+
|
|
1352
|
+
Example:
|
|
1353
|
+
>>> polygon = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0), Point(0.0, 1.0)])
|
|
1354
|
+
>>> polygon.contains(Point(0.5, 0.5)) # True
|
|
1355
|
+
"""
|
|
1356
|
+
@typing.overload
|
|
1357
|
+
def contains(self, point_set: PointSet) -> bool:
|
|
1358
|
+
"""
|
|
1359
|
+
Check if the polygon contains a point set.
|
|
1360
|
+
|
|
1361
|
+
Args:
|
|
1362
|
+
point_set (PointSet): The point set to check.
|
|
1363
|
+
|
|
1364
|
+
Returns:
|
|
1365
|
+
bool: True if the polygon contains the point set, False otherwise.
|
|
1366
|
+
|
|
1367
|
+
Example:
|
|
1368
|
+
>>> polygon = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0), Point(0.0, 1.0)])
|
|
1369
|
+
>>> point_set = PointSet([Point(0.5, 0.5), Point(1.5, 0.5), Point(1.5, 1.5)])
|
|
1370
|
+
>>> polygon.contains(point_set) # True
|
|
1371
|
+
"""
|
|
1372
|
+
def difference_with(self, polygon: Polygon) -> ...:
|
|
1373
|
+
"""
|
|
1374
|
+
Get the difference of the polygon with another polygon.
|
|
1375
|
+
|
|
1376
|
+
Args:
|
|
1377
|
+
polygon (Polygon): The polygon to check difference with.
|
|
1378
|
+
|
|
1379
|
+
Returns:
|
|
1380
|
+
Intersection: The difference of the polygon with another polygon.
|
|
1381
|
+
|
|
1382
|
+
Example:
|
|
1383
|
+
>>> polygon1 = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)])
|
|
1384
|
+
>>> polygon2 = Polygon([Point(0.01, 0.01), Point(1.01, 0.01), Point(1.01, 1.01)])
|
|
1385
|
+
>>> polygon1.difference_with(polygon2) # Intersection
|
|
1386
|
+
"""
|
|
1387
|
+
def get_convex_hull(self) -> Polygon:
|
|
1388
|
+
"""
|
|
1389
|
+
Get the convex hull of the polygon.
|
|
1390
|
+
|
|
1391
|
+
Returns:
|
|
1392
|
+
Polygon: The convex hull of the polygon.
|
|
1393
|
+
|
|
1394
|
+
Example:
|
|
1395
|
+
>>> polygon = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0), Point(0.0, 1.0)])
|
|
1396
|
+
>>> polygon.get_convex_hull()
|
|
1397
|
+
"""
|
|
1398
|
+
def get_edge_at(self, index: int) -> Segment:
|
|
1399
|
+
"""
|
|
1400
|
+
Get the edge at the given index.
|
|
1401
|
+
|
|
1402
|
+
Args:
|
|
1403
|
+
index (int): The index of the edge.
|
|
1404
|
+
|
|
1405
|
+
Returns:
|
|
1406
|
+
Polygon.Edge: The edge at the given index.
|
|
1407
|
+
|
|
1408
|
+
Example:
|
|
1409
|
+
>>> polygon = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0), Point(0.0, 1.0)])
|
|
1410
|
+
>>> polygon.get_edge_at(0)
|
|
1411
|
+
"""
|
|
1412
|
+
def get_edge_count(self) -> int:
|
|
1413
|
+
"""
|
|
1414
|
+
Get the number of edges in the polygon.
|
|
1415
|
+
|
|
1416
|
+
Returns:
|
|
1417
|
+
int: The number of edges.
|
|
1418
|
+
|
|
1419
|
+
Example:
|
|
1420
|
+
>>> polygon = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0), Point(0.0, 1.0)])
|
|
1421
|
+
>>> polygon.get_edge_count() # 4
|
|
1422
|
+
"""
|
|
1423
|
+
def get_edges(self) -> list[Segment]:
|
|
1424
|
+
"""
|
|
1425
|
+
Get all edges of the polygon.
|
|
1426
|
+
|
|
1427
|
+
Returns:
|
|
1428
|
+
list: List of all edges in the polygon.
|
|
1429
|
+
|
|
1430
|
+
Example:
|
|
1431
|
+
>>> polygon = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0), Point(0.0, 1.0)])
|
|
1432
|
+
>>> polygon.get_edges()
|
|
1433
|
+
"""
|
|
1434
|
+
def get_inner_ring_at(self, arg0: int) -> LineString:
|
|
1435
|
+
"""
|
|
1436
|
+
Get the inner ring at the given index.
|
|
1437
|
+
|
|
1438
|
+
Args:
|
|
1439
|
+
index (int): The index of the inner ring.
|
|
1440
|
+
|
|
1441
|
+
Returns:
|
|
1442
|
+
Polygon.Ring: The inner ring at the given index.
|
|
1443
|
+
|
|
1444
|
+
Example:
|
|
1445
|
+
>>> polygon = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0), Point(0.0, 1.0)])
|
|
1446
|
+
>>> polygon.get_inner_ring_at(0)
|
|
1447
|
+
"""
|
|
1448
|
+
def get_inner_ring_count(self) -> int:
|
|
1449
|
+
"""
|
|
1450
|
+
Get the number of inner rings in the polygon.
|
|
1451
|
+
|
|
1452
|
+
Returns:
|
|
1453
|
+
int: The number of inner rings.
|
|
1454
|
+
|
|
1455
|
+
Example:
|
|
1456
|
+
>>> polygon = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0), Point(0.0, 1.0)])
|
|
1457
|
+
>>> polygon.get_inner_ring_count() # 0
|
|
1458
|
+
"""
|
|
1459
|
+
def get_outer_ring(self) -> LineString:
|
|
1460
|
+
"""
|
|
1461
|
+
Get the outer ring of the polygon.
|
|
1462
|
+
|
|
1463
|
+
Returns:
|
|
1464
|
+
Polygon.Ring: The outer ring of the polygon.
|
|
1465
|
+
|
|
1466
|
+
Example:
|
|
1467
|
+
>>> polygon = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0), Point(0.0, 1.0)])
|
|
1468
|
+
>>> polygon.get_outer_ring()
|
|
1469
|
+
"""
|
|
1470
|
+
def get_vertex_at(self, index: int) -> Point:
|
|
1471
|
+
"""
|
|
1472
|
+
Get the vertex at the given index.
|
|
1473
|
+
|
|
1474
|
+
Args:
|
|
1475
|
+
index (int): The index of the vertex.
|
|
1476
|
+
|
|
1477
|
+
Returns:
|
|
1478
|
+
Polygon.Vertex: The vertex at the given index.
|
|
1479
|
+
|
|
1480
|
+
Example:
|
|
1481
|
+
>>> polygon = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0), Point(0.0, 1.0)])
|
|
1482
|
+
>>> polygon.get_vertex_at(0)
|
|
1483
|
+
"""
|
|
1484
|
+
def get_vertex_count(self) -> int:
|
|
1485
|
+
"""
|
|
1486
|
+
Get the total number of vertices in the polygon.
|
|
1487
|
+
|
|
1488
|
+
Returns:
|
|
1489
|
+
int: The number of vertices.
|
|
1490
|
+
|
|
1491
|
+
Example:
|
|
1492
|
+
>>> polygon = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0), Point(0.0, 1.0)])
|
|
1493
|
+
>>> polygon.get_vertex_count() # 4
|
|
1494
|
+
"""
|
|
1495
|
+
def get_vertices(self) -> list[Point]:
|
|
1496
|
+
"""
|
|
1497
|
+
Get all vertices of the polygon.
|
|
1498
|
+
|
|
1499
|
+
Returns:
|
|
1500
|
+
list: List of all vertices in the polygon.
|
|
1501
|
+
|
|
1502
|
+
Example:
|
|
1503
|
+
>>> polygon = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)])
|
|
1504
|
+
>>> vertices = polygon.get_vertices()
|
|
1505
|
+
"""
|
|
1506
|
+
def intersection_with(self, polygon: Polygon) -> ...:
|
|
1507
|
+
"""
|
|
1508
|
+
Get the intersection of the polygon with another polygon.
|
|
1509
|
+
|
|
1510
|
+
Args:
|
|
1511
|
+
polygon (Polygon): The polygon to check intersection with.
|
|
1512
|
+
|
|
1513
|
+
Returns:
|
|
1514
|
+
Intersection: The intersection of the polygon with another polygon.
|
|
1515
|
+
|
|
1516
|
+
Example:
|
|
1517
|
+
>>> polygon1 = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)])
|
|
1518
|
+
>>> polygon2 = Polygon([Point(0.01, 0.01), Point(1.01, 0.01), Point(1.01, 1.01)])
|
|
1519
|
+
>>> polygon1.intersection_with(polygon2) # Intersection
|
|
1520
|
+
"""
|
|
1521
|
+
def intersects(self, polygon: Polygon) -> bool:
|
|
1522
|
+
"""
|
|
1523
|
+
Check if the polygon intersects another polygon.
|
|
1524
|
+
|
|
1525
|
+
Args:
|
|
1526
|
+
polygon (Polygon): The polygon to check intersection with.
|
|
1527
|
+
|
|
1528
|
+
Returns:
|
|
1529
|
+
bool: True if the polygons intersect, False otherwise.
|
|
1530
|
+
|
|
1531
|
+
Example:
|
|
1532
|
+
>>> polygon1 = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)])
|
|
1533
|
+
>>> polygon2 = Polygon([Point(0.01, 0.01), Point(1.01, 0.01), Point(1.01, 1.01)])
|
|
1534
|
+
>>> polygon1.intersects(polygon2) # True
|
|
1535
|
+
"""
|
|
1536
|
+
def is_defined(self) -> bool:
|
|
1537
|
+
"""
|
|
1538
|
+
Check if the polygon is defined.
|
|
1539
|
+
|
|
1540
|
+
Returns:
|
|
1541
|
+
bool: True if the polygon is defined, False otherwise.
|
|
1542
|
+
|
|
1543
|
+
Example:
|
|
1544
|
+
>>> polygon = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)])
|
|
1545
|
+
>>> polygon.is_defined() # True
|
|
1546
|
+
"""
|
|
1547
|
+
def is_near(self, polygon: Polygon, tolerance: ostk.core.type.Real) -> bool:
|
|
1548
|
+
"""
|
|
1549
|
+
Check if this polygon is near another polygon within tolerance.
|
|
1550
|
+
|
|
1551
|
+
Args:
|
|
1552
|
+
polygon (Polygon): The polygon to compare with.
|
|
1553
|
+
tolerance (float): The tolerance for comparison.
|
|
1554
|
+
|
|
1555
|
+
Returns:
|
|
1556
|
+
bool: True if polygons are within tolerance, False otherwise.
|
|
1557
|
+
|
|
1558
|
+
Example:
|
|
1559
|
+
>>> polygon1 = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)])
|
|
1560
|
+
>>> polygon2 = Polygon([Point(0.01, 0.01), Point(1.01, 0.01), Point(1.01, 1.01)])
|
|
1561
|
+
>>> polygon1.is_near(polygon2, 0.1) # True
|
|
1562
|
+
"""
|
|
1563
|
+
def to_string(self, format: ostk.mathematics.geometry.d2.Object.Format = ..., precision: ostk.core.type.Integer = ...) -> ostk.core.type.String:
|
|
1564
|
+
"""
|
|
1565
|
+
Get the string representation of the polygon.
|
|
1566
|
+
|
|
1567
|
+
Args:
|
|
1568
|
+
format (Object.Format, optional): The output format. Defaults to Standard.
|
|
1569
|
+
precision (int, optional): The precision for floating point numbers. Defaults to undefined.
|
|
1570
|
+
|
|
1571
|
+
Returns:
|
|
1572
|
+
str: String representation of the polygon.
|
|
1573
|
+
|
|
1574
|
+
Example:
|
|
1575
|
+
>>> polygon = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0), Point(0.0, 1.0)])
|
|
1576
|
+
>>> polygon.to_string()
|
|
1577
|
+
"""
|
|
1578
|
+
def union_with(self, polygon: Polygon) -> ...:
|
|
1579
|
+
"""
|
|
1580
|
+
Get the union of the polygon with another polygon.
|
|
1581
|
+
|
|
1582
|
+
Args:
|
|
1583
|
+
polygon (Polygon): The polygon to union with.
|
|
1584
|
+
|
|
1585
|
+
Returns:
|
|
1586
|
+
Polygon: The union of the polygon with another polygon.
|
|
1587
|
+
|
|
1588
|
+
Example:
|
|
1589
|
+
>>> polygon1 = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0), Point(0.0, 1.0)])
|
|
1590
|
+
>>> polygon2 = Polygon([Point(0.01, 0.01), Point(1.01, 0.01), Point(1.01, 1.01), Point(0.01, 1.01)])
|
|
1591
|
+
>>> polygon1.union_with(polygon2)
|
|
1592
|
+
"""
|
|
1593
|
+
class Segment(ostk.mathematics.geometry.d2.Object):
|
|
1594
|
+
__hash__: typing.ClassVar[None] = None
|
|
1595
|
+
@staticmethod
|
|
1596
|
+
def undefined() -> Segment:
|
|
1597
|
+
"""
|
|
1598
|
+
Create an undefined segment.
|
|
1599
|
+
|
|
1600
|
+
Returns:
|
|
1601
|
+
Segment: An undefined segment object.
|
|
1602
|
+
|
|
1603
|
+
Example:
|
|
1604
|
+
>>> undefined_segment = Segment.undefined()
|
|
1605
|
+
>>> undefined_segment.is_defined() # False
|
|
1606
|
+
"""
|
|
1607
|
+
def __eq__(self, arg0: Segment) -> bool:
|
|
1608
|
+
...
|
|
1609
|
+
def __init__(self, start_point: Point, end_point: Point) -> None:
|
|
1610
|
+
"""
|
|
1611
|
+
Create a 2D segment defined by two endpoints.
|
|
1612
|
+
|
|
1613
|
+
Args:
|
|
1614
|
+
start_point (Point): The starting point of the segment.
|
|
1615
|
+
end_point (Point): The ending point of the segment.
|
|
1616
|
+
|
|
1617
|
+
Example:
|
|
1618
|
+
>>> start = Point(0.0, 0.0)
|
|
1619
|
+
>>> end = Point(1.0, 1.0)
|
|
1620
|
+
>>> segment = Segment(start, end)
|
|
1621
|
+
"""
|
|
1622
|
+
def __ne__(self, arg0: Segment) -> bool:
|
|
1623
|
+
...
|
|
1624
|
+
def __repr__(self) -> str:
|
|
1625
|
+
...
|
|
1626
|
+
def __str__(self) -> str:
|
|
1627
|
+
...
|
|
1628
|
+
def apply_transformation(self, transformation: typing.Any) -> None:
|
|
1629
|
+
"""
|
|
1630
|
+
Apply a transformation to the segment in place.
|
|
1631
|
+
|
|
1632
|
+
Args:
|
|
1633
|
+
transformation (Transformation): The 2D transformation to apply.
|
|
1634
|
+
|
|
1635
|
+
Example:
|
|
1636
|
+
>>> segment = Segment(Point(0.0, 0.0), Point(1.0, 1.0))
|
|
1637
|
+
>>> transformation = Translation([1.0, 1.0])
|
|
1638
|
+
>>> segment.apply_transformation(transformation)
|
|
1639
|
+
"""
|
|
1640
|
+
@typing.overload
|
|
1641
|
+
def distance_to(self, point: Point) -> ostk.core.type.Real:
|
|
1642
|
+
"""
|
|
1643
|
+
Calculate the distance from the segment to a point.
|
|
1644
|
+
|
|
1645
|
+
Args:
|
|
1646
|
+
point (Point): The point to calculate distance to.
|
|
1647
|
+
|
|
1648
|
+
Returns:
|
|
1649
|
+
float: The minimum distance from the segment to the point.
|
|
1650
|
+
|
|
1651
|
+
Example:
|
|
1652
|
+
>>> segment = Segment(Point(0.0, 0.0), Point(2.0, 0.0))
|
|
1653
|
+
>>> distance = segment.distance_to(Point(1.0, 1.0)) # 1.0
|
|
1654
|
+
"""
|
|
1655
|
+
@typing.overload
|
|
1656
|
+
def distance_to(self, point_set: PointSet) -> ostk.core.type.Real:
|
|
1657
|
+
"""
|
|
1658
|
+
Calculate the distance from the segment to a point set.
|
|
1659
|
+
|
|
1660
|
+
Args:
|
|
1661
|
+
point_set (PointSet): The point set to calculate distance to.
|
|
1662
|
+
|
|
1663
|
+
Returns:
|
|
1664
|
+
float: The minimum distance from the segment to any point in the set.
|
|
1665
|
+
|
|
1666
|
+
Example:
|
|
1667
|
+
>>> segment = Segment(Point(0.0, 0.0), Point(2.0, 0.0))
|
|
1668
|
+
>>> points = PointSet([Point(1.0, 1.0), Point(3.0, 1.0)])
|
|
1669
|
+
>>> distance = segment.distance_to(points) # 1.0
|
|
1670
|
+
"""
|
|
1671
|
+
def get_center(self) -> Point:
|
|
1672
|
+
"""
|
|
1673
|
+
Get the center (midpoint) of the segment.
|
|
1674
|
+
|
|
1675
|
+
Returns:
|
|
1676
|
+
Point: The center point of the segment.
|
|
1677
|
+
|
|
1678
|
+
Example:
|
|
1679
|
+
>>> segment = Segment(Point(0.0, 0.0), Point(2.0, 2.0))
|
|
1680
|
+
>>> center = segment.get_center() # Point(1.0, 1.0)
|
|
1681
|
+
"""
|
|
1682
|
+
def get_direction(self) -> numpy.ndarray[numpy.float64[2, 1]]:
|
|
1683
|
+
"""
|
|
1684
|
+
Get the direction vector of the segment (from start to end, normalized).
|
|
1685
|
+
|
|
1686
|
+
Returns:
|
|
1687
|
+
Vector2d: The normalized direction vector of the segment.
|
|
1688
|
+
|
|
1689
|
+
Example:
|
|
1690
|
+
>>> segment = Segment(Point(0.0, 0.0), Point(3.0, 4.0))
|
|
1691
|
+
>>> direction = segment.get_direction() # [0.6, 0.8]
|
|
1692
|
+
"""
|
|
1693
|
+
def get_first_point(self) -> Point:
|
|
1694
|
+
"""
|
|
1695
|
+
Get the first (starting) point of the segment.
|
|
1696
|
+
|
|
1697
|
+
Returns:
|
|
1698
|
+
Point: The starting point of the segment.
|
|
1699
|
+
|
|
1700
|
+
Example:
|
|
1701
|
+
>>> segment = Segment(Point(0.0, 0.0), Point(1.0, 1.0))
|
|
1702
|
+
>>> start = segment.get_first_point() # Point(0.0, 0.0)
|
|
1703
|
+
"""
|
|
1704
|
+
def get_length(self) -> ostk.core.type.Real:
|
|
1705
|
+
"""
|
|
1706
|
+
Get the length of the segment.
|
|
1707
|
+
|
|
1708
|
+
Returns:
|
|
1709
|
+
float: The length of the segment.
|
|
1710
|
+
|
|
1711
|
+
Example:
|
|
1712
|
+
>>> segment = Segment(Point(0.0, 0.0), Point(3.0, 4.0))
|
|
1713
|
+
>>> length = segment.get_length() # 5.0
|
|
1714
|
+
"""
|
|
1715
|
+
def get_second_point(self) -> Point:
|
|
1716
|
+
"""
|
|
1717
|
+
Get the second (ending) point of the segment.
|
|
1718
|
+
|
|
1719
|
+
Returns:
|
|
1720
|
+
Point: The ending point of the segment.
|
|
1721
|
+
|
|
1722
|
+
Example:
|
|
1723
|
+
>>> segment = Segment(Point(0.0, 0.0), Point(1.0, 1.0))
|
|
1724
|
+
>>> end = segment.get_second_point() # Point(1.0, 1.0)
|
|
1725
|
+
"""
|
|
1726
|
+
def is_defined(self) -> bool:
|
|
1727
|
+
"""
|
|
1728
|
+
Check if the segment is defined.
|
|
1729
|
+
|
|
1730
|
+
Returns:
|
|
1731
|
+
bool: True if the segment is defined, False otherwise.
|
|
1732
|
+
|
|
1733
|
+
Example:
|
|
1734
|
+
>>> segment = Segment(Point(0.0, 0.0), Point(1.0, 1.0))
|
|
1735
|
+
>>> segment.is_defined() # True
|
|
1736
|
+
"""
|
|
1737
|
+
def is_degenerate(self) -> bool:
|
|
1738
|
+
"""
|
|
1739
|
+
Check if the segment is degenerate (start and end points are the same).
|
|
1740
|
+
|
|
1741
|
+
Returns:
|
|
1742
|
+
bool: True if the segment is degenerate, False otherwise.
|
|
1743
|
+
|
|
1744
|
+
Example:
|
|
1745
|
+
>>> segment = Segment(Point(1.0, 1.0), Point(1.0, 1.0))
|
|
1746
|
+
>>> segment.is_degenerate() # True
|
|
1747
|
+
>>> segment2 = Segment(Point(0.0, 0.0), Point(1.0, 1.0))
|
|
1748
|
+
>>> segment2.is_degenerate() # False
|
|
1749
|
+
"""
|
|
1750
|
+
def to_line(self) -> Line:
|
|
1751
|
+
"""
|
|
1752
|
+
Convert the segment to an infinite line.
|
|
1753
|
+
|
|
1754
|
+
Returns:
|
|
1755
|
+
Line: A line that passes through both endpoints of the segment.
|
|
1756
|
+
|
|
1757
|
+
Example:
|
|
1758
|
+
>>> segment = Segment(Point(0.0, 0.0), Point(1.0, 1.0))
|
|
1759
|
+
>>> line = segment.to_line()
|
|
1760
|
+
"""
|
|
1761
|
+
def to_string(self, format: ostk.mathematics.geometry.d2.Object.Format = ..., precision: ostk.core.type.Integer = ...) -> ostk.core.type.String:
|
|
1762
|
+
"""
|
|
1763
|
+
Convert the segment to a string representation.
|
|
1764
|
+
|
|
1765
|
+
Args:
|
|
1766
|
+
format (Object.Format, optional): The output format. Defaults to Standard.
|
|
1767
|
+
precision (int, optional): The precision for floating point numbers. Defaults to undefined.
|
|
1768
|
+
|
|
1769
|
+
Returns:
|
|
1770
|
+
str: String representation of the segment.
|
|
1771
|
+
|
|
1772
|
+
Example:
|
|
1773
|
+
>>> segment = Segment(Point(0.0, 0.0), Point(1.0, 1.0))
|
|
1774
|
+
>>> segment.to_string()
|
|
1775
|
+
"""
|
|
1776
|
+
def set_point_2_array(arg0: list[list[Point]]) -> None:
|
|
1777
|
+
...
|
|
1778
|
+
def set_point_array(arg0: list[Point]) -> None:
|
|
1779
|
+
...
|