Learn R Programming

affiner (version 0.1.3)

as_coord3d: Cast to coord3d object

Description

as_coord3d() casts to a Coord3D class object

Usage

as_coord3d(x, ...)

# S3 method for angle as_coord3d(x, radius = 1, inclination = NULL, z = NULL, ...)

# S3 method for character as_coord3d(x, ...)

# S3 method for data.frame as_coord3d(x, ..., z = NULL)

# S3 method for list as_coord3d(x, ..., z = NULL)

# S3 method for matrix as_coord3d(x, ...)

# S3 method for numeric as_coord3d(x, y = rep_len(0, length(x)), z = rep_len(0, length(x)), ...)

# S3 method for Coord3D as_coord3d(x, ...)

# S3 method for Coord2D as_coord3d(x, z = rep_len(0, length(x)), ...)

Value

A Coord3D class object

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 inclination is not NULL represents spherical distances of spherical coordinates and if z is not NULL represents radial distances of cylindrical coordinates.

inclination

Spherical coordinates inclination angle aka polar angle. x represents 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") is FALSE.

Examples

Run this code
as_coord3d(x = 1, y = 2, z = 3)
df <- data.frame(x = sample.int(10, 3),
                 y = sample.int(10, 3),
                 z = sample.int(10, 3))
as_coord3d(df)
# Cylindrical coordinates
as_coord3d(degrees(90), z = 1, radius = 1)
# Spherical coordinates
as_coord3d(degrees(90), inclination = degrees(90), radius = 1)

Run the code above in your browser using DataLab