Coord3D {affiner} | R Documentation |
3D coordinate vector R6 Class
Description
Coord3D
is an R6::R6Class()
object representing three-dimensional points
represented by Cartesian Coordinates.
Active bindings
xyzw
A four-column matrix representing the homogeneous coordinates. The first three columns are "x", "y", and "z" coordinates and the fourth column is all ones.
x
A numeric vector of x-coordinates.
y
A numeric vector of y-coordinates.
z
A numeric vector of z-coordinates.
Methods
Public methods
Method new()
Usage
Coord3D$new(xyzw)
Arguments
xyzw
A matrix with four columns representing (homogeneous) coordinates. The first three columns represent x, y, and z coordinates and the last column is all ones. Column names should be "x", "y", "z", and "w".
Method permute()
Usage
Coord3D$permute(permutation = c("xyz", "xzy", "yxz", "yzx", "zyx", "zxy"))
Arguments
permutation
Either "xyz" (no permutation), "xzy" (permute y and z axes), "yxz" (permute x and y axes), "yzx" (x becomes z, y becomes x, z becomes y), "zxy" (x becomes y, y becomes z, z becomes x), "zyx" (permute x and z axes)
Method print()
Usage
Coord3D$print(n = NULL, ...)
Arguments
n
Number of coordinates to print. If
NULL
print all of them....
Passed to
format.default()
.
Method project()
Usage
Coord3D$project( plane = as_plane3d("xy-plane"), ..., scale = 0, alpha = angle(45, "degrees") )
Arguments
plane
A Plane3D object of length one representing the plane you wish to reflect across or project to or an object coercible to one using
as_plane3d(plane, ...)
such as "xy-plane", "xz-plane", or "yz-plane"....
Passed to
project3d()
.scale
Oblique projection foreshortening scale factor. A (degenerate)
0
value indicates an orthographic projection. A value of0.5
is used by a “cabinet projection” while a value of1.0
is used by a “cavalier projection”.alpha
Oblique projection angle (the angle the third axis is projected going off at). An
angle()
object or one coercible to one withas_angle(alpha, ...)
. Popular angles are 45 degrees, 60 degrees, andarctangent(2)
degrees.
Method reflect()
Usage
Coord3D$reflect(plane = as_plane3d("xy-plane"), ...)
Arguments
plane
A Plane3D object of length one representing the plane you wish to reflect across or project to or an object coercible to one using
as_plane3d(plane, ...)
such as "xy-plane", "xz-plane", or "yz-plane"....
Passed to
reflect3d()
.
Method rotate()
Usage
Coord3D$rotate(axis = as_coord3d("z-axis"), theta = angle(0), ...)
Arguments
axis
A Coord3D class object or one that can coerced to one by
as_coord3d(axis, ...)
. Theaxis
represents the axis to be rotated around.theta
An
angle()
object of length one or an object coercible to one byas_angle(theta, ...)
....
Passed to
rotate3d()
.
Method scale()
Usage
Coord3D$scale(x_scale = 1, y_scale = x_scale, z_scale = x_scale)
Arguments
x_scale
Scaling factor to apply to x coordinates
y_scale
Scaling factor to apply to y coordinates
z_scale
Scaling factor to apply to z coordinates
Method shear()
Usage
Coord3D$shear( xy_shear = 0, xz_shear = 0, yx_shear = 0, yz_shear = 0, zx_shear = 0, zy_shear = 0 )
Arguments
xy_shear
Shear factor:
x = x + xy_shear * y + xz_shear * z
xz_shear
Shear factor:
x = x + xy_shear * y + xz_shear * z
yx_shear
Shear factor:
y = yx_shear * x + y + yz_shear * z
yz_shear
Shear factor:
y = yx_shear * x + y + yz_shear * z
zx_shear
Shear factor:
z = zx_shear * x + zy_shear * y + z
zy_shear
Shear factor:
z = zx_shear * x + zy_shear * y + z
Method translate()
Usage
Coord3D$translate(x = as_coord3d(0, 0, 0), ...)
Arguments
Method transform()
Usage
Coord3D$transform(mat = transform3d())
Arguments
mat
A 4x4 matrix representing a post-multiplied affine transformation matrix. The last column must be equal to
c(0, 0, 0, 1)
. If the last row isc(0, 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 3x3 matrix (such as a 3x3 post-multiplied 3D rotation matrix) we'll quietly add a final column/row equal toc(0, 0, 0, 1)
.
Method clone()
The objects of this class are cloneable with this method.
Usage
Coord3D$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
p <- as_coord3d(x = rnorm(100, 2), y = rnorm(100, 2), z = rnorm(100, 2))
print(p, n = 10)
pc <- mean(p) # Centroid
# method chained affine transformation matrices are auto-pre-multiplied
p$
translate(-pc)$
reflect("xy-plane")$
rotate("z-axis", degrees(90))$
print(n = 10)