Coord1D
is an R6::R6Class()
object representing two-dimensional points
represented by Cartesian Coordinates.
xw
A two-column matrix representing the homogeneous coordinates. The first column is the "x" coordinates and the second column is all ones.
x
A numeric vector of x-coordinates.
new()
Coord1D$new(xw)
xw
A matrix with three columns representing (homogeneous) coordinates. The first column represents x coordinates and the last column is all ones. Column names should be "x" and "w".
print()
Coord1D$print(n = NULL, ...)
n
Number of coordinates to print. If NULL
print all of them.
...
Passed to format.default()
.
project()
Coord1D$project(point = as_point1d("origin"), ...)
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 as_point1d(point, ...)
such as "origin".
...
Passed to project1d()
.
reflect()
Coord1D$reflect(point = as_point1d("origin"), ...)
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 as_point1d(point, ...)
such as "origin".
...
Passed to reflect1d()
.
scale()
Coord1D$scale(x_scale = 1)
x_scale
Scaling factor to apply to x coordinates
translate()
Coord1D$translate(x = as_coord1d(0), ...)
x
A Coord1D object of length one or an object coercible to one by as_coord1d(x, ...)
.
...
Passed to as_coord1d(x, ...)
if x
is not a Coord1D object
transform()
Coord1D$transform(mat = transform1d())
mat
A 2x2 matrix representing a post-multiplied affine transformation matrix.
The last column must be equal to c(0, 1)
.
If the last row is c(0, 1)
you may need to transpose it
to convert it from a pre-multiplied affine transformation matrix to a post-multiplied one.
If a 1x1 matrix we'll quietly add a final column/row equal to c(0, 1)
.
clone()
The objects of this class are cloneable with this method.
Coord1D$clone(deep = FALSE)
deep
Whether to make a deep clone.
p <- as_coord1d(x = rnorm(100, 2))
print(p, n = 10L)
pc <- mean(p) # Centroid
# method chained affine transformation matrices are auto-pre-multiplied
p$
translate(-pc)$
reflect("origin")$
print(n = 10L)
Run the code above in your browser using DataLab