Simple-Transforms API#

Transform Matrix Creation#

Todo

Create visuals demonstrating each of the transformations

eye(dtype=<class 'flint'>)#

Create an identify affine transform

from_mat(mat, dtype=<class 'flint'>)#

Create a new generic affine transform from a 4x4, 3x4 or 3x3 matrix

  • A 3x3 matrix will only specify the linear transformation.

  • A 3x4 matrix will specify the linear transformation and translation.

  • A 4x4 will specify the linear transformation, translation, and perspective

    transformation.

Parameters:

mat – The input matrix (any properly shaped nested sequence type).

Returns:

An AffineTransform object corresponding to the matrix”

trans(d, center=None, dtype=<class 'flint'>)#

Create a new pure translation transformation.

Parameters:
  • d – A 3-length sequence [dx, dy, dz]

  • center – Ignored

Returns:

An pure translation AffineTransformation.

scale(s, center=None, dtype=<class 'flint'>)#

Create a new pure scaling transformation.

Parameters:
  • s – A scalar or 3-length sequence [sx, sy, sz] for scaling along each n

  • center – Optional 3-length center position [cx, cy, cz] for the scaling transform

Returns:

A scaling if AffineTransformation.

rot(axis, angle, center=None, dtype=<class 'flint'>)#

Create a new pure rotation transformation.

Parameters:
  • axis – The character ‘x’,’y’,’z’ or a three length vector [ax, ay, az]

  • angle – The angle in radians to rotate

  • center – Optional 3-length position [cx, cy, cz] for to specify a point on the axix of rotation

Returns:

A rotation AffineTransformation.

refl(n, center=None, dtype=<class 'flint'>)#

Create a new pure reflection transformation.

Parameters:
  • normal – The character ‘x’,’y’,’z’ or a 3 length [ux, uy, uz] vector for the normal vector for the reflection plane.

  • center – Optional 3-length center position [cx, cy, cz] a point on the plane of reflection operation.

Returns:

A skew AffineTransformation.

skew(n, s, center=None, dtype=<class 'flint'>)#

Create a new pure skew transformation.

Parameters:
  • n – The character ‘x’,’y’,’z’ or a 3 length [nx, ny, nz] normal vector to define the skew (shear) plane.

  • s – A 3 length [sx, sy, sz] vector for the skew direction.

  • center – Optional 3-length center position [cx, cy, cz] for the center of the skew operation.

Returns:

A skew AffineTransformation.

Todo

Add projective transformations to matrix creation routines

Transform Matrix Tools#

combine(lhs, rhs)#

Combine two affine transforms into a single transform.

This is simply the matrix multiplication of the two transforms, and so the

order of the two transforms matters. The resulting transform is the same as applying the right-hand-side transform first, then the left-hand-side.

Parameters:
  • lhs – The left-hand-side affine transform

  • rhs – The right-hand-side affine transform

Returns:

The resulting combined transform

transform_reduce(transforms)#

Reduce a sequence of affine transforms into a single affine transform.

This is the same as a repeated matrix multiplication, and so order of the

transforms matter. The result is the same as the first transform applied followed by the second, and so on. A transform list [T0, T1, T2, …, TN] would reduce to

$T_{text{reduced}} = T_Ncdot T_{N-1] cdot ldots cdot T1 cdot T0.$

Parameters:

transforms – The sequence of affine transforms

Returns:

The resulting reduced affine transform

apply(transform, v_in)#

Apply a transform to a single vertex or array of vertices.

The vertex can either be a 3-length coordinates [x,y,z] or 4-length

homogeneous coordinates [x,y,z,1]. For a 3-length vertex the result is the same as it would be for the same homogenous coordinate.

Parameters:
  • transform – The affine transform to apply

  • v_in – The vertex or array of vertices

Returns:

A new transformed vertex or array of transformed vertices

Todo

Add a ‘decompose’ function to take a general transformation and break it down into ‘pure’ transformations using singular value decomposition

Todo

Add functions to ‘invert’ most of the creation routines to recover the parameters used from the 4x4 matrix.