Skip to main content

Spatial objects and computations in 3D.

Project description

https://img.shields.io/pypi/v/scikit-spatial.svg https://img.shields.io/travis/ajhynes7/scikit-spatial.svg Documentation Status https://pyup.io/repos/github/ajhynes7/scikit-spatial/shield.svg https://codecov.io/gh/ajhynes7/scikit-spatial/branch/master/graph/badge.svg

Introduction

This package provides spatial objects in 3D (Point, Vector, Line, and Plane) based on NumPy arrays, as well as computations using these objects.

Point and Vector are subclasses of the NumPy ndarray, allowing them to be easily integrated with the SciPy ecosystem. The Line and Plane objects have Point and Vector objects as attributes.

The computations can be grouped into the following main categories:

  • Measurement
    • e.g.: Measure the angle between two vectors.

  • Comparison
    • e.g.: Check if two vectors are perpendicular.

  • Projection
    • e.g.: Project a point onto a line.

  • Intersection
    • e.g.: Find the intersection of a line and a plane.

The package has been built using contracts and is tested with hypothesis (see this PyCon talk for a good introduction to both libraries). The contracts prevent spatial computations that are undefined in Euclidean space, such as finding the intersection of two parallel lines.

Installation

The package can be installed via pip.

$ pip install scikit-spatial

Example Usage

Measure the angle between two vectors.

>>> import numpy as np
>>> from skspatial.objects import Vector
>>> vector = Vector([1, 0])
>>> angle = vector.angle_between([1, 1])
>>> np.degrees(angle).round()
45.0

Project a point onto a line.

>>> from skspatial.objects import Line
>>> line = Line(point=[0, 0, 0], direction=[1, 1, 0])
>>> line.project_point([5, 6, 7])
Point([5.5, 5.5, 0. ])

An error is returned if the computation is undefined.

>>> line_a = Line([0, 0], [1, 0])
>>> line_b = Line([1, 0], [1, 0])
>>> line_a.intersect_line(line_b)
Traceback (most recent call last):
...
dpcontracts.PreconditionError: The lines must not be parallel.

Acknowledgment

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scikit-spatial-1.0.0.tar.gz (30.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scikit_spatial-1.0.0-py2.py3-none-any.whl (19.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file scikit-spatial-1.0.0.tar.gz.

File metadata

  • Download URL: scikit-spatial-1.0.0.tar.gz
  • Upload date:
  • Size: 30.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3

File hashes

Hashes for scikit-spatial-1.0.0.tar.gz
Algorithm Hash digest
SHA256 205fa846d903d63d61643c2bed70d7fcc8cdc9b168f6d79b5ef510d9fb313591
MD5 0ec87a97ab5a28ce68dc6e7c571d3ed4
BLAKE2b-256 d269ed121baffd8c5214300c795af647db280f5a4d9c48c51928c94fa703fdb4

See more details on using hashes here.

File details

Details for the file scikit_spatial-1.0.0-py2.py3-none-any.whl.

File metadata

  • Download URL: scikit_spatial-1.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 19.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3

File hashes

Hashes for scikit_spatial-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c5f46ad7a031f3954e1dacba0c9ac7e27a8946eca0e7e3661cf2e2a8d82605c6
MD5 6dc510399a7a335540fe358c220e315d
BLAKE2b-256 34f2ef265fc8e3a16f4230a629d530fbd750faff510a06469d5917213da55bce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page