A Euclidean vector space module.
Project description
PyEVSpace
PyEVSpace is a Python Euclidean Vector Space package containing Euclidean vector and matrix types. The types are desigend to be used to represent physical vectors and rotations between reference frames, which means they are all 3-dimensional. This means that operations don't require size checking at runtime, which allows for optimum performance. The package only allows 3-dimensional vectors and matrices, so if you need something different, you should use a package more suited to your needs, such as numpy.
Install
The python module can be installed with
pip install pyevspace
Alternatively the repository can be downloaded or cloned using:
git clone https://github.com/qbizzle68/pyevspace.git
It can be used as is within Visual Studio, or built using setup.py if needed.
Usage
To use the module simply import the pyevspace module into your project:
from pyevspace import *
# create vector
vec = EVector((1, 2, 3))
# create matrix from sequences
mat = EMatrix((1, 3, 2), (7, 4, 3), (8, 4, 2))
# rotate vector
rotated = mat * vec
The module only contains two types, and a handful of module level methods, so it is probably necessary to import everything. However, if you don't wish to overpopulate the namespace, you can import the module using an alias:
import pyevspace as evs
vec = evs.EVector()
Examples
Examples of numeric operators
v1 = EVector((1, 2, 3))
v2 = EVector((4, 5, 6))
print(v1 * 2)
# prints [2, 4, 6]
print(v1 + v2)
# prints [5, 7, 9]
print(v1 - v2)
# prints [-3, -3, -3]
Examples of vector and matrix operators
v1 = EVector((1, 2, 3))
v2 = EVector((4, 5, 6))
m1 = EMatrix( EVector(4, 2, 3), EVector(8, 5, 2), EVector(4, 2, 1) )
print(dot(v1, v2))
# prints 32.0
print(cross(v1, v2))
# prints [ -3.00000, 6.00000, -3.00000 ]
print(det(m1))
# prints -8.0
print(transpose(m1))
# prints
# ([4, 2, 3],
# [8, 5, 2],
# [4, 2, 1])
Methods and operators
EVector
operators:
+
addition (otherEVector
)+=
inplace addition (otherEVector
)-
subtraction (otherEVector
)-=
inplace subtraction (otherEVector
)*
multiplication (floats or ints)*=
inplace multiplication (floats or ints)/
division (floats or ints)/=
inplace division (floats or ints)
EVector
methods:
mag()
magnitude of a vectormag2()
square of the magnitude of a vectornormalize()
normalizes a vectorcopy()
creates a deep copy of the vector[0]
gets the first comonent of a vector[1] = 4
sets the second comonent of a vector to 4
EMatrix
operators:
+
addition (otherEMatrix
)+=
inplace addition (otherEMatrix
)-
subtraction (otherEMatrix
)-=
inplace subtraction (otherEMatrix
)*
multiplication (floats or ints or otherEVector
or otherEMatrix
)*=
inplace multiplication (floats or ints)/
division (floats or ints)/=
inplace division (floats or ints)
EMatrix
methods:
[1, 1]
gets a component of a matrix[0, 2] = 4
sets a component of a matrix to a value
module level methods:
dot(EVector, EVector)
vector dot productcross(EVector, EVector)
vector cross productnorm(EVector)
returns a normalized vectorvang(EVector, EVector)
computes the angle between two vectorsvxcl(EVector, EVector)
computes a vector exculded from anotherdet(EMatrix)
computes the determinate of a matrixtranspose(EMatrix)
computes the transpose of a matrix
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyevspace-0.0.11.1.tar.gz
.
File metadata
- Download URL: pyevspace-0.0.11.1.tar.gz
- Upload date:
- Size: 20.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08985437920bd9076254bccd18faf3ce3992687ba807986e8907bd6993326006 |
|
MD5 | 74e535984099a8451472351da09d9fd0 |
|
BLAKE2b-256 | e7a9c5ae14d8c504db3cdc47da2782b9a07e861093acbdad2deede88dab995cb |
File details
Details for the file pyevspace-0.0.11.1-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: pyevspace-0.0.11.1-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 26.4 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e959ef6629ad2efd7bd6c0b5775508f4d046c2b2ce0e44ec19130163e5b1432 |
|
MD5 | 0484795c255b8489b26c278878ed7b8d |
|
BLAKE2b-256 | c8169133973c9dbf99dd7153c7c1cc20abdaed250c6f3432ef26e229d2c4f2c7 |