pyg4ometry.transformation

Functions

rad2deg(rad)

Convert rad in radians into degrees

deg2rad(deg)

Convert deg in degrees into radians

grad2rad(gradians)

Convert rad in gradians into radians

tbxyz2axisangle(rv)

Tait-Bryan x-y-z rotation to axis-angle representation

matrix2axisangle(matrix)

Convert 3x3 transformation matrix to axis angle representation

axisangle2matrix(axis, angle)

Convert axis angle to transformation matrix

matrix2tbxyz(matrix)

Convert rotation matrix to Tait-Bryan angles.

axisangle2tbxyz(axis, angle)

Convert axis and angle to tait bryan angles

tbxyz2matrix(angles)

Convert tait bryan angles to a single passive rotation matrix.

tbzyx2matrix(angles)

Convert Tait-Bryan angles to a single passive rotation matrix.

matrix_from(v_from, v_to)

Returns the rotation matrix that rotates v_from to parallel to

_rodrigues_anti_parallel(v_from, v_to)

v_from = vector FROM

are_parallel(vector_1, vector_2[, tolerance])

Check if vector vector_1 is parallel to vector vector_2 down to

are_anti_parallel(vector_1, vector_2[, tolerance])

Check if vector vector_1 is parallel to vector vector_2 down to

reverse(angles)

Invert the rotation represented by these angles.

two_fold_orientation(v1, v2, e1, e2)

matrix_from will align one vector with another, but there are

Module Contents

pyg4ometry.transformation.rad2deg(rad)

Convert rad in radians into degrees

Parameters:

rad (float) – Input in radians

Returns:

rad in degrees

Return type:

float

pyg4ometry.transformation.deg2rad(deg)

Convert deg in degrees into radians

Parameters:

deg (float) – Input in degrees

Returns:

deg in radians

Return type:

float

pyg4ometry.transformation.grad2rad(gradians)

Convert rad in gradians into radians

Parameters:

gradians (float) – Input in gradians

Returns:

gradians in radians

Return type:

float

pyg4ometry.transformation.tbxyz2axisangle(rv)

Tait-Bryan x-y-z rotation to axis-angle representation Algorithm from http://www.sedris.org/wg8home/Documents/WG80485.pdf

For converting rotation angles to an active axis/angle pair for use in pycsg. Order of rotation: x->y->z.

Parameters:

rv (float(3)) – rotation angles

Returns:

[axis,angle]

Return type:

list(list(3),float)

pyg4ometry.transformation.matrix2axisangle(matrix)

Convert 3x3 transformation matrix to axis angle representation

Parameters:

matrix (array(3,3)) – 3x3 rotation matrix array

Returns:

[axis,angle]

Return type:

list(list(3),float)

pyg4ometry.transformation.axisangle2matrix(axis, angle)

Convert axis angle to transformation matrix

Parameters:
  • axis (list/array(3)) – axis for rotation

  • angle (float) – rotation angle

Returns:

transformation matrix

Return type:

array(3,3)

pyg4ometry.transformation.matrix2tbxyz(matrix)

Convert rotation matrix to Tait-Bryan angles. Order of rotation is x -> y -> z.

Parameters:

matrix – active (positive angle = anti-clockwise rotation about that axis when looking at the axis) matrix.

Returns:

[x, y, z] Tait-Bryan angles in a list.

Return type:

list(3)

pyg4ometry.transformation.axisangle2tbxyz(axis, angle)

Convert axis and angle to tait bryan angles

Parameters:
  • axis (list/array(3)) – axis for rotation

  • angle (float) – rotation angle

Returns:

tait bryan angles (x-y-z)

Return type:

array(3)

pyg4ometry.transformation.tbxyz2matrix(angles)

Convert tait bryan angles to a single passive rotation matrix. rotation order = x -> y -> z.

Parameters:

angles – list of angles: x, y, z

Returns:

rotation matrix

Return type:

array(3,3)

pyg4ometry.transformation.tbzyx2matrix(angles)

Convert Tait-Bryan angles to a single passive rotation matrix. rotation order = x -> y -> z.

Parameters:

angles – list of angles: x, y, z

Returns:

rotation matrix

Return type:

array(3,3)

pyg4ometry.transformation.matrix_from(v_from, v_to)

Returns the rotation matrix that rotates v_from to parallel to v_to.

Useful for ensuring a given face points in a certain direction.

v_from and v_to should be array-like three-vectors.

pyg4ometry.transformation._rodrigues_anti_parallel(v_from, v_to)

v_from = vector FROM v_to = vector TO

source: http://en.citizendium.org/wiki/Rotation_matrix#Case_that_.22from.22_and_.22to.22_vectors_are_anti-parallel

pyg4ometry.transformation.are_parallel(vector_1, vector_2, tolerance=1e-10)

Check if vector vector_1 is parallel to vector vector_2 down to some tolerance.

Parameters:
  • vector_1 (array) – First input vector

  • vector_2 (array) – Second input vector

  • tolerance (float) – Tolerance for calculation

Returns:

if vectors are parallel

Return type:

bool

pyg4ometry.transformation.are_anti_parallel(vector_1, vector_2, tolerance=1e-10)

Check if vector vector_1 is parallel to vector vector_2 down to some tolerance.

Parameters:
  • vector_1 (array) – First input vector

  • vector_2 (array) – Second input vector

  • tolerance (float) – Tolerance for calculation

Returns:

if vectors are antiparallel

Return type:

bool

pyg4ometry.transformation.reverse(angles)

Invert the rotation represented by these angles.

pyg4ometry.transformation.two_fold_orientation(v1, v2, e1, e2)

matrix_from will align one vector with another, but there are an infinite number of such matrices that align two vectors. This further contrains the rotation by introducing a second pair of vectors.

v1 start v v2 end v e1 start e e2 end v