Coord3D is an R6::R6Class() object representing three-dimensional points
represented by Cartesian Coordinates.
xyzwA four-column matrix representing the homogeneous coordinates. The first three columns are "x", "y", and "z" coordinates and the fourth column is all ones.
xA numeric vector of x-coordinates.
yA numeric vector of y-coordinates.
zA numeric vector of z-coordinates.
new()Coord3D$new(xyzw)xyzwA 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".
permute()Coord3D$permute(permutation = c("xyz", "xzy", "yxz", "yzx", "zyx", "zxy"))permutationEither "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)
print()Coord3D$print(n = NULL, ...)nNumber of coordinates to print. If NULL print all of them.
...Passed to format.default().
project()Coord3D$project(
plane = as_plane3d("xy-plane"),
...,
scale = 0,
alpha = angle(45, "degrees")
)planeA 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().
scaleOblique projection foreshortening scale factor.
A (degenerate) 0 value indicates an orthographic projection.
A value of 0.5 is used by a “cabinet projection”
while a value of 1.0 is used by a “cavalier projection”.
alphaOblique projection angle (the angle the third axis is projected going off at).
An angle() object or one coercible to one with as_angle(alpha, ...).
Popular angles are 45 degrees, 60 degrees, and arctangent(2) degrees.
reflect()Coord3D$reflect(plane = as_plane3d("xy-plane"), ...)planeA 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().
rotate()Coord3D$rotate(axis = as_coord3d("z-axis"), theta = angle(0), ...)axisA Coord3D class object or one that can coerced to one by as_coord3d(axis, ...).
The axis represents the axis to be rotated around.
thetaAn angle() object of length one or an object coercible to one by as_angle(theta, ...).
...Passed to rotate3d().
scale()Coord3D$scale(x_scale = 1, y_scale = x_scale, z_scale = x_scale)x_scaleScaling factor to apply to x coordinates
y_scaleScaling factor to apply to y coordinates
z_scaleScaling factor to apply to z coordinates
shear()Coord3D$shear(
xy_shear = 0,
xz_shear = 0,
yx_shear = 0,
yz_shear = 0,
zx_shear = 0,
zy_shear = 0
)xy_shearShear factor: x = x + xy_shear * y + xz_shear * z
xz_shearShear factor: x = x + xy_shear * y + xz_shear * z
yx_shearShear factor: y = yx_shear * x + y + yz_shear * z
yz_shearShear factor: y = yx_shear * x + y + yz_shear * z
zx_shearShear factor: z = zx_shear * x + zy_shear * y + z
zy_shearShear factor: z = zx_shear * x + zy_shear * y + z
translate()Coord3D$translate(x = as_coord3d(0, 0, 0), ...)xA Coord3D object of length one or an object coercible to one by as_coord3d(x, ...).
...Passed to as_coord3d(x, ...) if x is not a Coord3D object
transform()Coord3D$transform(mat = transform3d())matA 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 is c(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 to c(0, 0, 0, 1).
clone()The objects of this class are cloneable with this method.
Coord3D$clone(deep = FALSE)deepWhether to make a deep clone.
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)
Run the code above in your browser using DataLab