normalize
On this page

normalize

Function

Returns a unit vector in the same direction as the input, computed by dividing each component by the vector's length.

The signature and the sentence under each name are the compiler's own text at commit 26de7be8.

Syntax

declare function normalize<V extends vec2 | vec3 | vec4>(a0: V): V
declare function normalize<T extends Numeric | Vec64Any>(a: T): T

A signature may name a type the ambient file declares for its own use. These are those declarations.

Vec64Any
type Vec64Any = vec2f64 | vec3f64 | vec4f64
Numeric
type Numeric = number | vec2 | vec3 | vec4 | vec2i | vec3i | vec4i | vec2u | vec3u | vec4u

Parameters

  • a VT

Return value

VT

Description

The zero vector produces NaN when normalized. Also accepts f64 operands.

Targets

WGSL
normalize(a)
GLSL ES 3.00
normalize(a)

Examples

See also

Edit this page Report a problem