Spherical
Represents a point in 3D using spherical coordinates:radius
is the distance from the origin.phi
is the azimuth angle (yaw) in radians.theta
is the polar angle (pitch) from the equator in radians.
This is useful for orbital camera rigs, sampling directions on a sphere, and converting to/from Cartesian coordinates.
Properties
phi float
float phi { 0.0f }
Azimuth angle (yaw) in radians.
radius float
float radius { 1.0f }
Radial distance from the origin.
theta float
float theta { 0.0f }
Polar angle (pitch) in radians.
Functions
MakeSafe() auto
auto vglx::Spherical::MakeSafe()
Clamps theta (polar) away from the poles. Keeps theta
within (-π/2 + ε, π/2 − ε) to avoid degeneracy where the azimuth angle becomes undefined and orientation calculations (e.g. cross products for basis vectors) can break down.
Spherical() constexpr
vglx::Spherical::Spherical(float radius, float phi, float theta)
Parameter | Description |
---|---|
radius | Radial distance from the origin. |
phi | Azimuth angle (yaw) in radians. |
theta | Polar angle (pitch) in radians. |
Constructs a spherical coordinate from radius, phi, and theta.
ToVector3() auto
auto vglx::Spherical::ToVector3() const
Converts spherical to Cartesian coordinates. Convention:phi
(azimuth): 0 along +Z, increasing toward +X.theta
(polar): 0 on the equator, +π/2 at +Y.