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

◆ normalize_coords_aspect() [2/2]

MAYAFLUX_API glm::vec3 MayaFlux::normalize_coords_aspect ( double  window_x,
double  window_y,
uint32_t  window_width,
uint32_t  window_height 
)

Normalize coordinates preserving aspect ratio (useful for circular/square shapes)

Parameters
window_xX coordinate in window space
window_yY coordinate in window space
window_widthWindow width in pixels
window_heightWindow height in pixels
Returns
Aspect-corrected NDC coordinates where circles remain circular

Unlike normalize_coords(), this ensures geometric shapes maintain their proportions. The shorter dimension maps to [-1, +1], the longer dimension extends beyond.

Definition at line 78 of file Windowing.cpp.

80{
81 float aspect = aspect_ratio(window_width, window_height);
82 float norm_x = (static_cast<float>(window_x) / static_cast<float>(window_width)) * 2.0F - 1.0F;
83 float norm_y = 1.0F - (static_cast<float>(window_y) / static_cast<float>(window_height)) * 2.0F;
84
85 if (aspect > 1.0F) {
86 norm_y /= aspect;
87 } else {
88 norm_x *= aspect;
89 }
90
91 return { norm_x, norm_y, 0.0F };
92}
float aspect_ratio(uint32_t window_width, uint32_t window_height)
Get window aspect ratio (width/height)
Definition Windowing.cpp:67

References aspect_ratio().

Referenced by normalize_coords_aspect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: