transform1d | R Documentation |
transform1d()
, reflect1d()
, scale2d()
,
and translate1d()
create 1D affine transformation matrix objects.
transform1d(mat = diag(2L))
project1d(point = as_point1d("origin"), ...)
reflect1d(point = as_point1d("origin"), ...)
scale1d(x_scale = 1)
translate1d(x = as_coord1d(0), ...)
mat |
A 2x2 matrix representing a post-multiplied affine transformation matrix.
The last column must be equal to |
point |
A Point1D object of length one representing the point
you with to reflect across or project to or an object coercible to one by |
... |
Passed to |
x_scale |
Scaling factor to apply to x coordinates |
x |
A Coord1D object of length one or an object coercible to one by |
transform1d()
User supplied (post-multiplied) affine transformation matrix
.
reflect1d()
Reflections across a point.
scale1d()
Scale the x-coordinates by multiplicative scale factors.
translate1d()
Translate the coordinates by a Coord1D class object parameter.
transform1d()
1D affine transformation matrix objects are meant to be
post-multiplied and therefore should not be multiplied in reverse order.
Note the Coord1D class object methods auto-pre-multiply affine transformations
when "method chaining" so pre-multiplying affine transformation matrices
to do a single cumulative transformation instead of a method chain of multiple transformations
will not improve performance as much as as it does in other R packages.
To convert a pre-multiplied 1D affine transformation matrix to a post-multiplied one
simply compute its transpose using t()
. To get an inverse transformation matrix
from an existing transformation matrix that does the opposite transformations
simply compute its inverse using solve()
.
A 2x2 post-multiplied affine transformation matrix with classes "transform1d" and "at_matrix"
p <- as_coord1d(x = sample(1:10, 3))
# {affiner} affine transformation matrices are post-multiplied
# and therefore should **not** go in reverse order
mat <- transform1d(diag(2)) %*%
scale1d(2) %*%
translate1d(x = -1)
p1 <- p$
clone()$
transform(mat)
# The equivalent result appyling affine transformations via method chaining
p2 <- p$
clone()$
transform(diag(2))$
scale(2)$
translate(x = -1)
all.equal(p1, p2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.