diff --git a/libsecondlife-cs/Helpers.cs b/libsecondlife-cs/Helpers.cs index 9bea90b2..37f7a588 100644 --- a/libsecondlife-cs/Helpers.cs +++ b/libsecondlife-cs/Helpers.cs @@ -206,6 +206,23 @@ public class Helpers return (float)Math.Sqrt(xd * xd + yd * yd + zd * zd); } + /// + /// Calculates the magnitutde of the supplied vector + /// + public static float VecMag(LLVector3 vector) + { + return (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y + vector.Z * vector.Z); + } + + /// + /// Returns the supplied vector in normalized form + /// + public static LLVector3 VecDist(LLVector3 vector) + { + float mag = VecMag(vector); + return new LLVector3(vector.X/mag,vector.Y/mag,vector.Z/mag); + } + /// /// Decode a zerocoded byte array, used to decompress packets marked /// with the zerocoded flag