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)

## Arguments

dim The dimensionality of the transformation matrix 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 A vector of vectors or an object convertible to one A scaling factor to apply An angle in radians to rotate (counterclockwise) For 3 dimensional rotation, which axis to rotate around A direction vector or an object convertible to one Angles in radians for yaw, pitch, and roll rotation.

## Value

An euclid_affine_transformation vector

## Examples

# Rotate triangle around its centroid and then around the center
p <- point(sample(10, 3), sample(10, 3))
t <- triangle(p, p, p)

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) 