Skip to main content

flipY: Y-Coordinate Inversion Functions

Vertical Axis Mirroring Transformations

The flipY functions invert the Y-coordinate while preserving other vector components. These functions handle coordinate system conversions between different graphics APIs and rendering contexts where Y-axis orientation differs.

Mathematical Definition

For any vector v=(x,y,z,w)\mathbf{v} = (x, y, z, w), the Y-flip transformation produces:

flipY(v)=(x,1y,z,w)\text{flipY}(\mathbf{v}) = (x, 1-y, z, w)

This transformation maps the range [0,1][0,1] to [1,0][1,0], effectively mirroring coordinates vertically around the center line y=0.5y = 0.5.

Function Variants

Input TypeOutputTransformation
vec2vec2(x,y)(x,1y)(x, y) \rightarrow (x, 1-y)
vec3vec3(x,y,z)(x,1y,z)(x, y, z) \rightarrow (x, 1-y, z)
vec4vec4(x,y,z,w)(x,1y,z,w)(x, y, z, w) \rightarrow (x, 1-y, z, w)
Live Editor
const fragment = () => {
      const flipped = flipYVec2(uv)
      return vec4(vec3(flipped, 0.5), 1)
}