as_coord3d: Cast to coord3d object

View source: R/as_coord.r

as_coord3dR Documentation

Cast to coord3d object

Description

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 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.

Value

A Coord3D class object

Examples

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)

affiner documentation built on April 4, 2025, 4:42 a.m.