Skip to main content

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:

  1. Vectors
  2. Matrix
  3. Quaternions

Table of Contents

Documentation

This section is meant to outline the classes, please see the documented section of code for more details.

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

Installation

  1. Create a new virtual environment, if not already created
python -m virtualenv venv
  1. Activate the virtual environment
source venv/bin/activate
  1. Install dependencies
make install-deps

Version Changes

NOTE: When making updates to the source code, make sure to bump versions.

  1. Update the version number in Py4DMath/version.py, using semantic versioning.

  2. Update the CHANGES.txt with the new version number and detail what changed.

Deployment

This package is available on PyPi.

To deploy to PyPi,

  1. Build the dist package using make build

  2. 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

Py4DMath-0.5.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

Py4DMath-0.5.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file Py4DMath-0.5.0.tar.gz.

File metadata

  • Download URL: Py4DMath-0.5.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for Py4DMath-0.5.0.tar.gz
Algorithm Hash digest
SHA256 5d04a7be4fdf82f6dd63606e9daaf90678145255923cd46ccafc28093cfa89a1
MD5 5b25f017d3b74937f68eac92409796be
BLAKE2b-256 87c76d3326454271c2c9f48a6312e578810d9ecca0038432476bbd4fcd42600a

See more details on using hashes here.

File details

Details for the file Py4DMath-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: Py4DMath-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for Py4DMath-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9cf5333150f4cbccbb0fb9b74fe1f122c67acab94233a7744048b57ecdee7d69
MD5 b5b76f8b6a32b83a9e053666bdde4513
BLAKE2b-256 165da74cc3c066aae7e3da0d1efe2a53fe48e948e1009e69ab05b76c07b38ee0

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