Spherical namespace

Working with spherical coordinate and angles.

Functions

auto rad2deg(float value) -> float
Convert radians to degrees.
auto deg2rad(float value) -> float
Convert degrees to radians.
template<typename T>
auto sincos(T arg) -> std::pair<T, T>
Return the sine and cosine in a single function call.
template<typename T>
auto theta(const Vec3<T>& v) -> T
template<typename T>
auto cos_theta(const Vec3<T>& v) -> T
template<typename T>
auto sin_theta(const Vec3<T>& v) -> T
template<typename T>
auto tan_theta(const Vec3<T>& v) -> T
template<typename T>
auto sin_theta2(const Vec3<T>& v) -> T
template<typename T>
auto phi(const Vec3<T>& v) -> T
template<typename T>
auto sin_phi(const Vec3<T>& v) -> T
template<typename T>
auto cos_phi(const Vec3<T>& v) -> T
template<typename T>
auto sin_phi2(const Vec3<T>& v) -> T
template<typename T>
auto cos_phi2(const Vec3<T>& v) -> T
template<typename T>
auto spherical_coordinates_to_direction(const Vec2<T>& phi_theta) -> Vec3<T>
Convert spherical (phi,theta) coordinates to a unit direction in Cartesian coordinates.
template<typename T>
auto direction_to_spherical_coordinates(const Vec3<T>& v) -> Vec2<T>
Convert a unit direction from Cartesian coordinates to spherical (phi,theta) coordinates.

Function documentation

template<typename T>
std::pair<T, T> Spherical::sincos(T arg)

Return the sine and cosine in a single function call.

template<typename T>
T Spherical::theta(const Vec3<T>& v)

Parameters
in Unit direction vector in local coordinates
Returns T The theta parameter in spherical coordinates

template<typename T>
T Spherical::cos_theta(const Vec3<T>& v)

Parameters
in Unit direction vector in local coordinates
Returns T Cosine of the angle between the local z axis and v

template<typename T>
T Spherical::sin_theta(const Vec3<T>& v)

Parameters
in Unit direction vector in local coordinates
Returns T Sine of the angle between the local z axis and v

template<typename T>
T Spherical::tan_theta(const Vec3<T>& v)

Parameters
in Unit direction vector in local coordinates
Returns T Tangent of the angle between the local z axis and v

template<typename T>
T Spherical::sin_theta2(const Vec3<T>& v)

Parameters
in Unit direction vector in local coordinates
Returns T Squared sine of the angle between the local z axis and v

template<typename T>
T Spherical::phi(const Vec3<T>& v)

Parameters
in Direction vector in local coordinates (need not be unit length)
Returns T The phi parameter in spherical coordinates

template<typename T>
T Spherical::sin_phi(const Vec3<T>& v)

Parameters
in Unit direction vector in local coordinates
Returns T Sine of the phi parameter in spherical coordinates

template<typename T>
T Spherical::cos_phi(const Vec3<T>& v)

Parameters
in Unit direction vector in local coordinates
Returns T Cosine of the phi parameter in spherical coordinates

template<typename T>
T Spherical::sin_phi2(const Vec3<T>& v)

Parameters
in Unit direction vector in local coordinates
Returns T Squared sine of the phi parameter in spherical coordinates

template<typename T>
T Spherical::cos_phi2(const Vec3<T>& v)

Parameters
in Unit direction vector in local coordinates
Returns T Squared cosine of the phi parameter in spherical coordinates

template<typename T>
Vec3<T> Spherical::spherical_coordinates_to_direction(const Vec2<T>& phi_theta)

Convert spherical (phi,theta) coordinates to a unit direction in Cartesian coordinates.

Parameters
phi_theta in The spherical angles with $\phi \in [0,2\pi)$ and $\theta \in [0, \pi]$ . $\theta = 0 \mapsto (0,0,1)$ and $\theta = 0 \mapsto (0,0,-1)$ .
Returns The corresponding unit-length direction vector in Cartesian coordinates.

template<typename T>
Vec2<T> Spherical::direction_to_spherical_coordinates(const Vec3<T>& v)

Convert a unit direction from Cartesian coordinates to spherical (phi,theta) coordinates.

Parameters
in The direction vector in Cartesian coordinates (assumed to be unit length)
Returns The spherical angles with $\phi \in [0,2\pi)$ and $\theta \in [0, \pi]$ . $\theta = 0 \mapsto (0,0,1)$ and $\theta = 0 \mapsto (0,0,-1)$ .