Homogeneous Transformation Matrices and Quaternions

## Project description

Transformations is a Python library for calculating 4x4 matrices for translating, rotating, reflecting, scaling, shearing, projecting, orthogonalizing, and superimposing arrays of 3D homogeneous coordinates as well as for converting between rotation matrices, Euler angles, and quaternions. Also includes an Arcball control object and functions to decompose transformation matrices.

Author: Christoph Gohlke Laboratory for Fluorescence Dynamics. University of California, Irvine BSD 3-Clause 2021.6.6

## Revisions

2021.6.6
Remove support for Python 3.6 (NEP 29).
2020.1.1
Remove support for Python 2.7 and 3.5.
2019.4.22
Fix setup requirements.

## Examples

```>>> alpha, beta, gamma = 0.123, -1.234, 2.345
>>> origin, xaxis, yaxis, zaxis = [0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]
>>> I = identity_matrix()
>>> Rx = rotation_matrix(alpha, xaxis)
>>> Ry = rotation_matrix(beta, yaxis)
>>> Rz = rotation_matrix(gamma, zaxis)
>>> R = concatenate_matrices(Rx, Ry, Rz)
>>> euler = euler_from_matrix(R, 'rxyz')
>>> numpy.allclose([alpha, beta, gamma], euler)
True
>>> Re = euler_matrix(alpha, beta, gamma, 'rxyz')
>>> is_same_transform(R, Re)
True
>>> al, be, ga = euler_from_matrix(Re, 'rxyz')
>>> is_same_transform(Re, euler_matrix(al, be, ga, 'rxyz'))
True
>>> q = quaternion_multiply(qx, qy)
>>> q = quaternion_multiply(q, qz)
>>> Rq = quaternion_matrix(q)
>>> is_same_transform(R, Rq)
True
>>> S = scale_matrix(1.23, origin)
>>> T = translation_matrix([1, 2, 3])
>>> Z = shear_matrix(beta, xaxis, origin, zaxis)
>>> R = random_rotation_matrix(numpy.random.rand(3))
>>> M = concatenate_matrices(T, R, Z, S)
>>> scale, shear, angles, trans, persp = decompose_matrix(M)
>>> numpy.allclose(scale, 1.23)
True
>>> numpy.allclose(trans, [1, 2, 3])
True
>>> numpy.allclose(shear, [0, math.tan(beta), 0])
True
>>> is_same_transform(R, euler_matrix(axes='sxyz', *angles))
True
>>> M1 = compose_matrix(scale, shear, angles, trans, persp)
>>> is_same_transform(M, M1)
True
>>> v0, v1 = random_vector(3), random_vector(3)
>>> M = rotation_matrix(angle_between_vectors(v0, v1), vector_product(v0, v1))
>>> v2 = numpy.dot(v0, M[:3,:3].T)
>>> numpy.allclose(unit_vector(v1), unit_vector(v2))
True
```

## Project details

This version 2021.6.6 2020.1.1 2019.4.22 2019.2.20 2019.1.1 2018.10.18 2018.9.5 2018.8.29

### Source Distribution

transformations-2021.6.6.tar.gz (45.5 kB view hashes)

Uploaded `source`

### Built Distributions

transformations-2021.6.6-pp38-pypy38_pp73-win_amd64.whl (56.6 kB view hashes)

Uploaded `pp38`

transformations-2021.6.6-pp37-pypy37_pp73-win_amd64.whl (58.4 kB view hashes)

Uploaded `pp37`

transformations-2021.6.6-cp310-cp310-win_amd64.whl (58.5 kB view hashes)

Uploaded `cp310`

transformations-2021.6.6-cp310-cp310-win32.whl (53.3 kB view hashes)

Uploaded `cp310`

transformations-2021.6.6-cp39-cp39-win_amd64.whl (58.5 kB view hashes)

Uploaded `cp39`

transformations-2021.6.6-cp39-cp39-win32.whl (53.2 kB view hashes)

Uploaded `cp39`

transformations-2021.6.6-cp38-cp38-win_amd64.whl (58.5 kB view hashes)

Uploaded `cp38`

transformations-2021.6.6-cp38-cp38-win32.whl (53.2 kB view hashes)

Uploaded `cp38`

transformations-2021.6.6-cp37-cp37m-win_amd64.whl (58.1 kB view hashes)

Uploaded `cp37`

transformations-2021.6.6-cp37-cp37m-win32.whl (52.8 kB view hashes)

Uploaded `cp37`