scikit-spatial 7.1.0__tar.gz → 7.2.0__tar.gz
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.
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/PKG-INFO +1 -1
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/pyproject.toml +1 -1
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/src/skspatial/__init__.py +7 -2
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/src/skspatial/objects/line.py +77 -0
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/src/skspatial/objects/plane.py +93 -0
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/LICENSE +0 -0
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/README.rst +0 -0
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/src/skspatial/_functions.py +0 -0
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/src/skspatial/measurement.py +0 -0
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/src/skspatial/objects/__init__.py +0 -0
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/src/skspatial/objects/_base_array.py +0 -0
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/src/skspatial/objects/_base_line_plane.py +0 -0
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/src/skspatial/objects/_base_spatial.py +0 -0
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/src/skspatial/objects/_base_sphere.py +0 -0
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/src/skspatial/objects/_mixins.py +0 -0
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/src/skspatial/objects/circle.py +0 -0
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/src/skspatial/objects/cylinder.py +0 -0
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/src/skspatial/objects/line_segment.py +0 -0
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/src/skspatial/objects/point.py +0 -0
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/src/skspatial/objects/points.py +0 -0
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/src/skspatial/objects/sphere.py +0 -0
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/src/skspatial/objects/triangle.py +0 -0
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/src/skspatial/objects/vector.py +0 -0
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/src/skspatial/plotting.py +0 -0
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/src/skspatial/py.typed +0 -0
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/src/skspatial/transformation.py +0 -0
- {scikit_spatial-7.1.0 → scikit_spatial-7.2.0}/src/skspatial/typing.py +0 -0
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"""Top-level package for scikit-spatial."""
|
|
2
2
|
|
|
3
|
-
import importlib.metadata as importlib_metadata # type: ignore
|
|
4
|
-
|
|
5
3
|
__author__ = "Andrew Hynes"
|
|
6
4
|
__email__ = "andrewjhynes@gmail.com"
|
|
5
|
+
|
|
6
|
+
try:
|
|
7
|
+
import importlib.metadata as importlib_metadata # type: ignore
|
|
8
|
+
|
|
9
|
+
except ModuleNotFoundError:
|
|
10
|
+
import importlib_metadata # type: ignore
|
|
11
|
+
|
|
7
12
|
__version__ = importlib_metadata.version("scikit-spatial")
|
|
@@ -302,6 +302,46 @@ class Line(_BaseLinePlane):
|
|
|
302
302
|
# Add the projected vector to the point on the line.
|
|
303
303
|
return self.point + vector_projected
|
|
304
304
|
|
|
305
|
+
def project_points(self, points: array_like) -> Points:
|
|
306
|
+
"""
|
|
307
|
+
Project multiple points onto the line.
|
|
308
|
+
|
|
309
|
+
Parameters
|
|
310
|
+
----------
|
|
311
|
+
points : array_like
|
|
312
|
+
Input points.
|
|
313
|
+
|
|
314
|
+
Returns
|
|
315
|
+
-------
|
|
316
|
+
Points
|
|
317
|
+
Projection of the points onto the line.
|
|
318
|
+
|
|
319
|
+
Examples
|
|
320
|
+
--------
|
|
321
|
+
>>> from skspatial.objects import Line
|
|
322
|
+
|
|
323
|
+
>>> line = Line([0, 0], [0, 1])
|
|
324
|
+
>>> line.project_points([[0, 5], [1,5], [0, 1], [1, 0], [0, 2], [-15, 5], [ 50, 10]])
|
|
325
|
+
Points([[ 0., 5.],
|
|
326
|
+
[ 0., 5.],
|
|
327
|
+
[ 0., 1.],
|
|
328
|
+
[ 0., 0.],
|
|
329
|
+
[ 0., 2.],
|
|
330
|
+
[ 0., 5.],
|
|
331
|
+
[ 0., 10.]])
|
|
332
|
+
|
|
333
|
+
"""
|
|
334
|
+
# Vectors from the points on the line to the point in space.
|
|
335
|
+
vectors = np.subtract(points, self.point)
|
|
336
|
+
|
|
337
|
+
# Project the vectors onto the line.
|
|
338
|
+
dot_products = np.dot(vectors, self.direction.unit())
|
|
339
|
+
|
|
340
|
+
# Add the projected vector to the point on the line.
|
|
341
|
+
projected_points = Points(dot_products[:, np.newaxis] * self.direction.unit() + self.point)
|
|
342
|
+
|
|
343
|
+
return projected_points
|
|
344
|
+
|
|
305
345
|
def project_vector(self, vector: array_like) -> Vector:
|
|
306
346
|
"""
|
|
307
347
|
Project a vector onto the line.
|
|
@@ -409,6 +449,43 @@ class Line(_BaseLinePlane):
|
|
|
409
449
|
|
|
410
450
|
return point_projected.distance_point(point)
|
|
411
451
|
|
|
452
|
+
def distance_points(self, points: array_like) -> np.ndarray:
|
|
453
|
+
"""
|
|
454
|
+
Return the distances from points to the line.
|
|
455
|
+
|
|
456
|
+
These are the distances from the points to their projections on the line.
|
|
457
|
+
|
|
458
|
+
Parameters
|
|
459
|
+
----------
|
|
460
|
+
points : array_like
|
|
461
|
+
Input points.
|
|
462
|
+
|
|
463
|
+
Returns
|
|
464
|
+
-------
|
|
465
|
+
np.ndarray
|
|
466
|
+
Distances from the points to the line.
|
|
467
|
+
|
|
468
|
+
Examples
|
|
469
|
+
--------
|
|
470
|
+
>>> import numpy as np
|
|
471
|
+
>>> from skspatial.objects import Line
|
|
472
|
+
|
|
473
|
+
>>> line = Line([0, 0], [0, 1])
|
|
474
|
+
>>> line.distance_points([[0, 5], [1,5], [0, 1], [1, 0], [0, 2], [-15, 5], [ 50, 10]])
|
|
475
|
+
array([ 0., 1., 0., 1., 0., 15., 50.])
|
|
476
|
+
|
|
477
|
+
>>> line = Line([0, 0, 0], [0, 0, 1])
|
|
478
|
+
>>> points = Points([[14, -8, 19], [16, 15, 11], [11, 19, 13], [-1,-18, 8], [-17, 1, 11]])
|
|
479
|
+
>>> np.round(line.distance_points(points), 3)
|
|
480
|
+
array([16.125, 21.932, 21.954, 18.028, 17.029])
|
|
481
|
+
|
|
482
|
+
"""
|
|
483
|
+
projected_points = self.project_points(points)
|
|
484
|
+
|
|
485
|
+
distances = np.linalg.norm(points - projected_points, axis=1)
|
|
486
|
+
|
|
487
|
+
return distances
|
|
488
|
+
|
|
412
489
|
def distance_line(self, other: Line) -> np.float64:
|
|
413
490
|
"""
|
|
414
491
|
Return the shortest distance from the line to another.
|
|
@@ -273,6 +273,37 @@ class Plane(_BaseLinePlane, _ToPointsMixin):
|
|
|
273
273
|
|
|
274
274
|
return Point(point) + vector_projected
|
|
275
275
|
|
|
276
|
+
def project_points(self, points: array_like) -> Points:
|
|
277
|
+
"""
|
|
278
|
+
Project multiple points onto the plane.
|
|
279
|
+
|
|
280
|
+
Parameters
|
|
281
|
+
----------
|
|
282
|
+
points : array_like
|
|
283
|
+
Input points.
|
|
284
|
+
|
|
285
|
+
Returns
|
|
286
|
+
-------
|
|
287
|
+
Points
|
|
288
|
+
Projections of the points onto the plane.
|
|
289
|
+
|
|
290
|
+
Examples
|
|
291
|
+
--------
|
|
292
|
+
>>> from skspatial.objects import Plane
|
|
293
|
+
|
|
294
|
+
>>> plane = Plane(point=[0, 0, 0], normal=[0, 0, 2])
|
|
295
|
+
|
|
296
|
+
>>> plane.project_points([[10, 2, 5],[1, 2, 3]])
|
|
297
|
+
Points([[10., 2., 0.],
|
|
298
|
+
[ 1., 2., 0.]])
|
|
299
|
+
|
|
300
|
+
"""
|
|
301
|
+
vectors = np.subtract(self.point, points)
|
|
302
|
+
|
|
303
|
+
dot_products = np.dot(vectors, self.normal.unit())
|
|
304
|
+
|
|
305
|
+
return Points(dot_products[:, np.newaxis] * self.normal.unit() + points)
|
|
306
|
+
|
|
276
307
|
def project_vector(self, vector: array_like) -> Vector:
|
|
277
308
|
"""
|
|
278
309
|
Project a vector onto the plane.
|
|
@@ -392,6 +423,38 @@ class Plane(_BaseLinePlane, _ToPointsMixin):
|
|
|
392
423
|
|
|
393
424
|
return self.normal.scalar_projection(vector_to_point)
|
|
394
425
|
|
|
426
|
+
def distance_points_signed(self, points: array_like) -> np.ndarray:
|
|
427
|
+
"""
|
|
428
|
+
Return the signed distances from multiple points to the plane.
|
|
429
|
+
|
|
430
|
+
Parameters
|
|
431
|
+
----------
|
|
432
|
+
points : array_like
|
|
433
|
+
Input points.
|
|
434
|
+
|
|
435
|
+
Returns
|
|
436
|
+
-------
|
|
437
|
+
np.ndarray
|
|
438
|
+
Signed distances from the points to the plane.
|
|
439
|
+
|
|
440
|
+
References
|
|
441
|
+
----------
|
|
442
|
+
http://mathworld.wolfram.com/Point-PlaneDistance.html
|
|
443
|
+
|
|
444
|
+
Examples
|
|
445
|
+
--------
|
|
446
|
+
>>> from skspatial.objects import Plane
|
|
447
|
+
|
|
448
|
+
>>> plane = Plane([0, 0, 0], [0, 0, 1])
|
|
449
|
+
|
|
450
|
+
>>> plane.distance_points_signed([[5, 2, 0], [5, 2, 1], [5, 2, -4], [5, 2, -4]])
|
|
451
|
+
array([ 0., 1., -4., -4.])
|
|
452
|
+
|
|
453
|
+
"""
|
|
454
|
+
vectors = np.subtract(points, self.point)
|
|
455
|
+
|
|
456
|
+
return np.array(np.dot(vectors, self.normal.unit()))
|
|
457
|
+
|
|
395
458
|
def distance_point(self, point: array_like) -> np.float64:
|
|
396
459
|
"""
|
|
397
460
|
Return the distance from a point to the plane.
|
|
@@ -428,6 +491,36 @@ class Plane(_BaseLinePlane, _ToPointsMixin):
|
|
|
428
491
|
"""
|
|
429
492
|
return abs(self.distance_point_signed(point))
|
|
430
493
|
|
|
494
|
+
def distance_points(self, point: array_like) -> np.ndarray:
|
|
495
|
+
"""
|
|
496
|
+
Return the distances from multiple points to the plane.
|
|
497
|
+
|
|
498
|
+
Parameters
|
|
499
|
+
----------
|
|
500
|
+
points : array_like
|
|
501
|
+
Input points.
|
|
502
|
+
|
|
503
|
+
Returns
|
|
504
|
+
-------
|
|
505
|
+
np.ndarray
|
|
506
|
+
Distances from the points to the plane.
|
|
507
|
+
|
|
508
|
+
References
|
|
509
|
+
----------
|
|
510
|
+
http://mathworld.wolfram.com/Point-PlaneDistance.html
|
|
511
|
+
|
|
512
|
+
Examples
|
|
513
|
+
--------
|
|
514
|
+
>>> from skspatial.objects import Plane
|
|
515
|
+
|
|
516
|
+
>>> plane = Plane([0, 0, 0], [0, 0, 1])
|
|
517
|
+
|
|
518
|
+
>>> plane.distance_points([[5, 2, 0], [5, 2, 1], [5, 2, -4], [5, 2, -4]])
|
|
519
|
+
array([0., 1., 4., 4.])
|
|
520
|
+
|
|
521
|
+
"""
|
|
522
|
+
return np.abs(self.distance_points_signed(point))
|
|
523
|
+
|
|
431
524
|
def side_point(self, point: array_like) -> int:
|
|
432
525
|
"""
|
|
433
526
|
Find the side of the plane where a point lies.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|