public static Vec4 Normalize(Vec4 vector) { float ls = vector.X * vector.X + vector.Y * vector.Y + vector.Z * vector.Z + vector.W * vector.W; float invNorm = 1.0f / (float)Math.Sqrt((double)ls); return(new Vec4( vector.X * invNorm, vector.Y * invNorm, vector.Z * invNorm, vector.W * invNorm)); }
public float Length() { if (Vector.IsHardwareAccelerated) { float ls = Vec4.Dot(this, this); return((float)System.Math.Sqrt(ls)); } else { float ls = X * X + Y * Y + Z * Z + W * W; return((float)Math.Sqrt((double)ls)); } }