Apply a transformation (scale, rotation, translation) to shape coordinates.
Arguments
- x
A matrix (nx2), list of matrices, or tibble with coo columns.
- ...
Additional arguments (reserved for future use).
- .cols
Column name(s) to process when
xis a tibble. IfNULL, automatically detects columns containing coo columns.- .ldk_col
Character. Name of landmark column. If
NULL, usescolname_ldk.- transform
A list with elements
scale,rotation, andtranslation, typically fromget_transform().
Value
If
xis a single matrix: returns the transformed matrixIf
xis a list: returns a list of transformed matricesIf
xis a tibble: returns the tibble with transformed coo column(s)
Details
Applies transformation in order:
Scale (multiply coordinates by scale factor)
Rotate (by rotation angle in radians)
Translate (shift by translation vector)
Landmarks are transformed along with coordinates.
See also
get_transform() for extracting transformations
Examples
source <- matrix(c(0,0, 1,0, 1,1, 0,1), ncol=2, byrow=TRUE)
target <- source * 2 # Scaled by 2
# Extract transformation
transform <- get_transform(source, target)
# Apply to another shape
new_shape <- matrix(c(0,0, 2,0, 2,2), ncol=2, byrow=TRUE)
transformed <- get_transformed(new_shape, transform)
