Skip to contents

Computes the Euclidean distance from the origin to a point, in either two dimensions (z omitted) or three.

Usage

cartesian_to_rho(x, y, z = NULL)

Arguments

x

A numeric vector of x-coordinates.

y

A numeric vector of y-coordinates.

z

An optional numeric vector of z-coordinates (default NULL). When NULL, a two-dimensional radius is returned.

Value

A numeric vector of radii, the same length as x.

Examples

cartesian_to_rho(3, 4)
#> [1] 5

# Supplying z gives the three-dimensional radius
cartesian_to_rho(3, 4, 12)
#> [1] 13