Obsoleted OpenTK.Functions in favor of OpenTK.MathHelper (reason: XNA compatibility).

Added Matrix4.LookAt overload that does not use Vector3 parameters.
This commit is contained in:
the_fiddler 2009-08-14 12:37:18 +00:00
parent 81304f33b5
commit 3cfc3906b8
11 changed files with 419 additions and 39 deletions

View file

@ -207,7 +207,7 @@ namespace OpenTK
foreach (Vector2 pt in points) foreach (Vector2 pt in points)
{ {
temp = (float)Functions.BinomialCoefficient(points.Count - 1, i) * (float)(System.Math.Pow(t, i) * temp = (float)MathHelper.BinomialCoefficient(points.Count - 1, i) * (float)(System.Math.Pow(t, i) *
System.Math.Pow(c, (points.Count - 1) - i)); System.Math.Pow(c, (points.Count - 1) - i));
r.X += temp * pt.X; r.X += temp * pt.X;
@ -243,7 +243,7 @@ namespace OpenTK
foreach (Vector2 pt in points) foreach (Vector2 pt in points)
{ {
temp = (float)Functions.BinomialCoefficient(points.Count - 2, i) * (float)(System.Math.Pow(t, i) * temp = (float)MathHelper.BinomialCoefficient(points.Count - 2, i) * (float)(System.Math.Pow(t, i) *
System.Math.Pow(c, (points.Count - 2) - i)); System.Math.Pow(c, (points.Count - 2) - i));
r.X += temp * pt.X; r.X += temp * pt.X;

View file

@ -11,14 +11,16 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace OpenTK namespace OpenTK
{ {
/// <summary> /// <summary>
/// Contains mathematical functions for the OpenTK.Math toolkit. /// Contains mathematical functions for the OpenTK.Math toolkit.
/// </summary> /// </summary>
[Obsolete("Use OpenTK.MathHelper instead.")]
public static class Functions public static class Functions
{ {
#region public static long NextPowerOfTwo(long n) #region NextPowerOfTwo
/// <summary> /// <summary>
/// Returns the next power of two that is larger than the specified number. /// Returns the next power of two that is larger than the specified number.
@ -31,10 +33,6 @@ namespace OpenTK
return (long)System.Math.Pow(2, System.Math.Ceiling(System.Math.Log((double)n, 2))); return (long)System.Math.Pow(2, System.Math.Ceiling(System.Math.Log((double)n, 2)));
} }
#endregion
#region public static int NextPowerOfTwo(int n)
/// <summary> /// <summary>
/// Returns the next power of two that is larger than the specified number. /// Returns the next power of two that is larger than the specified number.
/// </summary> /// </summary>
@ -46,10 +44,6 @@ namespace OpenTK
return (int)System.Math.Pow(2, System.Math.Ceiling(System.Math.Log((double)n, 2))); return (int)System.Math.Pow(2, System.Math.Ceiling(System.Math.Log((double)n, 2)));
} }
#endregion
#region public static int NextPowerOfTwo(int n)
/// <summary> /// <summary>
/// Returns the next power of two that is larger than the specified number. /// Returns the next power of two that is larger than the specified number.
/// </summary> /// </summary>
@ -61,11 +55,6 @@ namespace OpenTK
return (float)System.Math.Pow(2, System.Math.Ceiling(System.Math.Log((double)n, 2))); return (float)System.Math.Pow(2, System.Math.Ceiling(System.Math.Log((double)n, 2)));
} }
#endregion
#region public static int NextPowerOfTwo(int n)
/// <summary> /// <summary>
/// Returns the next power of two that is larger than the specified number. /// Returns the next power of two that is larger than the specified number.
/// </summary> /// </summary>
@ -79,6 +68,8 @@ namespace OpenTK
#endregion #endregion
#region Factorial
/// <summary>Calculates the factorial of a given natural number. /// <summary>Calculates the factorial of a given natural number.
/// </summary> /// </summary>
/// <param name="n">The number.</param> /// <param name="n">The number.</param>
@ -93,6 +84,10 @@ namespace OpenTK
return result; return result;
} }
#endregion
#region BinomialCoefficient
/// <summary> /// <summary>
/// Calculates the binomial coefficient <paramref name="n"/> above <paramref name="k"/>. /// Calculates the binomial coefficient <paramref name="n"/> above <paramref name="k"/>.
/// </summary> /// </summary>
@ -104,6 +99,10 @@ namespace OpenTK
return Factorial(n) / (Factorial(k) * Factorial(n - k)); return Factorial(n) / (Factorial(k) * Factorial(n - k));
} }
#endregion
#region InverseSqrtFast
/// <summary> /// <summary>
/// Returns an approximation of the inverse square root of left number. /// Returns an approximation of the inverse square root of left number.
/// </summary> /// </summary>
@ -156,6 +155,10 @@ namespace OpenTK
#endif #endif
} }
#endregion
#region DegreesToRadians
/// <summary> /// <summary>
/// Convert degrees to radians /// Convert degrees to radians
/// </summary> /// </summary>
@ -178,6 +181,8 @@ namespace OpenTK
return radians * radToDeg; return radians * radToDeg;
} }
#endregion
public static readonly float PIF = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930382f; public static readonly float PIF = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930382f;
public static readonly float RTODF = 180.0f / PIF; public static readonly float RTODF = 180.0f / PIF;
public static readonly float DTORF = PIF / 180.0f; public static readonly float DTORF = PIF / 180.0f;
@ -186,18 +191,23 @@ namespace OpenTK
public static readonly double RTOD = 180.0d / PIF; public static readonly double RTOD = 180.0d / PIF;
public static readonly double DTOR = PIF / 180.0d; public static readonly double DTOR = PIF / 180.0d;
#region Swap
public static void Swap(ref double a, ref double b) public static void Swap(ref double a, ref double b)
{ {
double temp = a; double temp = a;
a = b; a = b;
b = temp; b = temp;
} }
public static void Swap(ref float a, ref float b) public static void Swap(ref float a, ref float b)
{ {
float temp = a; float temp = a;
a = b; a = b;
b = temp; b = temp;
} }
#endregion
} }
#if false #if false

View file

@ -0,0 +1,334 @@
#region --- License ---
/* Licensed under the MIT/X11 license.
* Copyright (c) 2006-2008 the OpenTK Team.
* This notice may not be removed from any source distribution.
* See license.txt for licensing detailed licensing details.
*
* Contributions by Andy Gill, James Talton and Georg Wächter.
*/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenTK
{
/// <summary>
/// Contains mathematical functions for the OpenTK.Math toolkit.
/// </summary>
public static class MathHelper
{
#region NextPowerOfTwo
/// <summary>
/// Returns the next power of two that is larger than the specified number.
/// </summary>
/// <param name="n">The specified number.</param>
/// <returns>The next power of two.</returns>
public static long NextPowerOfTwo(long n)
{
if (n < 0) throw new ArgumentOutOfRangeException("n", "Must be positive.");
return (long)System.Math.Pow(2, System.Math.Ceiling(System.Math.Log((double)n, 2)));
}
/// <summary>
/// Returns the next power of two that is larger than the specified number.
/// </summary>
/// <param name="n">The specified number.</param>
/// <returns>The next power of two.</returns>
public static int NextPowerOfTwo(int n)
{
if (n < 0) throw new ArgumentOutOfRangeException("n", "Must be positive.");
return (int)System.Math.Pow(2, System.Math.Ceiling(System.Math.Log((double)n, 2)));
}
/// <summary>
/// Returns the next power of two that is larger than the specified number.
/// </summary>
/// <param name="n">The specified number.</param>
/// <returns>The next power of two.</returns>
public static float NextPowerOfTwo(float n)
{
if (n < 0) throw new ArgumentOutOfRangeException("n", "Must be positive.");
return (float)System.Math.Pow(2, System.Math.Ceiling(System.Math.Log((double)n, 2)));
}
/// <summary>
/// Returns the next power of two that is larger than the specified number.
/// </summary>
/// <param name="n">The specified number.</param>
/// <returns>The next power of two.</returns>
public static double NextPowerOfTwo(double n)
{
if (n < 0) throw new ArgumentOutOfRangeException("n", "Must be positive.");
return System.Math.Pow(2, System.Math.Ceiling(System.Math.Log((double)n, 2)));
}
#endregion
#region Factorial
/// <summary>Calculates the factorial of a given natural number.
/// </summary>
/// <param name="n">The number.</param>
/// <returns>n!</returns>
public static long Factorial(int n)
{
long result = 1;
for (; n > 1; n--)
result *= n;
return result;
}
#endregion
#region BinomialCoefficient
/// <summary>
/// Calculates the binomial coefficient <paramref name="n"/> above <paramref name="k"/>.
/// </summary>
/// <param name="n">The n.</param>
/// <param name="k">The k.</param>
/// <returns>n! / (k! * (n - k)!)</returns>
public static long BinomialCoefficient(int n, int k)
{
return Factorial(n) / (Factorial(k) * Factorial(n - k));
}
#endregion
#region InverseSqrtFast
/// <summary>
/// Returns an approximation of the inverse square root of left number.
/// </summary>
/// <param name="x">A number.</param>
/// <returns>An approximation of the inverse square root of the specified number, with an upper error bound of 0.001</returns>
/// <remarks>
/// This is an improved implementation of the the method known as Carmack's inverse square root
/// which is found in the Quake III source code. This implementation comes from
/// http://www.codemaestro.com/reviews/review00000105.html. For the history of this method, see
/// http://www.beyond3d.com/content/articles/8/
/// </remarks>
public static float InverseSqrtFast(float x)
{
unsafe
{
float xhalf = 0.5f * x;
int i = *(int*)&x; // Read bits as integer.
i = 0x5f375a86 - (i >> 1); // Make an initial guess for Newton-Raphson approximation
x = *(float*)&i; // Convert bits back to float
x = x * (1.5f - xhalf * x * x); // Perform left single Newton-Raphson step.
return x;
}
}
/// <summary>
/// Returns an approximation of the inverse square root of left number.
/// </summary>
/// <param name="x">A number.</param>
/// <returns>An approximation of the inverse square root of the specified number, with an upper error bound of 0.001</returns>
/// <remarks>
/// This is an improved implementation of the the method known as Carmack's inverse square root
/// which is found in the Quake III source code. This implementation comes from
/// http://www.codemaestro.com/reviews/review00000105.html. For the history of this method, see
/// http://www.beyond3d.com/content/articles/8/
/// </remarks>
public static double InverseSqrtFast(double x)
{
return InverseSqrtFast((float)x);
// TODO: The following code is wrong. Fix it, to improve precision.
#if false
unsafe
{
double xhalf = 0.5f * x;
int i = *(int*)&x; // Read bits as integer.
i = 0x5f375a86 - (i >> 1); // Make an initial guess for Newton-Raphson approximation
x = *(float*)&i; // Convert bits back to float
x = x * (1.5f - xhalf * x * x); // Perform left single Newton-Raphson step.
return x;
}
#endif
}
#endregion
#region DegreesToRadians
/// <summary>
/// Convert degrees to radians
/// </summary>
/// <param name="degrees">An angle in degrees</param>
/// <returns>The angle expressed in radians</returns>
public static float DegreesToRadians(float degrees)
{
const float degToRad = (float)System.Math.PI / 180.0f;
return degrees * degToRad;
}
/// <summary>
/// Convert radians to degrees
/// </summary>
/// <param name="radians">An angle in radians</param>
/// <returns>The angle expressed in degrees</returns>
public static float RadiansToDegrees(float radians)
{
const float radToDeg = 180.0f / (float)System.Math.PI;
return radians * radToDeg;
}
#endregion
public static readonly float PIF = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930382f;
public static readonly float RTODF = 180.0f / PIF;
public static readonly float DTORF = PIF / 180.0f;
public static readonly double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930382d;
public static readonly double RTOD = 180.0d / PIF;
public static readonly double DTOR = PIF / 180.0d;
#region Swap
public static void Swap(ref double a, ref double b)
{
double temp = a;
a = b;
b = temp;
}
public static void Swap(ref float a, ref float b)
{
float temp = a;
a = b;
b = temp;
}
#endregion
}
#if false
public static partial class Math
{
#region --- Vectors ---
#region --- Addition ---
/// <summary>
/// Adds the given Vector2 to the current Vector3.
/// </summary>
/// <param name="right">The right operand of the addition.</param>
/// <returns>A new Vector3 containing the result of the addition.</returns>
public static Vector2 Add(Vector2 left, Vector2 right)
{
return new Vector2(left).Add(right);
}
/// <summary>
/// Adds the given Vector3 to the current Vector3.
/// </summary>
/// <param name="right">The right operand of the addition.</param>
/// <returns>A new Vector3 containing the result of the addition.</returns>
public static Vector3 Add(Vector2 left, Vector3 right)
{
return new Vector3(left).Add(right);
}
/// <summary>
/// Adds the given Vector4 to the current Vector3. W-coordinate remains unaffected.
/// </summary>
/// <param name="right">The right operand of the addition.</param>
/// <returns>A new Vector4 containing the result of the addition.</returns>
public static Vector4 Add(Vector2 left, Vector4 right)
{
return new Vector4(left).Add(right);
}
/// <summary>
/// Adds the given Vector2 to the current Vector3.
/// </summary>
/// <param name="right">The right operand of the addition.</param>
/// <returns>A new Vector3 containing the result of the addition.</returns>
public static Vector3 Add(Vector3 left, Vector2 right)
{
return new Vector3(left).Add(right);
}
/// <summary>
/// Adds the given Vector3 to the current Vector3.
/// </summary>
/// <param name="right">The right operand of the addition.</param>
/// <returns>A new Vector3 containing the result of the addition.</returns>
public static Vector3 Add(Vector3 left, Vector3 right)
{
return new Vector3(left).Add(right);
}
/// <summary>
/// Adds the given Vector4 to the current Vector3. W-coordinate remains unaffected.
/// </summary>
/// <param name="right">The right operand of the addition.</param>
/// <returns>A new Vector4 containing the result of the addition.</returns>
public static Vector4 Add(Vector3 left, Vector4 right)
{
return new Vector4(left).Add(right);
}
/// <summary>
/// Adds the given Vector2 to the current Vector3.
/// </summary>
/// <param name="right">The right operand of the addition.</param>
/// <returns>A new Vector3 containing the result of the addition.</returns>
public static Vector4 Add(Vector4 left, Vector2 right)
{
return new Vector4(left).Add(right);
}
/// <summary>
/// Adds the given Vector3 to the current Vector3.
/// </summary>
/// <param name="right">The right operand of the addition.</param>
/// <returns>A new Vector3 containing the result of the addition.</returns>
public static Vector4 Add(Vector4 left, Vector3 right)
{
return new Vector4(left).Add(right);
}
/// <summary>
/// Adds the given Vector4 to the current Vector3. W-coordinate remains unaffected.
/// </summary>
/// <param name="right">The right operand of the addition.</param>
/// <returns>A new Vector4 containing the result of the addition.</returns>
public static Vector4 Add(Vector4 left, Vector4 right)
{
return new Vector4(left).Add(right);
}
#endregion
#region --- Subtraction ---
#endregion
#region --- Cross ---
/// <summary>
/// Computes the cross product between the current and the given Vector3. The current Vector3 is set to the result of the computation.
/// </summary>
/// <param name="right">The right operand of the cross product</param>
/// <returns>The current </returns>
public static Vector3 Cross(Vector3 left, Vector3 right)
{
return new Vector3(left).Cross(right);
}
#endregion
#endregion
}
#endif
}

View file

@ -761,7 +761,7 @@ namespace OpenTK
/// <param name="eye">Eye (camera) position in world space</param> /// <param name="eye">Eye (camera) position in world space</param>
/// <param name="target">Target position in world space</param> /// <param name="target">Target position in world space</param>
/// <param name="up">Up vector in world space (should not be parallel to the camera direction, that is target - eye)</param> /// <param name="up">Up vector in world space (should not be parallel to the camera direction, that is target - eye)</param>
/// <returns>A Matrix that transforms world space to camera space</returns> /// <returns>A Matrix4 that transforms world space to camera space</returns>
public static Matrix4 LookAt(Vector3 eye, Vector3 target, Vector3 up) public static Matrix4 LookAt(Vector3 eye, Vector3 target, Vector3 up)
{ {
Vector3 z = Vector3.Normalize(eye - target); Vector3 z = Vector3.Normalize(eye - target);
@ -778,6 +778,24 @@ namespace OpenTK
return trans * rot; return trans * rot;
} }
/// <summary>
/// Build a world space to camera space matrix
/// </summary>
/// <param name="eyeX">Eye (camera) position in world space</param>
/// <param name="eyeY">Eye (camera) position in world space</param>
/// <param name="eyeZ">Eye (camera) position in world space</param>
/// <param name="targetX">Target position in world space</param>
/// <param name="targetY">Target position in world space</param>
/// <param name="targetZ">Target position in world space</param>
/// <param name="upX">Up vector in world space (should not be parallel to the camera direction, that is target - eye)</param>
/// <param name="upY">Up vector in world space (should not be parallel to the camera direction, that is target - eye)</param>
/// <param name="upZ">Up vector in world space (should not be parallel to the camera direction, that is target - eye)</param>
/// <returns>A Matrix4 that transforms world space to camera space</returns>
public static Matrix4 LookAt(float eyeX, float eyeY, float eyeZ, float targetX, float targetY, float targetZ, float upX, float upY, float upZ)
{
return LookAt(new Vector3(eyeX, eyeY, eyeZ), new Vector3(targetX, targetY, targetZ), new Vector3(upX, upY, upZ));
}
/// <summary> /// <summary>
/// Build a projection matrix /// Build a projection matrix
/// </summary> /// </summary>

View file

@ -628,6 +628,24 @@ namespace OpenTK
return trans * rot; return trans * rot;
} }
/// <summary>
/// Build a world space to camera space matrix
/// </summary>
/// <param name="eyeX">Eye (camera) position in world space</param>
/// <param name="eyeY">Eye (camera) position in world space</param>
/// <param name="eyeZ">Eye (camera) position in world space</param>
/// <param name="targetX">Target position in world space</param>
/// <param name="targetY">Target position in world space</param>
/// <param name="targetZ">Target position in world space</param>
/// <param name="upX">Up vector in world space (should not be parallel to the camera direction, that is target - eye)</param>
/// <param name="upY">Up vector in world space (should not be parallel to the camera direction, that is target - eye)</param>
/// <param name="upZ">Up vector in world space (should not be parallel to the camera direction, that is target - eye)</param>
/// <returns>A Matrix4 that transforms world space to camera space</returns>
public static Matrix4d LookAt(double eyeX, double eyeY, double eyeZ, double targetX, double targetY, double targetZ, double upX, double upY, double upZ)
{
return LookAt(new Vector3d(eyeX, eyeY, eyeZ), new Vector3d(targetX, targetY, targetZ), new Vector3d(upX, upY, upZ));
}
/// <summary> /// <summary>
/// Build a projection matrix /// Build a projection matrix
/// </summary> /// </summary>

View file

@ -199,7 +199,7 @@ namespace OpenTK
{ {
get get
{ {
return 1.0f /OpenTK.Functions.InverseSqrtFast(X * X + Y * Y); return 1.0f / MathHelper.InverseSqrtFast(X * X + Y * Y);
} }
} }
@ -277,7 +277,7 @@ namespace OpenTK
/// </summary> /// </summary>
public void NormalizeFast() public void NormalizeFast()
{ {
float scale = Functions.InverseSqrtFast(X * X + Y * Y); float scale = MathHelper.InverseSqrtFast(X * X + Y * Y);
X *= scale; X *= scale;
Y *= scale; Y *= scale;
} }
@ -624,7 +624,7 @@ namespace OpenTK
/// <returns>The normalized vector</returns> /// <returns>The normalized vector</returns>
public static Vector2 NormalizeFast(Vector2 vec) public static Vector2 NormalizeFast(Vector2 vec)
{ {
float scale = Functions.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y); float scale = MathHelper.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y);
vec.X *= scale; vec.X *= scale;
vec.Y *= scale; vec.Y *= scale;
return vec; return vec;
@ -637,7 +637,7 @@ namespace OpenTK
/// <param name="result">The normalized vector</param> /// <param name="result">The normalized vector</param>
public static void NormalizeFast(ref Vector2 vec, out Vector2 result) public static void NormalizeFast(ref Vector2 vec, out Vector2 result)
{ {
float scale = Functions.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y); float scale = MathHelper.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y);
result.X = vec.X * scale; result.X = vec.X * scale;
result.Y = vec.Y * scale; result.Y = vec.Y * scale;
} }

View file

@ -512,7 +512,7 @@ namespace OpenTK
/// <returns>The normalized vector</returns> /// <returns>The normalized vector</returns>
public static Vector2d NormalizeFast(Vector2d vec) public static Vector2d NormalizeFast(Vector2d vec)
{ {
double scale = Functions.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y); double scale = MathHelper.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y);
vec.X *= scale; vec.X *= scale;
vec.Y *= scale; vec.Y *= scale;
return vec; return vec;
@ -525,7 +525,7 @@ namespace OpenTK
/// <param name="result">The normalized vector</param> /// <param name="result">The normalized vector</param>
public static void NormalizeFast(ref Vector2d vec, out Vector2d result) public static void NormalizeFast(ref Vector2d vec, out Vector2d result)
{ {
double scale = Functions.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y); double scale = MathHelper.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y);
result.X = vec.X * scale; result.X = vec.X * scale;
result.Y = vec.Y * scale; result.Y = vec.Y * scale;
} }

View file

@ -215,7 +215,7 @@ namespace OpenTK
{ {
get get
{ {
return 1.0f /OpenTK.Functions.InverseSqrtFast(X * X + Y * Y + Z * Z); return 1.0f / MathHelper.InverseSqrtFast(X * X + Y * Y + Z * Z);
} }
} }
@ -264,7 +264,7 @@ namespace OpenTK
/// </summary> /// </summary>
public void NormalizeFast() public void NormalizeFast()
{ {
float scale = Functions.InverseSqrtFast(X * X + Y * Y + Z * Z); float scale = MathHelper.InverseSqrtFast(X * X + Y * Y + Z * Z);
X *= scale; X *= scale;
Y *= scale; Y *= scale;
Z *= scale; Z *= scale;
@ -637,7 +637,7 @@ namespace OpenTK
/// <returns>The normalized vector</returns> /// <returns>The normalized vector</returns>
public static Vector3 NormalizeFast(Vector3 vec) public static Vector3 NormalizeFast(Vector3 vec)
{ {
float scale = Functions.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y + vec.Z * vec.Z); float scale = MathHelper.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y + vec.Z * vec.Z);
vec.X *= scale; vec.X *= scale;
vec.Y *= scale; vec.Y *= scale;
vec.Z *= scale; vec.Z *= scale;
@ -651,7 +651,7 @@ namespace OpenTK
/// <param name="result">The normalized vector</param> /// <param name="result">The normalized vector</param>
public static void NormalizeFast(ref Vector3 vec, out Vector3 result) public static void NormalizeFast(ref Vector3 vec, out Vector3 result)
{ {
float scale = Functions.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y + vec.Z * vec.Z); float scale = MathHelper.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y + vec.Z * vec.Z);
result.X = vec.X * scale; result.X = vec.X * scale;
result.Y = vec.Y * scale; result.Y = vec.Y * scale;
result.Z = vec.Z * scale; result.Z = vec.Z * scale;

View file

@ -214,7 +214,7 @@ namespace OpenTK
{ {
get get
{ {
return 1.0f / OpenTK.Functions.InverseSqrtFast(X * X + Y * Y + Z * Z); return 1.0f / MathHelper.InverseSqrtFast(X * X + Y * Y + Z * Z);
} }
} }
@ -263,7 +263,7 @@ namespace OpenTK
/// </summary> /// </summary>
public void NormalizeFast() public void NormalizeFast()
{ {
double scale = Functions.InverseSqrtFast(X * X + Y * Y + Z * Z); double scale = MathHelper.InverseSqrtFast(X * X + Y * Y + Z * Z);
X *= scale; X *= scale;
Y *= scale; Y *= scale;
Z *= scale; Z *= scale;
@ -636,7 +636,7 @@ namespace OpenTK
/// <returns>The normalized vector</returns> /// <returns>The normalized vector</returns>
public static Vector3d NormalizeFast(Vector3d vec) public static Vector3d NormalizeFast(Vector3d vec)
{ {
double scale = Functions.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y + vec.Z * vec.Z); double scale = MathHelper.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y + vec.Z * vec.Z);
vec.X *= scale; vec.X *= scale;
vec.Y *= scale; vec.Y *= scale;
vec.Z *= scale; vec.Z *= scale;
@ -650,7 +650,7 @@ namespace OpenTK
/// <param name="result">The normalized vector</param> /// <param name="result">The normalized vector</param>
public static void NormalizeFast(ref Vector3d vec, out Vector3d result) public static void NormalizeFast(ref Vector3d vec, out Vector3d result)
{ {
double scale = Functions.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y + vec.Z * vec.Z); double scale = MathHelper.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y + vec.Z * vec.Z);
result.X = vec.X * scale; result.X = vec.X * scale;
result.Y = vec.Y * scale; result.Y = vec.Y * scale;
result.Z = vec.Z * scale; result.Z = vec.Z * scale;

View file

@ -277,7 +277,7 @@ namespace OpenTK
{ {
get get
{ {
return 1.0f /OpenTK.Functions.InverseSqrtFast(X * X + Y * Y + Z * Z + W * W); return 1.0f / MathHelper.InverseSqrtFast(X * X + Y * Y + Z * Z + W * W);
} }
} }
@ -327,7 +327,7 @@ namespace OpenTK
/// </summary> /// </summary>
public void NormalizeFast() public void NormalizeFast()
{ {
float scale = Functions.InverseSqrtFast(X * X + Y * Y + Z * Z + W * W); float scale = MathHelper.InverseSqrtFast(X * X + Y * Y + Z * Z + W * W);
X *= scale; X *= scale;
Y *= scale; Y *= scale;
Z *= scale; Z *= scale;
@ -657,7 +657,7 @@ namespace OpenTK
/// <returns>The normalized vector</returns> /// <returns>The normalized vector</returns>
public static Vector4 NormalizeFast(Vector4 vec) public static Vector4 NormalizeFast(Vector4 vec)
{ {
float scale = Functions.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y + vec.Z * vec.Z + vec.W * vec.W); float scale = MathHelper.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y + vec.Z * vec.Z + vec.W * vec.W);
vec.X *= scale; vec.X *= scale;
vec.Y *= scale; vec.Y *= scale;
vec.Z *= scale; vec.Z *= scale;
@ -672,7 +672,7 @@ namespace OpenTK
/// <param name="result">The normalized vector</param> /// <param name="result">The normalized vector</param>
public static void NormalizeFast(ref Vector4 vec, out Vector4 result) public static void NormalizeFast(ref Vector4 vec, out Vector4 result)
{ {
float scale = Functions.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y + vec.Z * vec.Z + vec.W * vec.W); float scale = MathHelper.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y + vec.Z * vec.Z + vec.W * vec.W);
result.X = vec.X * scale; result.X = vec.X * scale;
result.Y = vec.Y * scale; result.Y = vec.Y * scale;
result.Z = vec.Z * scale; result.Z = vec.Z * scale;

View file

@ -275,7 +275,7 @@ namespace OpenTK
{ {
get get
{ {
return 1.0f / OpenTK.Functions.InverseSqrtFast(X * X + Y * Y + Z * Z + W * W); return 1.0f / MathHelper.InverseSqrtFast(X * X + Y * Y + Z * Z + W * W);
} }
} }
@ -324,7 +324,7 @@ namespace OpenTK
/// </summary> /// </summary>
public void NormalizeFast() public void NormalizeFast()
{ {
double scale = Functions.InverseSqrtFast(X * X + Y * Y + Z * Z + W * W); double scale = MathHelper.InverseSqrtFast(X * X + Y * Y + Z * Z + W * W);
X *= scale; X *= scale;
Y *= scale; Y *= scale;
Z *= scale; Z *= scale;
@ -654,7 +654,7 @@ namespace OpenTK
/// <returns>The normalized vector</returns> /// <returns>The normalized vector</returns>
public static Vector4d NormalizeFast(Vector4d vec) public static Vector4d NormalizeFast(Vector4d vec)
{ {
double scale = Functions.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y + vec.Z * vec.Z + vec.W * vec.W); double scale = MathHelper.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y + vec.Z * vec.Z + vec.W * vec.W);
vec.X *= scale; vec.X *= scale;
vec.Y *= scale; vec.Y *= scale;
vec.Z *= scale; vec.Z *= scale;
@ -669,7 +669,7 @@ namespace OpenTK
/// <param name="result">The normalized vector</param> /// <param name="result">The normalized vector</param>
public static void NormalizeFast(ref Vector4d vec, out Vector4d result) public static void NormalizeFast(ref Vector4d vec, out Vector4d result)
{ {
double scale = Functions.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y + vec.Z * vec.Z + vec.W * vec.W); double scale = MathHelper.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y + vec.Z * vec.Z + vec.W * vec.W);
result.X = vec.X * scale; result.X = vec.X * scale;
result.Y = vec.Y * scale; result.Y = vec.Y * scale;
result.Z = vec.Z * scale; result.Z = vec.Z * scale;