# timholy/AffineTransforms.jl

Computational geometry with affine transformations
Julia
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
 Failed to load latest commit information. src Sep 16, 2017 test Sep 16, 2017 .travis.yml Sep 16, 2017 LICENSE.md Jul 17, 2014 README.md May 24, 2017 REQUIRE Jan 30, 2017

# AffineTransforms

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).