as_coord3d() casts to a Coord3D class object
Usage
as_coord3d(x, ...)
# S3 method for class 'angle'
as_coord3d(x, radius = 1, inclination = NULL, z = NULL, ...)
# S3 method for class 'character'
as_coord3d(x, ...)
# S3 method for class 'data.frame'
as_coord3d(x, ..., z = NULL)
# S3 method for class 'list'
as_coord3d(x, ..., z = NULL)
# S3 method for class 'matrix'
as_coord3d(x, ...)
# S3 method for class 'numeric'
as_coord3d(x, y = rep_len(0, length(x)), z = rep_len(0, length(x)), ...)
# S3 method for class 'Coord3D'
as_coord3d(x, ...)
# S3 method for class 'Coord2D'
as_coord3d(x, z = rep_len(0, length(x)), ...)Arguments
- x
An object that can be cast to a Coord3D class object such as a matrix or data frame of coordinates.
- ...
Further arguments passed to or from other methods
- radius
A numeric vector. If
inclinationis notNULLrepresents spherical distances of spherical coordinates and ifzis notNULLrepresents radial distances of cylindrical coordinates.- inclination
Spherical coordinates inclination angle aka polar angle.
xrepresents the azimuth aka azimuthal angle.- z
Numeric vector of z-coordinates to be used
- y
Numeric vector of y-coordinates to be used if
hasName(x, "z")isFALSE.
Value
A Coord3D class object
Examples
as_coord3d(x = 1, y = 2, z = 3)
#> <Coord3D[1]>
#> x y z w
#> 1 2 3 1
df <- data.frame(x = sample.int(10, 3),
y = sample.int(10, 3),
z = sample.int(10, 3))
as_coord3d(df)
#> <Coord3D[3]>
#> x y z w
#> [1,] 1 3 3 1
#> [2,] 10 9 7 1
#> [3,] 8 5 9 1
# Cylindrical coordinates
as_coord3d(degrees(90), z = 1, radius = 1)
#> <Coord3D[1]>
#> x y z w
#> 0 1 1 1
# Spherical coordinates
as_coord3d(degrees(90), inclination = degrees(90), radius = 1)
#> <Coord3D[1]>
#> x y z w
#> 0 1 0 1
