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

◆ to_ndc_aspect()

glm::vec3 MayaFlux::Kinesis::to_ndc_aspect ( double  window_x,
double  window_y,
uint32_t  width,
uint32_t  height 
)
inline

Convert window pixel coordinates to NDC, corrected for aspect ratio.

The shorter dimension maps to [-1, +1]; the longer dimension extends beyond. Circles drawn in NDC space remain circular in window space.

Definition at line 131 of file ViewTransform.hpp.

134{
135 const float aspect = static_cast<float>(width) / static_cast<float>(height);
136 float x = (static_cast<float>(window_x) / static_cast<float>(width)) * 2.0F - 1.0F;
137 float y = 1.0F - (static_cast<float>(window_y) / static_cast<float>(height)) * 2.0F;
138 if (aspect >= 1.0F) {
139 x *= aspect; // width is longer: extend X beyond [-1,+1]
140 } else {
141 y /= aspect; // height is longer: extend Y beyond [-1,+1]
142 }
143 return { x, y, 0.0F };
144}
uint32_t width

References width.

Referenced by MayaFlux::normalize_coords_aspect(), and MayaFlux::normalize_coords_aspect().

+ Here is the caller graph for this function: