Skip to contents

General-purpose escape hatch for an affine transform not covered by trans_translate()/trans_rotate()/trans_scale()/trans_reflect()/ trans_shear(): wraps a caller-supplied matrix directly.

Usage

trans_affine(matrix)

Arguments

matrix

A 3x3 numeric matrix in homogeneous coordinates (its third row must be c(0, 0, 1)), or a 2x3 matrix giving only the first two rows (the third row is added automatically).

Examples

# equivalent to trans_scale(2, 3)
trans_affine(matrix(c(2, 0, 0, 0, 3, 0, 0, 0, 1), nrow = 3, byrow = TRUE))
#> <sketchpad::trans>
#>  @ matrix: num [1:3, 1:3] 2 0 0 0 3 0 0 0 1

# the 2x3 form omits the trivial homogeneous third row
draw(shape_square(
  side = 1,
  trans = trans_affine(matrix(c(2, 0, 0, 0, 3, 0), nrow = 2, byrow = TRUE))
))