Convert Spherical Coordinates to Cartesian Vector
Source:R/coordinates.R, R/rotation.R
astro_vector_from_sphere.RdGiven spherical coordinates and a time at which they are valid, returns a vector of Cartesian coordinates. The returned value includes the time, as required by the vector structure.
Given spherical coordinates and a time at which they are valid, returns a vector of Cartesian coordinates. The returned value includes the time, as required by the vector type.
Value
A list representing a Cartesian vector with elements:
x,y,z: Cartesian coordinates in AUt: Time valuestatus: Status code (0 = success)
A list representing a vector with components:
- x
The Cartesian x-coordinate in AU
- y
The Cartesian y-coordinate in AU
- z
The Cartesian z-coordinate in AU
- t
The date and time (POSIXct) at which this vector is valid
- status
Status code (0 = success)
Examples
sphere <- list(lat = 45, lon = 90, dist = 1.5)
time <- as.POSIXct("2024-01-01 12:00:00", tz = "UTC")
vec <- astro_vector_from_sphere(sphere, time)
# Convert spherical to Cartesian
sphere <- list(lat = 0, lon = 0, dist = 1)
time <- as.POSIXct("2024-01-01", tz = "UTC")
vec <- astro_vector_from_sphere(sphere, time)