Coord2D is an R6::R6Class() object representing two-dimensional points
represented by Cartesian Coordinates.
Active bindings
xywA three-column matrix representing the homogeneous coordinates. The first two columns are "x" and "y" coordinates and the third column is all ones.
xA numeric vector of x-coordinates.
yA numeric vector of y-coordinates.
Methods
Coord2D$new()
Usage
Coord2D$new(xyw)Coord2D$permute()
Usage
Coord2D$permute(permutation = c("xy", "yx"))Coord2D$print()
Arguments
nNumber of coordinates to print. If
NULLprint all of them....Passed to
format.default().
Coord2D$project()
Usage
Coord2D$project(line = as_line2d("x-axis"), ..., scale = 0)Arguments
lineA Line2D object of length one representing the line you with to reflect across or project to or an object coercible to one by
as_line2d(line, ...)such as "x-axis" or "y-axis"....Passed to
project2d()scaleOblique projection scale factor. A degenerate
0value indicates an orthogonal projection.
Coord2D$reflect()
Usage
Coord2D$reflect(line = as_line2d("x-axis"), ...)Arguments
lineA Line2D object of length one representing the line you with to reflect across or project to or an object coercible to one by
as_line2d(line, ...)such as "x-axis" or "y-axis"....Passed to
reflect2d().
Coord2D$rotate()
Usage
Coord2D$rotate(theta = angle(0), ...)Arguments
thetaAn
angle()object of length one or an object coercible to one byas_angle(theta, ...)....Passed to
as_angle().
Coord2D$translate()
Usage
Coord2D$translate(x = as_coord2d(0, 0), ...)Coord2D$transform()
Usage
Coord2D$transform(mat = transform2d())Arguments
matA 3x3 matrix representing a post-multiplied affine transformation matrix. The last column must be equal to
c(0, 0, 1). If the last row isc(0, 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 2x2 matrix (such as a 2x2 post-multiplied 2D rotation matrix) we'll quietly add a final column/row equal toc(0, 0, 1).
Examples
p <- as_coord2d(x = rnorm(100, 2), y = rnorm(100, 2))
print(p, n = 10)
#> <Coord2D[100]>
#> x y w
#> [1,] 1.6127864 1.57061991 1
#> [2,] 1.2145673 3.36046133 1
#> [3,] 0.9432631 1.92914257 1
#> [4,] 1.2044586 1.72784632 1
#> [5,] 0.2437246 -0.44668003 1
#> [6,] 1.3094621 2.06548664 1
#> [7,] 1.4414580 0.90149110 1
#> [8,] 1.4633367 1.36682182 1
#> [9,] 2.2271271 -0.06365445 1
#> [10,] 2.9784549 4.64893203 1
pc <- mean(p) # Centroid
# method chained affine transformation matrices are auto-pre-multiplied
p$
translate(-pc)$
shear(x = 1, y = 0)$
reflect("x-axis")$
rotate(90, "degrees")$
print(n = 10)
#> <Coord2D[100]>
#> x y w
#> [1,] -0.39933268 -0.9014031 1
#> [2,] 1.39050873 0.4902193 1
#> [3,] -0.04081003 -1.2124037 1
#> [4,] -0.24210628 -1.1525045 1
#> [5,] -2.41663263 -4.2877649 1
#> [6,] 0.09553404 -0.7098607 1
#> [7,] -1.06846150 -1.7418603 1
#> [8,] -0.60313077 -1.2546509 1
#> [9,] -2.03360705 -1.9213367 1
#> [10,] 2.67897943 3.5425775 1
