Coord3D is an R6::R6Class() object representing three-dimensional points
represented by Cartesian Coordinates.
Active bindings
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.
Methods
Coord3D$new()
Usage
Coord3D$new(xyzw)Coord3D$permute()
Usage
Coord3D$permute(permutation = c("xyz", "xzy", "yxz", "yzx", "zyx", "zxy"))Coord3D$print()
Arguments
nNumber of coordinates to print. If
NULLprint all of them....Passed to
format.default().
Coord3D$project()
Usage
Coord3D$project(
plane = as_plane3d("xy-plane"),
...,
scale = 0,
alpha = angle(45, "degrees")
)Arguments
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)
0value indicates an orthographic projection. A value of0.5is used by a “cabinet projection” while a value of1.0is 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 withas_angle(alpha, ...). Popular angles are 45 degrees, 60 degrees, andarctangent(2)degrees.
Coord3D$reflect()
Usage
Coord3D$reflect(plane = as_plane3d("xy-plane"), ...)Arguments
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().
Coord3D$rotate()
Usage
Coord3D$rotate(axis = as_coord3d("z-axis"), theta = angle(0), ...)Arguments
axisA Coord3D class object or one that can coerced to one by
as_coord3d(axis, ...). Theaxisrepresents the axis to be rotated around.thetaAn
angle()object of length one or an object coercible to one byas_angle(theta, ...)....Passed to
rotate3d().
Coord3D$shear()
Usage
Coord3D$shear(
xy_shear = 0,
xz_shear = 0,
yx_shear = 0,
yz_shear = 0,
zx_shear = 0,
zy_shear = 0
)Arguments
xy_shearShear factor:
x = x + xy_shear * y + xz_shear * zxz_shearShear factor:
x = x + xy_shear * y + xz_shear * zyx_shearShear factor:
y = yx_shear * x + y + yz_shear * zyz_shearShear factor:
y = yx_shear * x + y + yz_shear * zzx_shearShear factor:
z = zx_shear * x + zy_shear * y + zzy_shearShear factor:
z = zx_shear * x + zy_shear * y + z
Coord3D$translate()
Usage
Coord3D$translate(x = as_coord3d(0, 0, 0), ...)Coord3D$transform()
Usage
Coord3D$transform(mat = transform3d())Arguments
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 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).
Examples
p <- as_coord3d(x = rnorm(100, 2), y = rnorm(100, 2), z = rnorm(100, 2))
print(p, n = 10)
#> <Coord3D[100]>
#> x y z w
#> [1,] 1.6438756 3.7361110 1.2884759 1
#> [2,] 0.9355358 1.1547522 2.6621788 1
#> [3,] 3.0771165 1.0384285 2.2911302 1
#> [4,] 3.1815756 3.0174911 2.1979580 1
#> [5,] 2.1983921 0.5039463 0.7964339 1
#> [6,] 1.5995948 0.8151813 1.9601830 1
#> [7,] 2.6161543 2.6302344 2.6869825 1
#> [8,] 3.9741567 4.1012525 2.7052670 1
#> [9,] 3.8846623 1.3862632 2.9914417 1
#> [10,] 0.4113795 0.3653617 3.1442490 1
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)
#> <Coord3D[100]>
#> x y z w
#> [1,] -1.9126698 -0.54472328 0.65979008 1
#> [2,] 0.6686890 -1.25306307 -0.71391285 1
#> [3,] 0.7850127 0.88851767 -0.34286428 1
#> [4,] -1.1940498 0.99297670 -0.24969205 1
#> [5,] 1.3194950 0.00979323 1.15183205 1
#> [6,] 1.0082599 -0.58900411 -0.01191701 1
#> [7,] -0.8067932 0.42755542 -0.73871652 1
#> [8,] -2.2778113 1.78555788 -0.75700106 1
#> [9,] 0.4371780 1.69606346 -1.04317573 1
#> [10,] 1.4580795 -1.77721941 -1.19598303 1
