Scaling {PlaneGeometry} | R Documentation |
R6 class representing a (non-uniform) scaling
Description
A (non-uniform) scaling is given by a center, a direction vector, and a scale factor.
Active bindings
center
get or set the center
direction
get or set the direction
scale
get or set the scale factor
Methods
Public methods
Method new()
Create a new Scaling
object.
Usage
Scaling$new(center, direction, scale)
Arguments
center
a point, the center of the scaling
direction
a vector, the direction of the scaling
scale
a number, the scale factor
Returns
A new Scaling
object.
Examples
Scaling$new(c(1,1), c(1,3), 2)
Method print()
Show instance of a Scaling
object.
Usage
Scaling$print(...)
Arguments
...
ignored
Method transform()
Transform a point or several points by the reference scaling.
Usage
Scaling$transform(M)
Arguments
M
a point or a two-column matrix of points, one point per row
Method getMatrix()
Augmented matrix of the scaling.
Usage
Scaling$getMatrix()
Returns
A 3x3 matrix.
Examples
S <- Scaling$new(c(1,1), c(2,3), 2) P <- c(1,5) S$transform(P) S$getMatrix() %*% c(P,1)
Method asAffine()
Convert the reference scaling to an Affine
object.
Usage
Scaling$asAffine()
Method scaleCircle()
Scale a circle. The result is an ellipse.
Usage
Scaling$scaleCircle(circ)
Arguments
circ
a
Circle
object
Returns
An Ellipse
object.
Method clone()
The objects of this class are cloneable with this method.
Usage
Scaling$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
References
R. Goldman, An Integrated Introduction to Computer Graphics and Geometric Modeling. CRC Press, 2009.
Examples
Q <- c(1,1); w <- c(1,3); s <- 2
S <- Scaling$new(Q, w, s)
# the center is mapped to itself:
S$transform(Q)
# any vector \code{u} parallel to the direction vector is mapped to \code{s*u}:
u <- 3*w
all.equal(s*u, S$transform(u) - S$transform(c(0,0)))
# any vector perpendicular to the direction vector is mapped to itself
wt <- 3*c(-w[2], w[1])
all.equal(wt, S$transform(wt) - S$transform(c(0,0)))
## ------------------------------------------------
## Method `Scaling$new`
## ------------------------------------------------
Scaling$new(c(1,1), c(1,3), 2)
## ------------------------------------------------
## Method `Scaling$getMatrix`
## ------------------------------------------------
S <- Scaling$new(c(1,1), c(2,3), 2)
P <- c(1,5)
S$transform(P)
S$getMatrix() %*% c(P,1)