vectormath
Vector math utilities for Python built on NumPy
Why
The vectormath package provides a fast, simple library of vector math
utilities by leveraging NumPy. This allows explicit
geometric constructs to be created (for example, Vector3 and Plane)
without redefining the underlying array math.
Scope
The vectormath package includes Vector3/Vector2 and
Vector3Array/Vector2Array.
Goals
Speed: All low-level operations rely on NumPy arrays. These are densely packed, typed, and partially implemented in C. The
VectorArrayclasses in particular take advantage of this speed by performing vector operations on all Vectors at once, rather than in a loop.Simplicty: High-level operations are explicit and straight-forward. This library should be usable by Programmers, Mathematicians, and Geologists.
Alternatives
Connections
properties uses
vectormathas the underlying framework for Vector properties.
Installation
To install the repository, ensure that you have pip installed and run:
pip install vectormath
For the development version:
git clone https://github.com/seequent/vectormath.git
cd vectormath
pip install -e .
Examples
This example gives a brief demonstration of some of the notable features of
Vector3 and Vector3Array
import numpy as np
import vectormath as vmath
# Single Vectors
v = vmath.Vector3(5, 0, 0)
v.normalize()
print(v) # >> [1, 0, 0]
print(v.x) # >> 1.0
# VectorArrays are much faster than a for loop over Vectors
v_array = vmath.Vector3Array([[4, 0, 0], [0, 2, 0], [0, 0, 3]])
print(v_array.x) # >> [4, 0, 0]
print(v_array.length) # >> [4, 2, 3]
print(v_array.normalize()) # >> [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
# Vectors can be accessed individually or in slices
print(type(v_array[1:])) # >> vectormath.Vector3Array
print(type(v_array[2])) # >> vectormath.Vector3
# All these classes are just numpy arrays
print(isinstance(v, np.ndarray)) # >> True
print(type(v_array[1:, 1:])) # >> numpy.ndarray
Current version: v0.2.2
Release files for vectormath 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| vectormath-0.2.2.tar.gz | 9.2 kB | Details |
Release files / vectormath-0.2.2.tar.gz
| Download URL | vectormath-0.2.2.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f9f9209d350ec89dc11e2548e0e6397c1b9489c8468eb50ce33788ee4322a7b8
|
|
BLAKE2b-256 checksum How to use checksums |
bed35d49b6e961d87ba4845205509fbd0f2fa39875859ccb5e4778035518b89f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/2.7
|