normalize function
Normalize a vec4
@param {vec4} out the receiving vector @param {ReadonlyVec4} a vector to normalize @returns {vec4} out
Implementation
List<double> normalize(List<double> out, List<double> a) {
final x = a[0];
final y = a[1];
final z = a[2];
final w = a[3];
double len = x * x + y * y + z * z + w * w;
if (len > 0) {
len = 1 / math.sqrt(len);
}
out[0] = x * len;
out[1] = y * len;
out[2] = z * len;
out[3] = w * len;
return out;
}