NORMALIZE(3Cg)

NAME
normalize - normalizes a vector

SYNOPSIS
  float normalize(float v);
  float normalize(float1 v);
  float normalize(float2 v);
  float normalize(float3 v);
  float normalize(float4 v);

  half normalize(half v);
  half normalize(half1 v);
  half normalize(half2 v);
  half normalize(half3 v);
  half normalize(half4 v);

  fixed normalize(fixed v);
  fixed normalize(fixed1 v);
  fixed normalize(fixed2 v);
  fixed normalize(fixed3 v);
  fixed normalize(fixed4 v);

PARAMETERS

v   Vector to normalize.

DESCRIPTION
Returns the normalized version of a vector, meaning a vector in the same direction as the original vector but with a Euclidean length of one.

REFERENCE IMPLEMENTATION
normalize for a float3 vector could be implemented like this.

  float3 normalize(float3 v)
  {
    return rsqrt(dot(v,v))*v;
  }

PROFILE SUPPORT
normalize is supported in all profiles except fp20.

SEE ALSO
distance, dot, length, rsqrt, sqrt