Skip to main content

Homogeneous transformation toolbox

Project description

Homogeneous Transform

A simple Python library for creating homogeneous transformation matrices for 3D transformations, including rotation, translation, and scaling. This library is built using NumPy and SciPy for efficient numerical computations.


Features

  • Generate homogeneous rotation matrices from scipy.spatial.transform.Rotationinstance.
  • Create homogeneous translation matrices from 3D translation vectors.
  • Construct homogeneous scaling matrices from 3D scale vectors.
  • Easy-to-use functions for common transformation operations.

Installation

Install the package:

pip install homogeneous-transform

Usage

Importing the Library

import numpy as np
from homogeneous_transform import rh, th, sh
from scipy.spatial.transform import Rotation as R

Examples

1. Create a Homogeneous Rotation Matrix

Convert a rotation instance (e.g., 45 degrees around the Z-axis) into a 4x4 homogeneous matrix:

rotation = R.from_euler('z', 45, degrees=True)  # Rotation around Z-axis
rotation_matrix = rh(rotation)
print("Homogeneous Rotation Matrix:")
print(rotation_matrix)

Output:

Homogeneous Rotation Matrix:
[[ 0.70710678 -0.70710678  0.          0.        ]
 [ 0.70710678  0.70710678  0.          0.        ]
 [ 0.          0.          1.          0.        ]
 [ 0.          0.          0.          1.        ]]

2. Create a Homogeneous Translation Matrix

Convert a translation vector (e.g., ([1, 2, 3])) into a 4x4 homogeneous matrix:

translation_vector = [1, 2, 3]
translation_matrix = th(translation_vector)
print("Homogeneous Translation Matrix:")
print(translation_matrix)

Output:

Homogeneous Translation Matrix:
[[1. 0. 0. 1.]
 [0. 1. 0. 2.]
 [0. 0. 1. 3.]
 [0. 0. 0. 1.]]

3. Create a Homogeneous Scaling Matrix

Convert a scale vector (e.g., ([2, 3, 4])) into a 4x4 homogeneous matrix:

scale_vector = [2, 3, 4]
scaling_matrix = sh(scale_vector)
print("Homogeneous Scaling Matrix:")
print(scaling_matrix)

Output:

Homogeneous Scaling Matrix:
[[2. 0. 0. 0.]
 [0. 3. 0. 0.]
 [0. 0. 4. 0.]
 [0. 0. 0. 1.]]

API Reference

rh(rotation_instance)

  • Description: Converts a scipy.spatial.transform.Rotation instance into a 4x4 homogeneous rotation matrix.
  • Parameters:
    • rotation_instance: A scipy.spatial.transform.Rotation object.
  • Returns: A numpy.ndarray representing the 4x4 rotation matrix.

th(translation_vector)

  • Description: Converts a 3D translation vector into a 4x4 homogeneous translation matrix.
  • Parameters:
    • translation_vector: A 3-element list, tuple, or NumPy array representing x, y, z.
  • Returns: A numpy.ndarray representing the 4x4 translation matrix.

sh(scale_vector)

  • Description: Converts a 3D scale vector into a 4x4 homogeneous scaling matrix.
  • Parameters:
    • scale_vector: A 3-element list, tuple, or NumPy array representing sx, sy, sz.
  • Returns: A numpy.ndarray representing the 4x4 scaling matrix.

License

This project is licensed under the GNU GENERAL PUBLIC License. See the LICENSE file for details.


Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Submit a pull request with a clear description of the changes.

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

homogeneous_transform-0.1.0.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

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

homogeneous_transform-0.1.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file homogeneous_transform-0.1.0.tar.gz.

File metadata

  • Download URL: homogeneous_transform-0.1.0.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.0

File hashes

Hashes for homogeneous_transform-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d04688477d5994e7549ee3b9d087e6a71f951cdb5465ce058e5c5808fedf7148
MD5 353447bca622e459e9f5194e64cd16d0
BLAKE2b-256 a404a5f09b6f829b59228a7cfc475bdd7ea46b9281645074f891f653b176b692

See more details on using hashes here.

File details

Details for the file homogeneous_transform-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for homogeneous_transform-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d74ed446345160a560d0f408e1521641bbb2672d5a90217d1b815ebb9b276d41
MD5 7521faded2749976d50bbcb68ac50626
BLAKE2b-256 a586df9ccf749a3ed3b1f4a9076f6ffcc5af0f9cafae97af0a59058caca1a4c0

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