diff --git a/Source/OpenTK/Math/BezierCurve.cs b/Source/OpenTK/Math/BezierCurve.cs new file mode 100644 index 00000000..383de5e9 Binary files /dev/null and b/Source/OpenTK/Math/BezierCurve.cs differ diff --git a/Source/OpenTK/Math/BezierCurveCubic.cs b/Source/OpenTK/Math/BezierCurveCubic.cs new file mode 100644 index 00000000..3c0deddf Binary files /dev/null and b/Source/OpenTK/Math/BezierCurveCubic.cs differ diff --git a/Source/OpenTK/Math/BezierCurveQuadric.cs b/Source/OpenTK/Math/BezierCurveQuadric.cs new file mode 100644 index 00000000..154e8d5d Binary files /dev/null and b/Source/OpenTK/Math/BezierCurveQuadric.cs differ diff --git a/Source/OpenTK/Math/Functions.cs b/Source/OpenTK/Math/Functions.cs index b59735e0..76de7c77 100644 --- a/Source/OpenTK/Math/Functions.cs +++ b/Source/OpenTK/Math/Functions.cs @@ -1,8 +1,10 @@ #region --- License --- -/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos - * See license.txt for license info +/* 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. + * Contributions by Andy Gill, James Talton and Georg Wächter. */ #endregion @@ -17,6 +19,32 @@ namespace OpenTK.Math /// public static class Functions { + /// + /// Calculates the factorial of a given natural number. + /// + /// The number. + /// n! + public static long Factorial(int n) + { + long result = 1; + + for (; n > 1; n--) + result *= n; + + return result; + } + + /// + /// Calculates the binomial coefficient above . + /// + /// The n. + /// The k. + /// n! / (k! * (n - k)!) + public static long BinomialCoefficient(int n, int k) + { + return Factorial(n) / (Factorial(k) * Factorial(n - k)); + } + /// /// Returns an approximation of the inverse square root of left number. /// @@ -43,6 +71,9 @@ namespace OpenTK.Math 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; @@ -52,6 +83,7 @@ namespace OpenTK.Math x = x * (1.5f - xhalf * x * x); // Perform left single Newton-Raphson step. return x; } +#endif } /// diff --git a/Source/OpenTK/Math/Vector2.cs b/Source/OpenTK/Math/Vector2.cs index 81dbf6e2..3d57024a 100644 --- a/Source/OpenTK/Math/Vector2.cs +++ b/Source/OpenTK/Math/Vector2.cs @@ -2,7 +2,7 @@ /* Copyright (c) 2006, 2007 Stefanos Apostolopoulos * See license.txt for license info * - * Contributions by Andy Gill. + * Contributions by Andy Gill, Georg WΓ¤chter. */ #endregion @@ -145,6 +145,21 @@ namespace OpenTK.Math } } + #endregion + + #region public Vector2 Perpendicular + + /// + /// Gets the perpendicular vector. + /// + public Vector2 Perpendicular + { + get + { + return new Vector2(Y, -X); + } + } + #endregion #region public void Normalize() diff --git a/Source/OpenTK/Math/Vector2d.cs b/Source/OpenTK/Math/Vector2d.cs index 593740dd..f0709c52 100644 Binary files a/Source/OpenTK/Math/Vector2d.cs and b/Source/OpenTK/Math/Vector2d.cs differ