The function returns the unit vector v/length(v)
of vector v. If length(v) is close to zero (more precisely, if length(v) < eps), a zero vector is returned to avoid division by zero. The constant eps is set to 100*Modelica.Constants.eps. The function is based on Modelica.Math.Vectors.normalize.
function vectorNormalization input Real v[:] "Vector"; constant Real eps = 100*Modelica.Constants.eps "if |v| < eps then result = v/eps"; output Real result[size(v, 1)] "Input vector v normalized to length=1"; end vectorNormalization;