MathExtensions ClassDelta Engine Documentation
Extends the System.Math class, but uses floats and provides some extra constants. View code on GitHub
Inheritance Hierarchy

System Object
  DeltaEngine.Extensions MathExtensions

Namespace: DeltaEngine.Extensions
Assembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public static class MathExtensions

The MathExtensions type exposes the following members.

Methods

  NameDescription
Public methodStatic memberAbs
Public methodStatic memberAcos
Public methodStatic memberAsin
Public methodStatic memberAtan2
Public methodStatic memberClamp(Int32, Int32, Int32)
Public methodStatic memberClamp(Single, Single, Single)
Public methodStatic memberCos
Public methodStatic memberDegreesToRadians
Public methodStatic memberGetNearestMultiple
Public methodStatic memberInvSqrt
Public methodStatic memberIsLineIntersectingWith
http://en.wikipedia.org/wiki/Line%E2%80%93line_intersection View code on GitHub
Public methodStatic memberIsNearlyEqual
Public methodStatic memberLerp
Public methodStatic memberMax(Int32, Int32)
Public methodStatic memberMax(Single, Single)
Public methodStatic memberMin(Int32, Int32)
Public methodStatic memberMin(Single, Single)
Public methodStatic memberRadiansToDegrees
Public methodStatic memberRound(Single)
Public methodStatic memberRound(Single, Int32)
Public methodStatic memberSin
Public methodStatic memberSqrt
Public methodStatic memberTan
Public methodStatic memberWrapRotationToMinus180ToPlus180
Top
Fields

  NameDescription
Public fieldStatic memberEpsilon
Public fieldStatic memberPi
Top
Remarks

Tests: DeltaEngine.Tests.Extensions.MathExtensionsTests
Examples

19 unit tests call DeltaEngine.Extensions.MathExtensions
[Test]
public void Abs()
{
    Assert.AreEqual(5, MathExtensions.Abs(2) + MathExtensions.Abs(3));
    Assert.AreEqual(5, MathExtensions.Abs(-2) + MathExtensions.Abs(3));
    Assert.AreEqual(5, 2.0f.Abs() + 3.0f.Abs());
    Assert.AreEqual(5, (-2.0f).Abs() + 3.0f.Abs());
}
[Test]
public void IsNearlyEqual()
{
    Assert.IsTrue(2.0f.IsNearlyEqual(2.00001f));
    Assert.IsFalse(2.0f.IsNearlyEqual(2.0002f));
    Assert.IsTrue(MathExtensions.Pi.IsNearlyEqual(3.1415f));
}
[Test]
public static void Round()
{
    Assert.AreEqual(1, 1.25f.Round());
    Assert.AreEqual(10, 9.68f.Round());
    Assert.AreEqual(1.23f, 1.2345f.Round(2));
}
See Also