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.Rotationinstance into a 4x4 homogeneous rotation matrix. - Parameters:
rotation_instance: Ascipy.spatial.transform.Rotationobject.
- Returns: A
numpy.ndarrayrepresenting 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.ndarrayrepresenting 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.ndarrayrepresenting 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:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Submit a pull request with a clear description of the changes.
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
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 homogeneous_transform-0.1.1.tar.gz.
File metadata
- Download URL: homogeneous_transform-0.1.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d804dab8b2d86e9c07fe17f6f346f4011bfcc3dd3b6d497451465e0d7add60a
|
|
| MD5 |
b53763b44998c457a258216897219fc9
|
|
| BLAKE2b-256 |
ef4de841ccb92ba78aca92377d9169ad424c71aca0b5df0edaf0c1d26ff13114
|
File details
Details for the file homogeneous_transform-0.1.1-py3-none-any.whl.
File metadata
- Download URL: homogeneous_transform-0.1.1-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
535f4f1578b1dacbada97c107d5b5613c69a8f15559e60db0d712a0c599ef1a9
|
|
| MD5 |
fab8d258e5096e45a0940f489ecbae0c
|
|
| BLAKE2b-256 |
4ab66568f9fad3dbcc5eb9a7e114207381339df0fd8d9e46f11c2f52fbf78205
|