p <- as_coord3d(x = sample(1:10, 3), y = sample(1:10, 3), z = sample(1:10, 3))
# {affiner} affine transformation matrices are post-multiplied
# and therefore should **not** go in reverse order
mat <- transform3d(diag(4L)) %*%
rotate3d("z-axis", degrees(90)) %*%
scale3d(1, 2, 1) %*%
translate3d(x = -1, y = -1, z = -1)
p1 <- p$
clone()$
transform(mat)
# The equivalent result appyling affine transformations via method chaining
p2 <- p$
clone()$
transform(diag(4L))$
rotate("z-axis", degrees(90))$
scale(1, 2, 1)$
translate(x = -1, y = -1, z = -1)
all.equal(p1, p2)
Run the code above in your browser using DataLab