Learn R Programming

affiner (version 0.1.3)

Coord1D: 1D coordinate vector R6 Class

Description

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

Arguments

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


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


Method print()

Usage

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

Arguments

n

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

...

Passed to format.default().


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


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


Method scale()

Usage

Coord1D$scale(x_scale = 1)

Arguments

x_scale

Scaling factor to apply to x coordinates


Method 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


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


Method 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

Run this code
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