From 5a3cd349535f2a696be8b670d331688add864ddb Mon Sep 17 00:00:00 2001 From: chrisbrandtner <chrisbrandtner@ebc5dd9b-fb1d-0410-b6f8-d24c324e9604> Date: Sat, 24 Jan 2009 16:15:04 +0000 Subject: [PATCH] Removed cast to float from Vector3d.CalculateAngle (unnecessary precision loss as double is returned). Overloaded static Vector3 and Vector3d CalculateAngle methods. --- Source/OpenTK/Math/Vector3.cs | 12 ++++++++++++ Source/OpenTK/Math/Vector3d.cs | Bin 68836 -> 70198 bytes 2 files changed, 12 insertions(+) diff --git a/Source/OpenTK/Math/Vector3.cs b/Source/OpenTK/Math/Vector3.cs index 6c5f25a8..fede0363 100644 --- a/Source/OpenTK/Math/Vector3.cs +++ b/Source/OpenTK/Math/Vector3.cs @@ -896,6 +896,18 @@ namespace OpenTK.Math return (float)System.Math.Acos((Vector3.Dot(first, second)) / (first.Length * second.Length)); } + /// <summary>Calculates the angle (in radians) between two vectors.</summary> + /// <param name="first">The first vector.</param> + /// <param name="second">The second vector.</param> + /// <param name="result">Angle (in radians) between the vectors.</param> + /// <remarks>Note that the returned angle is never bigger than the constant Pi.</remarks> + public static void CalculateAngle( ref Vector3 first, ref Vector3 second, out float result ) + { + float temp; + Vector3.Dot( ref first, ref second, out temp ); + result = (float)System.Math.Acos( temp / ( first.Length * second.Length ) ); + } + #endregion #endregion diff --git a/Source/OpenTK/Math/Vector3d.cs b/Source/OpenTK/Math/Vector3d.cs index 3e9f40dc67b8ffc106aa2053915ef18290702af9..691c23837337bc5d8f97531b67785c42b675eafb 100644 GIT binary patch delta 213 zcmaDdlV#fymJP2yP5$xe!ej#_smYV7g(lm*kD9Ea<}>NTwaE)MYA`xZ_I__ZS?;6M zWG^>`Nw=gXmwh}jc|$GF<RkB-CV$#1H@W5$-(<0UQj_O=;+gEWGG_7tO+NM#hE#@J zhJwi-h2$r1cq}#f*9tD}G=@xuB8Fmy5(XUx1t2SxAq_|u1L<Uje1<%R6tH+cLn%Ya z<l3{UlMQByOkTH=4d^x{VFjQru!%q&`arC~pfEZ5vn8tngC>K*^pEU}y^}Y1@NG8u HvPA*_|7}m* delta 34 scmV+-0Nww#qy*%d1hDGzlZ-7UlZ^NZlMM5&li*%1lTb)Hvx51w7(8eZod5s;