Convert Cartesian Vector to Spherical Coordinates
Source:R/coordinates.R, R/rotation.R
astro_sphere_from_vector.RdGiven a Cartesian vector, returns latitude, longitude, and distance in spherical coordinates.
Given a Cartesian vector, returns latitude, longitude, and distance.
Value
A list representing spherical coordinates with elements:
lat: Latitude in degreeslon: Longitude in degrees (0-360)dist: Distance in AUstatus: Status code (0 = success)
A list with components:
- lat
Latitude angle: -90..+90 degrees
- lon
Longitude angle: 0..360 degrees
- dist
Distance in AU
- status
Status code (0 = success)
Examples
vec <- list(x = 1, y = 1, z = 1, t = as.POSIXct("2024-01-01", tz = "UTC"))
sphere <- astro_sphere_from_vector(vec)
# Convert Cartesian to spherical
vec <- list(x = 1, y = 0, z = 0, t = as.POSIXct("2024-01-01", tz = "UTC"))
sphere <- astro_sphere_from_vector(vec)