center: Coordinate Centering Transformation
Converting unit coordinates to centered coordinate system
The center functions transform coordinates from the unit range to the centered range . This operation centers coordinates around the origin, essential for symmetric operations and distance calculations.
Mathematical Foundation
For any coordinate value in the range :
This linear transformation maps:
- (minimum)
- (center)
- (maximum)
Function Variants
Function | Input Type | Output Type | Description |
---|---|---|---|
centerFloat(x) | float | float | Centers scalar value |
centerVec2(v) | vec2 | vec2 | Centers 2D vector components |
centerVec3(v) | vec3 | vec3 | Centers 3D vector components |
ライブエディター
const fragment = () => { const centered = centerVec2(uv) const voronoi = centered.length().mul(centered.x.mul(centered.y).mul(100)).fract() const pattern = voronoi.step(0.8) return vec4(vec3(pattern), 1) }