Skip to contents

Moves positions (x, y) by an affine map (x', y') = L (x, y) + T, given as the 2 x 3 matrix [L | T] (see affine_from_landmarks()).

Usage

apply_affine(points, M)

Arguments

points

A data frame with columns x and y (other columns are kept), or a matrix with two columns (x, y).

M

A 2 x 3 numeric matrix.

Value

points with the moved positions, in the same form (data frame or matrix).

Examples

cells <- data.frame(x = c(0, 10), y = c(0, 0))
R <- rbind(c(0, -1, 5), c(1, 0, 0))  # turn by 90 degrees about the origin, then shift x by 5
apply_affine(cells, R)
#>   x  y
#> 1 5  0
#> 2 5 10