The distortion affects relative vectors calculated in NDC (OpenGL Normalised Device Coordinates) space at the point at which they are mapped to a rectangular (i.e. non-square) screen.
Let the metric used to measure distance be the proportion of the height of the (NDC cube)/screen. Let's say we wish to calculate a position Q in NDC which is a desired distance from P on the screen.
For a square screen, nothing needs to be done, just calculate PQ as normal. For a screen aspect ratio ≠ 1, e.g. when the screen width is greater than the screen height, the relative vector needs to be scaled in the X-axis direction.
Q Q'
| / /
| / /
| / /
| / /
P/P'_/_ _ _ _ _ _ _ _ _ _
|
For a square aspect ratio, Q = Q'.
The process that stops the distortion:
- calculate the relative vector PQ' with the desired length;
- scale PQ' in the X-axis direction by
1/(aspect ratio)
giving PQ; - add PQ to P to get Q.
The X-axis scaling from step 2 is ultimately undone by the NDC to screen space transformation applied by OpenGL.