From 98be4c17918e2400a214db07f675b42e6aaf2ade Mon Sep 17 00:00:00 2001 From: Date: Mon, 20 Nov 2006 03:16:08 +0000 Subject: [PATCH] Added Helpers.VecMag(LLVector3 vector) and VecNorm(LLVector3 vector) git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@605 52acb1d6-8a22-11de-b505-999d5b087335 --- libsecondlife-cs/Helpers.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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