transform_matrix_affine.Rd
https://en.wikipedia.org/wiki/Transformation_matrix
https://www.cnblogs.com/bnuvincent/p/6691189.html
Rconic::`Affine planar transformations matrix`
none: ignore everything
translate: x, y, counterclockwise
scale: x, y, scale.x, scale.y
scale_xy: x, y
rotate: x, y, theta (angle of the rotation), counterclockwise
shear: x, y, counterclockwise
reflect: x, y, theta (angle from x axis), counterclockwise
transform_matrix_affine( type = c("none", "translate", "scale", "rotate", "shear", "reflect"), x = 0, y = 0, theta = NA, scale.x = 1, scale.y = 1, counterclockwise = FALSE )
type | a affine transformation type |
---|---|
x | transform value along x axis |
y | transform value along y axis |
theta | transform value of angle in radian, usually in 0 to 2pi |
scale.x, scale.y | scale size, only used for |
counterclockwise | control directions of theta or x,y if type is "shear" |
a 3*3 matrix
# eigen matrix transform_matrix_affine(type = "none")#> [,1] [,2] [,3] #> [1,] 1 0 0 #> [2,] 0 1 0 #> [3,] 0 0 1# shift matrix for convert c(0, 0) to c(1, 2) mat <- transform_matrix_affine(type = "translate", x = 1, y = 2) mat %*% c(0, 0, 1)#> [,1] #> [1,] 1 #> [2,] 2 #> [3,] 1# rotation matrix for convert c(0, 0) to c(0, 2) mat <- transform_matrix_affine(type = "rotate", x = 1, y = 1, theta = pi/2) mat %*% c(0, 0, 1)#> [,1] #> [1,] 0 #> [2,] 2 #> [3,] 1# shear for convert c(1, 1) to c(2, 1) if along x or c(1, 2) if along y mat <- transform_matrix_affine(type = "shear", x = pi*45/180, y = 0) mat <- transform_matrix_affine(type = "shear", x = 0, y = pi*45/180, counterclockwise = T) # reflect for convert c(0, 0) to c(2, 2) mat <- transform_matrix_affine(type = "reflect", x = 1, y = 1, theta = pi*45/180)