MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ spherical()

UVField MayaFlux::Kinesis::spherical ( const glm::vec3 &  centre = glm::vec3(0.0F))
inline

Spherical projection from a centre point.

Parameters
centreWorld-space centre of the sphere
Returns
UVField: glm::vec3 -> glm::vec2

u = longitude in [0, 1], zero at +X, increasing counter-clockwise. v = latitude in [0, 1], zero at south pole, one at north pole.

Degenerate at the poles (sin(phi) -> 0) and at centre. Vertices straddling the longitude seam will show a UV discontinuity.

Definition at line 96 of file UVProjection.hpp.

97{
98 return { .fn = [centre](const glm::vec3& p) -> glm::vec2 {
99 const glm::vec3 d = p - centre;
100 const float len = glm::length(d);
101 if (len < 1e-6F)
102 return glm::vec2(0.0F);
103
104 const glm::vec3 n = d / len;
105 const float u = (glm::atan(n.z, n.x) / static_cast<float>(std::numbers::pi) + 1.0F) * 0.5F;
106 const float v = n.y * 0.5F + 0.5F;
107 return { u, v };
108 } };
109}

References MayaFlux::Kinesis::Tendency< D, R >::fn.