These functions allow you to create vectors of transformation matrices for
affine transformation in 2 or 3 dimensions. Transformation matrices are used
to apply transformations to geometries using `transform()`

. Transformations
can be stacked by multiplying them together. This is generally more
performant than applying transformations one by one to geometries.
Transformations can be reversed by applying the inverse transformation to a
geometry. The inverse transformation matrix can be obtained using
`inverse()`

. Affine transformation matrices have an additional column and row
compared to linear transformation matrices. This means that matrices for 2
dimensional transformations are 3x3 and matrices for 2 dimensional
transformations are 4x4. In both cases the last row will consist of 0's and a
final scaling factor (usually 1). Rotation is generally not possible to do
while maintaining exactness as sine and cosine cannot be calculate to
exactness. 3 dimensional rotation can either be done around an axis, around
a direction, or be defining specific angles of rotation for yaw, pitch, and
roll.

affine_identity(dim = 2L) affine_matrix(x) affine_translate(vec) affine_scale(fac, dim = 2L) affine_rotate(rho, axis = NA, direction = NA, yaw = NA, pitch = NA, roll = NA) is_affine_transformation(x) as_affine_transformation(x) inverse(x) is_reflecting(x)

dim | The dimensionality of the transformation matrix |
---|---|

x | An object that can be converted to an affine transformation matrix vector. Matrices and arrays can be converted provided they have the correct dimensions. List of matrices can be converted provided that all matrices have the same dimensions and that the dimensions is correct |

vec | A vector of vectors or an object convertible to one |

fac | A scaling factor to apply |

rho | An angle in radians to rotate (counterclockwise) |

axis | For 3 dimensional rotation, which axis to rotate around |

direction | A direction vector or an object convertible to one |

yaw, pitch, roll | Angles in radians for yaw, pitch, and roll rotation. |

An `euclid_affine_transformation`

vector

# Rotate triangle around its centroid and then around the center p <- point(sample(10, 3), sample(10, 3)) t <- triangle(p[1], p[2], p[3]) ct <- centroid(t) # Assemble transformation (remember reverse order) trans <- affine_rotate(pi/4) * affine_translate(vec(ct)) * affine_rotate(2*pi/5) * affine_translate(-vec(ct)) t2 <- transform(t, trans) plot(c(t, t2), col = c("grey", "firebrick"), border = NA)