as_coord2d() casts to a Coord2D class object
Usage
as_coord2d(x, ...)
# S3 method for class 'angle'
as_coord2d(x, radius = 1, ...)
# S3 method for class 'character'
as_coord2d(x, ...)
# S3 method for class 'complex'
as_coord2d(x, ...)
# S3 method for class 'Coord3D'
as_coord2d(
x,
permutation = c("xyz", "xzy", "yxz", "yzx", "zyx", "zxy"),
...,
plane = as_plane3d("xy-plane"),
scale = 0,
alpha = angle(45, "degrees")
)
# S3 method for class 'data.frame'
as_coord2d(x, ...)
# S3 method for class 'list'
as_coord2d(x, ...)
# S3 method for class 'matrix'
as_coord2d(x, ...)
# S3 method for class 'numeric'
as_coord2d(x, y = rep_len(0, length(x)), ...)
# S3 method for class 'Coord2D'
as_coord2d(x, ...)Arguments
- x
An object that can be cast to a Coord2D class object such as a matrix or data frame of coordinates.
- ...
Further arguments passed to or from other methods
- radius
A numeric vector of radial distances.
- 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). This permutation is applied before the (oblique) projection.
- plane
A Plane3D class object representing the plane you wish to project to or an object coercible to one using
as_plane3d(plane, ...)such as "xy-plane", "xz-plane", or "yz-plane".- scale
Oblique 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”.- 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.- y
Numeric vector of y-coordinates to be used.
Value
A Coord2D class object
Examples
df <- data.frame(x = sample.int(10, 3),
y = sample.int(10, 3))
as_coord2d(df)
#> <Coord2D[3]>
#> x y w
#> [1,] 4 4 1
#> [2,] 7 7 1
#> [3,] 6 8 1
as_coord2d(complex(real = 3, imaginary = 2))
#> <Coord2D[1]>
#> x y w
#> 3 2 1
as_coord2d(angle(90, "degrees"), radius = 2)
#> <Coord2D[1]>
#> x y w
#> 0 2 1
as_coord2d(as_coord3d(1, 2, 2), alpha = degrees(90), scale = 0.5)
#> <Coord2D[1]>
#> x y w
#> 1 3 1
