Skip to main content

A Euclidean vector space module.

Project description

PyEVSpace

PyEVSpace is a Python Euclidean Vector Space module containing Euclidean vector and matrix types. The module is created by extending C code with the Python/C API to ensure the best performance and runs faster than the same code implemented directly in python. The python types are designed to be used to represent physical vectors and rotations between reference frames, however they can be utilized in other ways if so desired.

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

and built there using:

py setup.py build

This is only recommended if editing the source code and testing its functionality. Most users should install using pip.

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.00000, 4.00000, 6.00000 ]

print(v1 + v2)
# prints [ 5.00000, 7.00000, 9.00000 ]

print(v1 - v2)
# prints [-3.00000, -3.00000, -3.00000 ]

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.00000, 2.00000, 3.00000 ]
# [ 8.00000, 5.00000, 2.00000 ]
# [ 4.00000, 2.00000, 1.00000 ]

Methods and operators

EVector operators:

  • + addition (other EVector)
  • += inplace addition (other EVector)
  • - subtraction (other EVector)
  • -= inplace subtraction (other EVector)
  • * multiplication (floats or ints)
  • *= inplace multiplication (floats or ints)
  • / division (floats or ints)
  • /= inplace division (floats or ints)

EVector methods:

  • mag() magnitude of a vector
  • mag2() square of the magnitude of a vector
  • normalize() normalizes a vector
  • copy() 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 (other EMatrix)
  • += inplace addition (other EMatrix)
  • - subtraction (other EMatrix)
  • -= inplace subtraction (other EMatrix)
  • * multiplication (floats or ints)
  • *= inplace multiplication (floats or ints)
  • @ matrix multiplication (other EMatrix or EVector)
  • @= inplace matrix multiplication (other EMatrix or EVector)
  • / division (floats or ints)
  • /= inplace division (floats or ints)

EMatrix methods:

  • get(row, column) gets a component of a matrix
  • set(row, column, value) sets a comonent of a matrix to a value
  • copy() creates a deep copy of the matrix

module level methods:

  • dot(EVector, EVector) vector dot product
  • cross(EVector, EVector) vector cross product
  • norm(EVector) returns a normalized vector
  • vang(EVector, EVector) computes the angle between two vectors
  • vxcl(EVector, EVector) computes a vector exculded from another
  • det(EMatrix) computes the determinate of a matrix
  • transpose(EMatrix) computes the transpose of a matrix

License

MIT

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

pyevspace-0.0.8.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

pyevspace-0.0.8-cp310-cp310-win_amd64.whl (16.2 kB view details)

Uploaded CPython 3.10 Windows x86-64

File details

Details for the file pyevspace-0.0.8.tar.gz.

File metadata

  • Download URL: pyevspace-0.0.8.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.0

File hashes

Hashes for pyevspace-0.0.8.tar.gz
Algorithm Hash digest
SHA256 7e6752ab8a4898d13489d905c4ba946b546872c34c2bb06849425492024aefe8
MD5 05ba3cb8b3e871fb72bcc9826b093ca0
BLAKE2b-256 1167c2f9949a8643ae3ca6397b5c15656f34cbf44b3c43cae07ba661ce546bb4

See more details on using hashes here.

File details

Details for the file pyevspace-0.0.8-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pyevspace-0.0.8-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b6cc67b7f1944300d91615a95d149100b1a5a300654e8b82fcac5b02844b8ffa
MD5 4257126e5e7f59fec5dc94aeb4f87fc3
BLAKE2b-256 bf28f7d913e99fda3777aa7b0f44377b3bf713171cd28f9451f097eb5a506ceb

See more details on using hashes here.

Supported by

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