Skip to contents

Calculates the angle measured from the positive z-axis. Points at the origin return 0.

Usage

cartesian_to_theta(x, y, z)

Arguments

x

A numeric vector of x-coordinates.

y

A numeric vector of y-coordinates.

z

A numeric vector of z-coordinates.

Value

A numeric vector of inclination angles in radians, between 0 and pi.

Examples

# On the positive z-axis, the inclination is zero
cartesian_to_theta(0, 0, 1)
#> [1] 0

# In the xy-plane, it is a quarter turn
cartesian_to_theta(1, 0, 0)
#> [1] 1.570796