Skip to main content

from_spherical

Function from_spherical 

Source
pub fn from_spherical(zenith_rad: f64, azimuth_rad: f64) -> Vec3
Expand description

The unit vector $\hat{r}(\theta, \phi) = (\sin\theta \cos\phi, \sin\theta \sin\phi, \cos\theta)$ of the zenith zenith_rad (from $+z$) and the azimuth azimuth_rad (from $+x$ towards $+y$), see the module.

§Examples

use comnum_math::geometry::from_spherical;
use std::f64::consts::FRAC_PI_2;
assert_eq!(from_spherical(0.0, 1.0), [0.0, 0.0, 1.0]);
let y = from_spherical(FRAC_PI_2, FRAC_PI_2);
assert!((y[1] - 1.0).abs() < 1e-15 && y[0].abs() < 1e-15 && y[2].abs() < 1e-15);