The Book of Shaders by Patricio Gonzalez Vivo


Length

Calculate the length of a vector

Declaration

float length(float x)  
float length(vec2 x)  
float length(vec3 x)  
float length(vec4 x)

Parameters

x specifies a vector of which to calculate the length.

Description

length() returns the length of the vector.

See Also

distance(), normalize(), Chapter 07: Shapes