| Shear {PlaneGeometry} | R Documentation |
R6 class representing a shear transformation
Description
A shear is given by a vertex, two perpendicular vectors, and an angle.
Active bindings
vertexget or set the vertex
vectorget or set the first vector
ratioget or set the ratio between the length of
vectorand the length of the second vector, perpendicular to the first oneangleget or set the angle
degreesget or set the
degreesfield
Methods
Public methods
Method new()
Create a new Shear object.
Usage
Shear$new(vertex, vector, ratio, angle, degrees = TRUE)
Arguments
vertexa point
vectora vector
ratioa positive number, the ratio between the length of
vectorand the length of the second vector, perpendicular to the first oneanglean angle strictly between -90 degrees and 90 degrees
degreeslogical, whether
angleis given in degrees
Returns
A new Shear object.
Examples
Shear$new(c(1,1), c(1,3), 0.5, 30)
Method print()
Show instance of a Shear object.
Usage
Shear$print(...)
Arguments
...ignored
Method transform()
Transform a point or several points by the reference shear.
Usage
Shear$transform(M)
Arguments
Ma point or a two-column matrix of points, one point per row
Method getMatrix()
Augmented matrix of the shear.
Usage
Shear$getMatrix()
Returns
A 3x3 matrix.
Examples
S <- Shear$new(c(1,1), c(1,3), 0.5, 30) S$getMatrix()
Method asAffine()
Convert the reference shear to an Affine object.
Usage
Shear$asAffine()
Examples
Shear$new(c(0,0), c(1,0), 1, atan(30), FALSE)$asAffine()
Method clone()
The objects of this class are cloneable with this method.
Usage
Shear$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
References
R. Goldman, An Integrated Introduction to Computer Graphics and Geometric Modeling. CRC Press, 2009.
Examples
P <- c(0,0); w <- c(1,0); ratio <- 1; angle <- 45
shear <- Shear$new(P, w, ratio, angle)
wt <- ratio * c(-w[2], w[1])
Q <- P + w; R <- Q + wt; S <- P + wt
A <- shear$transform(P)
B <- shear$transform(Q)
C <- shear$transform(R)
D <- shear$transform(S)
plot(0, 0, type = "n", asp = 1, xlim = c(0,1), ylim = c(0,2))
lines(rbind(P,Q,R,S,P), lwd = 2) # unit square
lines(rbind(A,B,C,D,A), lwd = 2, col = "blue") # image by the shear
## ------------------------------------------------
## Method `Shear$new`
## ------------------------------------------------
Shear$new(c(1,1), c(1,3), 0.5, 30)
## ------------------------------------------------
## Method `Shear$getMatrix`
## ------------------------------------------------
S <- Shear$new(c(1,1), c(1,3), 0.5, 30)
S$getMatrix()
## ------------------------------------------------
## Method `Shear$asAffine`
## ------------------------------------------------
Shear$new(c(0,0), c(1,0), 1, atan(30), FALSE)$asAffine()