AffineTransforms.jl

Computational geometry with affine transformations
Popularity
20 Stars
Updated Last
2 Months Ago
Started In
July 2014

AffineTransforms

Build Status

A package for working with affine transformations. For new projects, I recommend CoordinateTransformations instead.

Installation

In julia, type

Pkg.add("AffineTransforms")

Theory

An affine transformation is of the form

y = A*x + b

This is the "forward" transformation. The "inverse" transformation is therefore

x = A\(y-b)

Usage

Create an affine transformation with

tfm = AffineTransform(A, b)

The following are all different ways of computing the forward transform:

y = tfm * x
y = tformfwd(tfm, x)
y = similar(x); tformfwd!(y, tfm, x)

Similarly, the following are all different ways of computing the inverse transform:

x = tfm\y
x = tforminv(tfm, y)
x = similar(y); tforminv!(x, tfm, y)

Convenience constructors

tformeye(T, nd)
tformeye(nd)

Creates the identity transformation in nd dimensions.

tformtranslate(v)

Creates a shift (translation) transformation

tformrotate(angle)   # creates a 2d rotation
tformrotate(axis, angle)   # creates a 3d rotation
tformrotate(axis)          # creates a 3d rotation

In 3d, these constructors work with angle-axis representation, where axis is a 3-vector. When angle is provided, axis is used as if it were normalized to have unit length. If you just specify axis, then norm(axis) is used for the angle.

tformscale(scale::Real, nd)

Creates a scaling transformation, where A will have scale along the diagonal.

tformrigid(p)

Particularly useful for optimization of rigid transformations. If length(p) == 3, this creates a 2d transform, where p[1] is the rotation angle, p[2:3] are the two components of translation. If length(p) == 6, this creates a 3d transform, where p[1:3] is axis for tformrotate, and p[4:6] are the three components of translation.

Representation conversions

rotationparameters(R)

Converts a 2d or 3d rotation matrix R into an angle (in 2d) or the axis representation (in 3d).