Shear: R6 class representing a shear transformation

ShearR Documentation

R6 class representing a shear transformation

Description

A shear is given by a vertex, two perpendicular vectors, and an angle.

Active bindings

vertex

get or set the vertex

vector

get or set the first vector

ratio

get or set the ratio between the length of vector and the length of the second vector, perpendicular to the first one

angle

get or set the angle

degrees

get or set the degrees field

Methods

Public methods


Method new()

Create a new Shear object.

Usage
Shear$new(vertex, vector, ratio, angle, degrees = TRUE)
Arguments
vertex

a point

vector

a vector

ratio

a positive number, the ratio between the length of vector and the length of the second vector, perpendicular to the first one

angle

an angle strictly between -90 degrees and 90 degrees

degrees

logical, whether angle is 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
M

a 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
deep

Whether 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()

PlaneGeometry documentation built on Aug. 10, 2023, 1:09 a.m.