### Verify installation and tests Source: http://matthew-brett.github.io/transforms3d/_sources/devel/make_release.rst.txt Test the installation process within a virtual environment. ```bash mkvirtualenv transforms3d-test pip install pytest wheel git clean -fxd python setup.py install mkdir for_test cd for_test pytest --doctest-modules transforms3d ``` -------------------------------- ### Upload documentation Source: http://matthew-brett.github.io/transforms3d/_sources/devel/make_release.rst.txt Install documentation requirements and build/upload documentation to GitHub. ```bash pip install -e . # if you haven't done this already pip install -r doc-requirements.txt cd doc make github ``` -------------------------------- ### Installation Source: http://matthew-brett.github.io/transforms3d/index.html Instructions for installing the transforms3d package via pip. ```APIDOC ## Installation ### Description Install the latest version of the transforms3d package using pip. ### Command `pip install transforms3d` ``` -------------------------------- ### Configure PyPI credentials Source: http://matthew-brett.github.io/transforms3d/_sources/devel/make_release.rst.txt Example configuration for ~/.pypirc when using 2-factor authentication. ```ini [pypi] username = __token__ ``` -------------------------------- ### Matrix and Quaternion Operations Example Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d._gohlketransforms.html Demonstrates various transformations including rotation, scaling, translation, and decomposition using matrices and quaternions. Requires numpy and math. ```python >>> 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 >>> qx = quaternion_about_axis(alpha, xaxis) >>> qy = quaternion_about_axis(beta, yaxis) >>> qz = quaternion_about_axis(gamma, zaxis) >>> 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 ``` -------------------------------- ### Install transforms3d with pip Source: http://matthew-brett.github.io/transforms3d/_sources/index.rst.txt Use this command to install the latest version of the transforms3d package. ```bash pip install transforms3d ``` -------------------------------- ### Decomposition of a 4x4 affine matrix Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d.affines.html This example demonstrates how to construct an affine matrix from translation, rotation, zoom, and shear components, and then decompose it back using `decompose44`. It verifies that the decomposed components match the original ones. ```python T = [20, 30, 40] # translations R = [[0, -1, 0], [1, 0, 0], [0, 0, 1]] # rotation matrix Z = [2.0, 3.0, 4.0] # zooms S = [0.2, 0.1, 0.3] # shears # Now we make an affine matrix A = np.eye(4) Smat = np.array([[1, S[0], S[1]], [0, 1, S[2]], [0, 0, 1]]) RZS = np.dot(R, np.dot(np.diag(Z), Smat)) A[:3,:3] = RZS A[:-1,-1] = T # set translations Tdash, Rdash, Zdash, Sdash = decompose44(A) np.allclose(T, Tdash) True np.allclose(R, Rdash) True np.allclose(Z, Zdash) True np.allclose(S, Sdash) True ``` -------------------------------- ### Get Versions Source: http://matthew-brett.github.io/transforms3d/_sources/reference/transforms3d._version.rst.txt Retrieves the version information for the transforms3d library. ```APIDOC ## GET /_version ### Description Retrieves the version information for the transforms3d library. ### Method GET ### Endpoint /_version ### Parameters None ### Request Example None ### Response #### Success Response (200) - **version** (string) - The version string of the transforms3d library. #### Response Example { "version": "1.0.0" } ``` -------------------------------- ### Convert zoom matrix to factor and direction Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d.zooms.html Use `mat2zfdir` to get the scaling factor and direction from a 3x3 zoom matrix. Note that roundtrip transformations may not yield identical factor/direction values but will produce equivalent matrices. ```python >>> factor = np.random.random() * 10 - 5 >>> S0 = zfdir2mat(factor, None) >>> f2, d2 = mat2zfdir(S0) >>> S1 = zfdir2mat(f2, d2) >>> np.allclose(S0, S1) True >>> direct = np.random.random(3) - 0.5 >>> S0 = zfdir2mat(factor, direct) >>> f2, d2 = mat2zfdir(S0) >>> S1 = zfdir2mat(f2, d2) >>> np.allclose(S0, S1) True ``` -------------------------------- ### Import and use C implementation Source: http://matthew-brett.github.io/transforms3d/devel/refactor_plan.html Demonstrates accessing the C-optimized implementation of rotation matrix functions. ```python >>> import transforms3d.c as t3dc >>> M = t3dc.euler2mat(0.1, 0.3, 0.2) ``` -------------------------------- ### Upload to PyPI Source: http://matthew-brett.github.io/transforms3d/_sources/devel/make_release.rst.txt Build the source distribution and upload it to PyPI using twine. ```bash python setup.py sdist twine upload -s dist/* ``` -------------------------------- ### Get Real Part of Quaternion Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d._gohlketransforms.html Extracts the real component from a quaternion. Quaternions are represented as [real, x, y, z]. ```python >>> quaternion_real([3, 0, 1, 2]) 3.0 ``` -------------------------------- ### Import and use Python implementation Source: http://matthew-brett.github.io/transforms3d/devel/refactor_plan.html Demonstrates the standard usage of the library's Python-based rotation matrix functions. ```python >>> import transforms3d as t3d >>> M = t3d.euler3rmat(0.1, 0.3, 0.2) ``` -------------------------------- ### Prepare pre-release test branch Source: http://matthew-brett.github.io/transforms3d/_sources/devel/make_release.rst.txt Create a clean branch for testing the current state of the repository. ```bash git branch -D pre-release-test # in case branch already exists git co -b pre-release-test ``` -------------------------------- ### Convert Euler angles to rotation matrix Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d.euler.html Use `euler2mat` to get a rotation matrix from Euler angles. Specify the axis sequence for correct interpretation. Requires numpy. ```python >>> R = euler2mat(1, 2, 3, 'syxz') >>> np.allclose(np.sum(R[0]), -1.34786452) True ``` ```python >>> R = euler2mat(1, 2, 3, (0, 1, 0, 1)) >>> np.allclose(np.sum(R[0]), -0.383436184) True ``` -------------------------------- ### Importing Python and C Implementations Source: http://matthew-brett.github.io/transforms3d/_sources/devel/refactor_plan.rst.txt Demonstrates the proposed structure for accessing Python and C-optimized routines within the library. ```python >>> import transforms3d as t3d >>> M = t3d.euler3rmat(0.1, 0.3, 0.2) ``` ```python >>> import transforms3d.c as t3dc >>> M = t3dc.euler2mat(0.1, 0.3, 0.2) ``` ```python >>> import transforms3d as t3d >>> import transforms3d.python as t3dpy ``` -------------------------------- ### Convert Rotation Matrix to Euler Angles Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d._gohlketransforms.html Use `euler_from_matrix` to get Euler angles from a rotation matrix. Specify the axis sequence for correct interpretation. Note that multiple Euler angle triplets can represent the same matrix. ```python >>> R0 = euler_matrix(1, 2, 3, 'syxz') >>> al, be, ga = euler_from_matrix(R0, 'syxz') >>> R1 = euler_matrix(al, be, ga, 'syxz') >>> numpy.allclose(R0, R1) True >>> angles = (4*math.pi) * (numpy.random.random(3) - 0.5) >>> for axes in _AXES2TUPLE.keys(): ... R0 = euler_matrix(axes=axes, *angles) ... R1 = euler_matrix(axes=axes, *euler_from_matrix(R0, axes)) ... if not numpy.allclose(R0, R1): print(axes, "failed") ``` -------------------------------- ### Initialize and Use Arcball Control Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d._gohlketransforms.html Demonstrates initializing the Arcball class with identity or quaternion inputs, placing the trackball, and performing drag operations to calculate rotation matrices. ```python >>> ball = Arcball() >>> ball = Arcball(initial=numpy.identity(4)) >>> ball.place([320, 320], 320) >>> ball.down([500, 250]) >>> ball.drag([475, 275]) >>> R = ball.matrix() >>> numpy.allclose(numpy.sum(R), 3.90583455) True >>> ball = Arcball(initial=[1, 0, 0, 0]) >>> ball.place([320, 320], 320) >>> ball.setaxes([1, 1, 0], [-1, 1, 0]) >>> ball.constrain = True >>> ball.down([400, 200]) >>> ball.drag([200, 400]) >>> R = ball.matrix() >>> numpy.allclose(numpy.sum(R), 0.2055924) True >>> ball.next() ``` -------------------------------- ### Run local tests Source: http://matthew-brett.github.io/transforms3d/_sources/devel/make_release.rst.txt Execute doctests from the project root directory. ```bash pytest --doctest-modules transforms3d ``` -------------------------------- ### Tag the release Source: http://matthew-brett.github.io/transforms3d/_sources/devel/make_release.rst.txt Create a signed annotated tag to define the package version. ```bash git tag -sm 'Fifth public release' 0.6.0 ``` -------------------------------- ### Check documentation doctests Source: http://matthew-brett.github.io/transforms3d/_sources/devel/make_release.rst.txt Run doctests contained within the documentation files. ```bash cd doc make doctest cd .. ``` -------------------------------- ### Compose Null Affine Matrix Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d.affines.html Demonstrates creating an identity affine matrix using `compose` with zero translations, identity rotation, unit zooms, and zero shears. This is useful for testing or as a base case for transformations. ```python >>> compose(np.zeros(3), np.eye(3), np.ones(3), np.zeros(3)) array([[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]) ``` -------------------------------- ### Clean repository Source: http://matthew-brett.github.io/transforms3d/_sources/devel/make_release.rst.txt Remove untracked files and directories to ensure a clean build environment. ```bash git clean -fxd ``` -------------------------------- ### Create Reflection Matrix Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d._gohlketransforms.html Constructs a matrix that mirrors points across a plane defined by a point and a normal vector. Verifies properties of the resulting matrix. ```python >>> v0 = numpy.random.random(4) - 0.5 >>> v0[3] = 1. >>> v1 = numpy.random.random(3) - 0.5 >>> R = reflection_matrix(v0, v1) >>> numpy.allclose(2, numpy.trace(R)) True >>> numpy.allclose(v0, numpy.dot(R, v0)) True >>> v2 = v0.copy() >>> v2[:3] += v1 >>> v3 = v0.copy() >>> v2[:3] -= v1 >>> numpy.allclose(v2, numpy.dot(R, v3)) True ``` -------------------------------- ### Alternative namespace import Source: http://matthew-brett.github.io/transforms3d/devel/refactor_plan.html Shows an alternative approach for explicitly importing the Python namespace. ```python >>> import transforms3d as t3d >>> import transforms3d.python as t3dpy ``` -------------------------------- ### Create affine matrix for scaling Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d.zooms.html Use `zfdir2aff` to generate a 4x4 affine matrix that performs scaling. It supports uniform scaling, scaling along a specific direction, and scaling around a given origin. A factor of -1 indicates point symmetry. ```python >>> v = (np.random.rand(3, 5) - 0.5) * 20.0 >>> S = zfdir2aff(-1.234)[:3,:3] >>> np.allclose(np.dot(S, v), -1.234*v) True >>> factor = np.random.random() * 10 - 5 >>> direct = np.random.random(3) - 0.5 >>> origin = np.random.random(3) - 0.5 >>> S = zfdir2aff(factor, None, origin) >>> S = zfdir2aff(factor, direct, origin) ``` -------------------------------- ### Demonstrate Gimbal Lock with Euler Angles Source: http://matthew-brett.github.io/transforms3d/_sources/gimbal_lock.rst.txt Initializes rotation matrices using euler2mat to show how gimbal lock causes redundant rotations around the same axis. ```python >>> import numpy as np >>> np.set_printoptions(precision=3, suppress=True) # neat printing >>> from transforms3d.euler import euler2mat, mat2euler >>> x_angle = -0.2 >>> y_angle = -np.pi / 2 >>> z_angle = -0.2 >>> R = euler2mat(x_angle, y_angle, z_angle, 'sxyz') >>> R array([[ 0. , 0.389, -0.921], [-0. , 0.921, 0.389], [ 1. , -0. , 0. ]]) ``` ```python >>> R = euler2mat(x_angle + 0.1, y_angle, z_angle - 0.1, 'sxyz') >>> R array([[ 0. , 0.389, -0.921], [-0. , 0.921, 0.389], [ 1. , -0. , 0. ]]) ``` ```python >>> R_dash = euler2mat(x_angle + z_angle, y_angle, 0, 'sxyz') >>> np.allclose(R, R_dash) True ``` -------------------------------- ### Utility Functions Source: http://matthew-brett.github.io/transforms3d/_sources/reference/transforms3d.derivations.rst.txt Utility functions for creating matrices, checking matrix equality, and simplifying matrices. ```APIDOC ## make_matrix ### Description Creates a matrix. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters None explicitly defined in the provided text. ### Request Example None provided. ### Response None explicitly defined in the provided text. ### Response Example None provided. ## matrices_equal ### Description Checks if two matrices are equal. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters None explicitly defined in the provided text. ### Request Example None provided. ### Response None explicitly defined in the provided text. ### Response Example None provided. ## matrix_simplify ### Description Simplifies a matrix. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters None explicitly defined in the provided text. ### Request Example None provided. ### Response None explicitly defined in the provided text. ### Response Example None provided. ``` -------------------------------- ### Transforms3d Utils Functions Source: http://matthew-brett.github.io/transforms3d/_sources/reference/transforms3d.utils.rst.txt This section provides documentation for various utility functions in the transforms3d.utils module. ```APIDOC ## Transforms3d Utils Functions ### Description This module contains utility functions for common operations. ### Functions - **inique**: Checks if a vector is unique. - **normalized_vector**: Normalizes a given vector. - **permuted_signs**: Permutes the signs of a vector. - **permuted_with_signs**: Permutes a vector with specified signs. - **random_unit_vector**: Generates a random unit vector. - **vector_norm**: Calculates the norm (magnitude) of a vector. ``` -------------------------------- ### Constructing an affine matrix from components Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d.affines.html This code snippet shows the mathematical construction of a 4x4 affine matrix `A` from translation vector `T`, rotation matrix `R`, zoom vector `Z`, and shear matrix `Smat`. It's used to create a matrix for decomposition. ```python Smat = np.array([[1, S[0], S[1]], [0, 1, S[2]], [0, 0, 1]]) RZS = np.dot(R, np.dot(np.diag(Z), Smat)) A[:3,:3] = RZS A[:-1,-1] = T ``` -------------------------------- ### Generate clip matrix Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d._gohlketransforms.html Creates a matrix to transform coordinates from a frustum to normalized device coordinates. ```python >>> frustum = numpy.random.rand(6) >>> frustum[1] += frustum[0] >>> frustum[3] += frustum[2] >>> frustum[5] += frustum[4] >>> M = clip_matrix(perspective=False, *frustum) >>> numpy.dot(M, [frustum[0], frustum[2], frustum[4], 1]) array([-1., -1., -1., 1.]) >>> numpy.dot(M, [frustum[1], frustum[3], frustum[5], 1]) array([ 1., 1., 1., 1.]) >>> M = clip_matrix(perspective=True, *frustum) >>> v = numpy.dot(M, [frustum[0], frustum[2], frustum[4], 1]) >>> v / v[3] array([-1., -1., -1., 1.]) >>> v = numpy.dot(M, [frustum[1], frustum[3], frustum[4], 1]) >>> v / v[3] array([ 1., 1., -1., 1.]) ``` -------------------------------- ### zfdir2aff Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d.zooms.html Creates an affine transformation matrix to scale by a factor around an origin in a given direction. ```APIDOC ## zfdir2aff ### Description Return affine to scale by factor around origin in direction. Use factor -1 for point symmetry. ### Method POST (assumed, as it constructs a matrix) ### Endpoint /transforms3d/zooms/zfdir2aff ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **factor** (scalar) - Required - factor to zoom by. - **direction** (None or array-like, shape (3,)) - Optional - direction of zoom. If None, uniform scaling is applied. - **origin** (None or array-like, shape (3,)) - Optional - point at which to apply zooms. ### Request Example ```json { "factor": 2.0, "direction": [1,0,0], "origin": [0,0,0] } ``` ### Response #### Success Response (200) - **aff** (array, shape (4,4)) - 4x4 transformation matrix implementing zooms. #### Response Example ```json { "aff": [[2,0,0,0],[0,2,0,0],[0,0,2,0],[0,0,0,1]] } ``` ``` -------------------------------- ### Create Affine Transformation for Reflection Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d.reflections.html Use `rfnorm2aff` to generate a 4x4 affine transformation matrix that represents a reflection across a plane defined by a normal vector and a point. This is useful for applying reflections in 3D transformations. ```python >>> normal = np.random.random(3) - 0.5 >>> point = np.random.random(3) - 0.5 >>> R = rfnorm2aff(normal, point) >>> np.allclose(2., np.trace(R)) True >>> np.allclose(point, np.dot(R[:3,:3], point) + R[:3,3]) True ``` -------------------------------- ### zfdir2aff Source: http://matthew-brett.github.io/transforms3d/_sources/reference/transforms3d.zooms.rst.txt Converts zoom, factor, and direction components to a 4x4 affine matrix. ```APIDOC ## zfdir2aff ### Description Converts zoom, factor, and direction components to a 4x4 affine matrix. ### Method FUNCTION ### Endpoint transforms3d.zooms.zfdir2aff(zooms, factors, directions) ``` -------------------------------- ### API Reference Modules Source: http://matthew-brett.github.io/transforms3d/index.html Overview of the available modules within the transforms3d package. ```APIDOC ## API Reference Modules ### Description The package is organized into several functional modules for specific transformation types. ### Modules - **affines**: Affine transformation utilities - **axangles**: Axis-angle rotation utilities - **euler**: Euler angle rotation utilities - **quaternions**: Quaternion rotation utilities - **reflections**: Reflection transformation utilities - **shears**: Shear transformation utilities - **taitbryan**: Tait-Bryan angle utilities - **zooms**: Zoom/scaling transformation utilities - **utils**: General utility functions ``` -------------------------------- ### Create matrix for scaling Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d.zooms.html Use `zfdir2mat` to create a 3x3 matrix for scaling operations. It can apply uniform scaling or scaling along a specified direction. A factor of -1 is used for point symmetry. ```python >>> v = (np.random.rand(3, 5) - 0.5) * 20.0 >>> S = zfdir2mat(-1.234) >>> np.allclose(np.dot(S, v), -1.234*v) True >>> factor = np.random.random() * 10 - 5 >>> direct = np.random.random(3) - 0.5 >>> S = zfdir2mat(factor, direct) ``` -------------------------------- ### reflection_matrix Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d._gohlketransforms.html Creates a matrix to mirror at a plane defined by a point and a normal vector. ```APIDOC ## reflection_matrix ### Description Return matrix to mirror at plane defined by point and normal vector. ### Parameters #### Request Body - **point** (array) - Required - Point on the plane. - **normal** (array) - Required - Normal vector to the plane. ``` -------------------------------- ### Create a matrix with a name prefix Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d.derivations.html Utility function to create a matrix with a specified name prefix and dimensions. ```python transforms3d.derivations.utils.make_matrix(name_prefix, N, M) ``` -------------------------------- ### Create Identity Matrix Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d._gohlketransforms.html Generate a 4x4 identity matrix using `identity_matrix`. This is useful for initializing transformations. ```python >>> I = identity_matrix() >>> numpy.allclose(I, numpy.dot(I, I)) True >>> numpy.sum(I), numpy.trace(I) (4.0, 4.0) >>> numpy.allclose(I, numpy.identity(4)) True ``` -------------------------------- ### aff2zfdir Source: http://matthew-brett.github.io/transforms3d/_sources/reference/transforms3d.zooms.rst.txt Converts an affine matrix to zoom, factor, and direction components. ```APIDOC ## aff2zfdir ### Description Converts a 4x4 affine matrix to zoom, factor, and direction components. ### Method FUNCTION ### Endpoint transforms3d.zooms.aff2zfdir(aff) ``` -------------------------------- ### zfdir2mat Source: http://matthew-brett.github.io/transforms3d/_sources/reference/transforms3d.zooms.rst.txt Converts zoom, factor, and direction components to a 3x3 matrix. ```APIDOC ## zfdir2mat ### Description Converts zoom, factor, and direction components to a 3x3 matrix. ### Method FUNCTION ### Endpoint transforms3d.zooms.zfdir2mat(zooms, factors, directions) ``` -------------------------------- ### mat2zfdir Source: http://matthew-brett.github.io/transforms3d/_sources/reference/transforms3d.zooms.rst.txt Converts a 3x3 matrix to zoom, factor, and direction components. ```APIDOC ## mat2zfdir ### Description Converts a 3x3 matrix to zoom, factor, and direction components. ### Method FUNCTION ### Endpoint transforms3d.zooms.mat2zfdir(mat) ``` -------------------------------- ### Create Reflection Matrix Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d.reflections.html Use `rfnorm2mat` to create a 3x3 matrix that performs a reflection in a plane passing through the origin and orthogonal to the given normal vector. This is useful for applying reflections in 3D coordinate systems. ```python >>> normal = np.random.random(3) - 0.5 >>> mat = rfnorm2mat(normal) >>> print(mat.shape) (3, 3) ``` -------------------------------- ### Generate all permutations with sign permutations Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d.utils.html Use `permuted_with_signs` to obtain all permutations of a sequence, including all possible sign combinations for each permutation. This is useful for exploring all possible orientations or configurations. ```python >>> tuple(permuted_with_signs((1,2))) ((1, 2), (1, -2), (-1, 2), (-1, -2), (2, 1), (2, -1), (-2, 1), (-2, -1)) ``` -------------------------------- ### Generate contributor list Source: http://matthew-brett.github.io/transforms3d/_sources/devel/make_release.rst.txt Use this command to identify contributors since the last release tag. ```bash git shortlog -ns 0.6.0.. ``` -------------------------------- ### mat2zfdir Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d.zooms.html Converts a 3x3 zoom matrix to scaling factor and direction. ```APIDOC ## mat2zfdir ### Description Return scaling factor and direction from zoom (scaling) matrix. ### Method GET (assumed, as it's a conversion function) ### Endpoint /transforms3d/zooms/mat2zfdir ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **mat** (array-like, shape (3,3)) - Required - 3x3 zoom matrix. ### Request Example ```json { "mat": [[1,0,0],[0,1,0],[0,0,1]] } ``` ### Response #### Success Response (200) - **factor** (scalar) - zoom (scale) factor. - **direction** (None or array, shape (3,)) - direction of zoom. None if scaling is uniform. #### Response Example ```json { "factor": 1.0, "direction": null } ``` ``` -------------------------------- ### Convert affine matrix to zoom factor, direction, and origin Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d.zooms.html Use `aff2zfdir` to extract scaling factor, direction, and origin from a 4x4 affine transformation matrix. This is useful for analyzing or decomposing scaling operations. ```python >>> factor = np.random.random() * 10 - 5 >>> direct = np.random.random(3) - 0.5 >>> origin = np.random.random(3) - 0.5 >>> S0 = zfdir2aff(factor) >>> f2, d2, o2 = aff2zfdir(S0) >>> np.allclose(S0, zfdir2aff(f2, d2, o2)) True >>> S0 = zfdir2aff(factor, direct) >>> f2, d2, o2 = aff2zfdir(S0) >>> np.allclose(S0, zfdir2aff(f2, d2, o2)) True >>> S0 = zfdir2aff(factor, direct, origin) ``` -------------------------------- ### Create Scale Matrix Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d._gohlketransforms.html Generates a matrix to scale by a given factor around an origin and in a specified direction. Use a factor of -1 for point symmetry. ```python >>> v = (numpy.random.rand(4, 5) - 0.5) * 20 >>> v[3] = 1 >>> S = scale_matrix(-1.234) >>> numpy.allclose(numpy.dot(S, v)[:3], -1.234*v[:3]) True >>> factor = random.random() * 10 - 5 >>> origin = numpy.random.random(3) - 0.5 >>> direct = numpy.random.random(3) - 0.5 >>> S = scale_matrix(factor, origin) >>> S = scale_matrix(factor, origin, direct) ``` -------------------------------- ### Calculate projection matrix Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d._gohlketransforms.html Generates a matrix to project onto a plane defined by a point and normal, supporting perspective and orthogonal projections. ```python >>> P = projection_matrix([0, 0, 0], [1, 0, 0]) >>> numpy.allclose(P[1:, 1:], numpy.identity(4)[1:, 1:]) True >>> point = numpy.random.random(3) - 0.5 >>> normal = numpy.random.random(3) - 0.5 >>> direct = numpy.random.random(3) - 0.5 >>> persp = numpy.random.random(3) - 0.5 >>> P0 = projection_matrix(point, normal) >>> P1 = projection_matrix(point, normal, direction=direct) >>> P2 = projection_matrix(point, normal, perspective=persp) >>> P3 = projection_matrix(point, normal, perspective=persp, pseudo=True) >>> is_same_transform(P2, numpy.dot(P0, P3)) True >>> P = projection_matrix([3, 0, 0], [1, 1, 0], [1, 0, 0]) >>> v0 = (numpy.random.rand(4, 5) - 0.5) * 20 >>> v0[3] = 1 >>> v1 = numpy.dot(P, v0) >>> numpy.allclose(v1[1], v0[1]) True >>> numpy.allclose(v1[0], 3-v1[1]) True ``` -------------------------------- ### affine_matrix_from_points Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d._gohlketransforms.html Calculate an affine transformation matrix to register two point sets. ```APIDOC ## affine_matrix_from_points(v0, v1, shear=True, scale=True, usesvd=True) ### Description Return affine transform matrix to register two point sets. ### Parameters #### Query Parameters - **v0** (array) - Required - First point set (ndims, *) - **v1** (array) - Required - Second point set (ndims, *) - **shear** (bool) - Optional - Include shear in transformation - **scale** (bool) - Optional - Include scale in transformation - **usesvd** (bool) - Optional - Use SVD for minimization ``` -------------------------------- ### Matrix multiplication with column vectors Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d.derivations.html Demonstrates how rotation matrices operate on column vectors to produce rotated vectors. Assumes R is a 3x3 rotation matrix and v is a 3xN matrix of N vectors. ```python vdash = np.dot(R, v) ``` -------------------------------- ### transforms3d API Modules Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d.derivations.html Overview of the available modules within the transforms3d library for handling 3D transformations. ```APIDOC ## transforms3d API Reference ### Description The transforms3d library provides various modules for geometric transformations. Below are the available modules: - **affines**: Affine transformation matrices - **axangles**: Axis-angle representations - **euler**: Euler angle conversions - **quaternions**: Quaternion operations - **reflections**: Reflection matrices - **shears**: Shear transformations - **taitbryan**: Tait-Bryan angle conversions - **zooms**: Scaling and zoom transformations - **utils**: General utility functions ``` -------------------------------- ### zfdir2mat Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d.zooms.html Creates a 3x3 matrix to scale by a factor around an origin in a given direction. ```APIDOC ## zfdir2mat ### Description Return matrix to scale by factor around origin in direction. Use factor == -1 for point symmetry. ### Method POST (assumed, as it constructs a matrix) ### Endpoint /transforms3d/zooms/zfdir2mat ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **factor** (scalar) - Required - factor to zoom by. - **direction** (None or array-like, shape (3,), optional) - Optional - direction of zoom. If None, uniform scaling is applied. ### Request Example ```json { "factor": 2.0, "direction": [1,0,0] } ``` ### Response #### Success Response (200) - **mat** (array, shape (3,3)) - 3x3 transformation matrix implementing zooms. #### Response Example ```json { "mat": [[2,0,0],[0,2,0],[0,0,2]] } ``` ``` -------------------------------- ### Quaternion Utility Functions Source: http://matthew-brett.github.io/transforms3d/_sources/reference/transforms3d.quaternions.rst.txt Functions for creating identity quaternions, checking for unit quaternions, and filling positive components. ```APIDOC ## fillpositive ### Description Ensures the real component of a quaternion is positive. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters (No specific parameters listed in the provided text) ### Request Example N/A ### Response (No specific response details listed in the provided text) ## qeye ### Description Returns the identity quaternion. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters (No specific parameters listed in the provided text) ### Request Example N/A ### Response (No specific response details listed in the provided text) ## qisunit ### Description Checks if a quaternion is a unit quaternion. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters (No specific parameters listed in the provided text) ### Request Example N/A ### Response (No specific response details listed in the provided text) ``` -------------------------------- ### Compose transformation matrix Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d._gohlketransforms.html Constructs a transformation matrix from individual components like scale, shear, angles, and translation. ```python >>> scale = numpy.random.random(3) - 0.5 >>> shear = numpy.random.random(3) - 0.5 >>> angles = (numpy.random.random(3) - 0.5) * (2*math.pi) >>> trans = numpy.random.random(3) - 0.5 >>> persp = numpy.random.random(4) - 0.5 >>> M0 = compose_matrix(scale, shear, angles, trans, persp) >>> result = decompose_matrix(M0) >>> M1 = compose_matrix(*result) >>> is_same_transform(M0, M1) True ``` -------------------------------- ### Utility Functions Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d.derivations.html Utility functions for matrix manipulation within derivations. ```APIDOC ## `make_matrix` ### Description Creates a matrix with a given name prefix and dimensions. ### Method Not applicable (function) ### Endpoint Not applicable (function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None (returns a matrix) ### Response Example None ## `matrices_equal` ### Description Checks if two matrices are equal. ### Method Not applicable (function) ### Endpoint Not applicable (function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None (returns boolean) ### Response Example None ## `matrix_simplify` ### Description Simplifies a given matrix. ### Method Not applicable (function) ### Endpoint Not applicable (function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None (returns simplified matrix) ### Response Example None ``` -------------------------------- ### Quaternion Manipulation Functions Source: http://matthew-brett.github.io/transforms3d/_sources/reference/transforms3d.quaternions.rst.txt Functions for quaternion arithmetic, normalization, and exponentiation/logarithm. ```APIDOC ## qconjugate ### Description Computes the conjugate of a quaternion. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters (No specific parameters listed in the provided text) ### Request Example N/A ### Response (No specific response details listed in the provided text) ## qexp ### Description Computes the exponential of a quaternion. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters (No specific parameters listed in the provided text) ### Request Example N/A ### Response (No specific response details listed in the provided text) ## qinverse ### Description Computes the inverse of a quaternion. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters (No specific parameters listed in the provided text) ### Request Example N/A ### Response (No specific response details listed in the provided text) ## qlog ### Description Computes the logarithm of a quaternion. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters (No specific parameters listed in the provided text) ### Request Example N/A ### Response (No specific response details listed in the provided text) ## qmult ### Description Performs quaternion multiplication. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters (No specific parameters listed in the provided text) ### Request Example N/A ### Response (No specific response details listed in the provided text) ## qnorm ### Description Computes the norm (magnitude) of a quaternion. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters (No specific parameters listed in the provided text) ### Request Example N/A ### Response (No specific response details listed in the provided text) ## qpow ### Description Computes a quaternion raised to a power. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters (No specific parameters listed in the provided text) ### Request Example N/A ### Response (No specific response details listed in the provided text) ``` -------------------------------- ### clip_matrix Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d._gohlketransforms.html Generates a matrix to obtain normalized device coordinates from a frustum. ```APIDOC ## clip_matrix ### Description Return a matrix to obtain normalized device coordinates from a frustum. The frustum bounds are axis-aligned along x (left, right), y (bottom, top) and z (near, far). ### Parameters #### Arguments - **left** (float) - Required - Left frustum bound. - **right** (float) - Required - Right frustum bound. - **bottom** (float) - Required - Bottom frustum bound. - **top** (float) - Required - Top frustum bound. - **near** (float) - Required - Near frustum bound. - **far** (float) - Required - Far frustum bound. - **perspective** (bool) - Optional - If True, the frustum is a truncated pyramid. ``` -------------------------------- ### compose_matrix Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d._gohlketransforms.html Creates a transformation matrix from a sequence of transformation components. ```APIDOC ## compose_matrix ### Description Return a transformation matrix from a sequence of transformations. This is the inverse of the decompose_matrix function. ### Parameters #### Arguments - **scale** (vector) - Optional - Vector of 3 scaling factors. - **shear** (list) - Optional - List of shear factors for x-y, x-z, y-z axes. - **angles** (list) - Optional - List of Euler angles about static x, y, z axes. - **translate** (vector) - Optional - Translation vector along x, y, z axes. - **perspective** (vector) - Optional - Perspective partition of matrix. ``` -------------------------------- ### Compose Affine Matrix from T, R, Z Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d.affines.html Use `compose` to create an affine transformation matrix from translation, rotation, and zoom components. This is useful for building transformation matrices for 3D graphics or other applications requiring matrix composition. ```python >>> T = [20, 30, 40] # translations >>> R = [[0, -1, 0], [1, 0, 0], [0, 0, 1]] # rotation matrix >>> Z = [2.0, 3.0, 4.0] # zooms >>> A = compose(T, R, Z) >>> A array([[ 0., -3., 0., 20.], [ 2., 0., 0., 30.], [ 0., 0., 4., 40.], [ 0., 0., 0., 1.]]) ``` -------------------------------- ### transforms3d API Overview Source: http://matthew-brett.github.io/transforms3d/reference/index.html The library is organized into modules handling specific transformation types such as affines, quaternions, Euler angles, and axis-angles. ```APIDOC ## transforms3d API Modules ### Description The transforms3d library is structured into several modules, each focusing on a specific mathematical representation of 3D transformations. ### Modules - **_gohlketransforms**: Low-level transformation utilities. - **affines**: Functions for composing and decomposing affine matrices. - **axangles**: Conversions between axis-angle and other formats. - **euler**: Euler angle rotation conventions and conversions. - **quaternions**: Quaternion arithmetic and conversion functions. - **reflections**: Reflection matrix utilities. - **shears**: Shear matrix utilities. - **taitbryan**: Tait-Bryan angle rotation conventions. - **zooms**: Zoom/scaling factor utilities. ``` -------------------------------- ### Quaternion Conversion Functions Source: http://matthew-brett.github.io/transforms3d/_sources/reference/transforms3d.quaternions.rst.txt Functions for converting between axis-angle, matrices, and quaternions. ```APIDOC ## axangle2quat ### Description Converts an axis-angle representation to a quaternion. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters (No specific parameters listed in the provided text) ### Request Example N/A ### Response (No specific response details listed in the provided text) ## mat2quat ### Description Converts a rotation matrix to a quaternion. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters (No specific parameters listed in the provided text) ### Request Example N/A ### Response (No specific response details listed in the provided text) ## quat2axangle ### Description Converts a quaternion to an axis-angle representation. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters (No specific parameters listed in the provided text) ### Request Example N/A ### Response (No specific response details listed in the provided text) ## quat2mat ### Description Converts a quaternion to a rotation matrix. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters (No specific parameters listed in the provided text) ### Request Example N/A ### Response (No specific response details listed in the provided text) ``` -------------------------------- ### Create Orthogonalization Matrix Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d._gohlketransforms.html Generate an orthogonalization matrix for crystallographic cell coordinates using `orthogonalization_matrix`. Angles should be provided in degrees. ```python >>> O = orthogonalization_matrix([10, 10, 10], [90, 90, 90]) >>> numpy.allclose(O[:3, :3], numpy.identity(3, float) * 10) True >>> O = orthogonalization_matrix([9.8, 12.0, 15.5], [87.2, 80.7, 69.7]) >>> numpy.allclose(numpy.sum(O), 43.063229) True ``` -------------------------------- ### Calculate Affine Matrix from Point Sets Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d._gohlketransforms.html Computes an affine transformation matrix to register two sets of points, supporting optional shear, scale, and SVD-based minimization. ```python >>> v0 = [[0, 1031, 1031, 0], [0, 0, 1600, 1600]] >>> v1 = [[675, 826, 826, 677], [55, 52, 281, 277]] >>> affine_matrix_from_points(v0, v1) array([[ 0.14549, 0.00062, 675.50008], [ 0.00048, 0.14094, 53.24971], [ 0. , 0. , 1. ]]) >>> T = translation_matrix(numpy.random.random(3)-0.5) >>> R = random_rotation_matrix(numpy.random.random(3)) >>> S = scale_matrix(random.random()) >>> M = concatenate_matrices(T, R, S) >>> v0 = (numpy.random.rand(4, 100) - 0.5) * 20 >>> v0[3] = 1 >>> v1 = numpy.dot(M, v0) >>> v0[:3] += numpy.random.normal(0, 1e-8, 300).reshape(3, -1) >>> M = affine_matrix_from_points(v0[:3], v1[:3]) >>> numpy.allclose(v1, numpy.dot(M, v0)) True ``` -------------------------------- ### Convert Euler angles to quaternion Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d.taitbryan.html Returns a quaternion in (w, x, y, z) format corresponding to the given Euler angles (z, y, x). Uses the z, then y, then x static-frame rotation convention. ```python >>> quat = euler2quat(zrot, yrot, xrot) ``` -------------------------------- ### TBZYX Namespace Source: http://matthew-brett.github.io/transforms3d/reference/transforms3d.euler.html Namespace for Tait-Bryan ZYX Euler angle convention functions, inheriting from EulerFuncs. ```APIDOC ## class transforms3d.euler.TBZYX ### Description Namespace for Tait-Bryan ZYX Euler angle convention functions. ### Methods * **__init__()**: Initialize Tait-Bryan ZYX namespace. * **euler2mat(ai, aj, ak)**: Return rotation matrix from Euler angles. See `transforms3d.taitbryan.euler2mat()` for details. * **euler2quat(ai, aj, ak)**: Return quaternion from Euler angles. See `transforms3d.taitbryan.euler2quat()` for details. * **mat2euler(mat)**: Return Euler angles from rotation matrix mat. See `transforms3d.taitbryan.mat2euler()` for details. ```