A math engine for controlling 3D objects
Project description
Py4DMath
Py4DMath is a math engine that contains functions which allows a 3D object to translate and rotate.
It consists of the following classes:
- Vectors
- Matrix
- Quaternions
Usage
Install the package using,
pip install Py4DMath
This package contains three main classes that are briefly described below. To learn more about each class please read through the comments found in the source code.
Vector3D
A class to represent a vector in 3D space.
...
Attributes
----------
x: float
the x position of the vector
y: float
the y position of the vector
z: float
the z position of the vector
Methods
----------
copy():
Returns a copy of the vector.
show():
Prints visual representation of the vector.
add():
Returns the result of vector addition.
subtract():
Returns the result of vector subtraction.
multiply():
Returns a vector multiplied by a scalar value.
divide():
Returns a vector divided by a scalar value.
dot():
Returns the dot product between two vectors.
cross():
Returns the cross product between two vectors.
magnitude():
Returns the magnitude of the vector.
normalize():
Returns the normalized unit vector.
rotate():
Rotates a vector using an angle and an axis.
Matrix3D
A class to represent a 3x3 matrix.
...
Attributes
----------
matrix: float[9]
the array representing the matrix (column-major format)
Static/Class Methods
----------
getIdentityMatrix():
Returns an identity matrix.
Methods
----------
copy():
Returns a copy of the matrix.
show():
Prints visual representation of matrix.
add():
Returns the result of matrix addition.
subtract():
Returns the result of matrix subtraction.
scalar_multiply():
Returns a vector multiplied by a scalar value.
matrix_multiply():
Returns a vector multiplied by another matrix.
inverse():
Returns the inverse of the matrix.
transpose():
Returns the transpose of the matrix.
transform():
Returns vector transformed by matrix.
Quaternion
A class representing a Quaternion.
q = s + v
where s is a scalar number, v is a vector representing an axis
...
Attributes
----------
s: float
the scalar number
v: Vector3D
the vector representing an axis
Static/Class Methods
----------
getRotationQuaternion():
Returns the rotation quaternion.
Methods
----------
copy():
Returns a copy of the quaternion.
add():
Returns the result of quaternion addition.
subtract():
Returns the result of quaternion subtraction.
scalar_multiply():
Returns the result of a quaternion multiplied by a scalar value.
quaternion_multiply():
Returns the result of quaternion multiplication.
norm():
Returns the norm of the quaternion.
normalize():
Returns the normalized quaternion (unit norm).
conjugate():
Returns the conjugate of the quaternion.
inverse():
Returns the inverse of the quaternion.
Developer's Guide
Prerequistes
- Python 3.10+
- virtualenv
Getting Started
The quickest way to get started working on this package is to run the command,
make init
Otherwise, you can follow these steps,
- Create a new virtual environment, if not already created
python -m virtualenv venv
- Activate the virtual environment
source venv/bin/activate
- Install dependencies
make install-deps
- Setup pre-commit hooks
pre-commit install
Version Changes
NOTE: When making updates to the source code, make sure to bump versions.
-
Update the version number in Py4DMath/version.py, using semantic versioning.
-
Update the CHANGES.txt with the new version number and detail what changed.
Deployment
This package is available on PyPi.
To deploy to PyPi,
-
Build the
distpackage usingmake build -
Upload to PyPi using
make upload
Contact
Nicholas Chumney - nicholas.chumney@outlook.com
Acknowledgements
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file Py4DMath-1.0.0.tar.gz.
File metadata
- Download URL: Py4DMath-1.0.0.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b2293f43f72b7eab023fc9c30003acbcec62666f0996c23082eba987bf0b6a4
|
|
| MD5 |
5c05955135b94c026de322faf3f05ccc
|
|
| BLAKE2b-256 |
c9a4b24eaa31e3dc2d7ae51425832866bd7961ad6db0ea7f94690178b3521866
|
File details
Details for the file Py4DMath-1.0.0-py3-none-any.whl.
File metadata
- Download URL: Py4DMath-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fb5cb908df7ddcd4d19e05659c9ab98da6b1d54669e59ed860113a9ec77f6ab
|
|
| MD5 |
73e7894a810a7b4e7dc8e68fd461f4e7
|
|
| BLAKE2b-256 |
19c949f8b285154c4b6d57926b265c27cf5e8c85fd1faae7f532d36bf4f88097
|