Skip to contents

Coord1D is an R6::R6Class() object representing one-dimensional points represented by Cartesian Coordinates.

Active bindings

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.

Methods


Coord1D$new()

Usage

Coord1D$new(xw)

Arguments

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".


Coord1D$print()

Usage

Coord1D$print(n = NULL, ...)

Arguments

n

Number of coordinates to print. If NULL print all of them.

...

Passed to format.default().


Coord1D$project()

Usage

Coord1D$project(point = as_point1d("origin"), ...)

Arguments

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


Coord1D$reflect()

Usage

Coord1D$reflect(point = as_point1d("origin"), ...)

Arguments

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


Coord1D$scale()

Usage

Coord1D$scale(x_scale = 1)

Arguments

x_scale

Scaling factor to apply to x coordinates


Coord1D$translate()

Usage

Coord1D$translate(x = as_coord1d(0), ...)

Arguments

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


Coord1D$transform()

Usage

Coord1D$transform(mat = transform1d())

Arguments

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).


Coord1D$clone()

The objects of this class are cloneable with this method.

Usage

Coord1D$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

p <- as_coord1d(x = rnorm(100, 2))
print(p, n = 10L)
#> <Coord1D[100]>
#>                x w
#>  [1,]  0.5999565 1
#>  [2,]  2.2553171 1
#>  [3,] -0.4372636 1
#>  [4,]  1.9944287 1
#>  [5,]  2.6215527 1
#>  [6,]  3.1484116 1
#>  [7,]  0.1781823 1
#>  [8,]  1.7526747 1
#>  [9,]  1.7558004 1
#> [10,]  1.7172946 1
pc <- mean(p) # Centroid
# method chained affine transformation matrices are auto-pre-multiplied
p$
  translate(-pc)$
  reflect("origin")$
  print(n = 10L)
#> <Coord1D[100]>
#>                 x w
#>  [1,]  1.47083272 1
#>  [2,] -0.18452785 1
#>  [3,]  2.50805282 1
#>  [4,]  0.07636049 1
#>  [5,] -0.55076352 1
#>  [6,] -1.07762240 1
#>  [7,]  1.89260687 1
#>  [8,]  0.31811451 1
#>  [9,]  0.31498881 1
#> [10,]  0.35349465 1