basic curve test addet (semms like it wont run, corrected some minor errors in curve
This commit is contained in:
parent
49b56d3862
commit
488ad31c21
@ -68,6 +68,7 @@
|
||||
<Compile Include="Strukturen\BoundingFrustumTest.cs" />
|
||||
<Compile Include="Strukturen\BoundingSphereTest.cs" />
|
||||
<Compile Include="Strukturen\ColorTest.cs" />
|
||||
<Compile Include="Strukturen\CurveTest.cs" />
|
||||
<Compile Include="Strukturen\MathHelperTest.cs" />
|
||||
<Compile Include="Strukturen\MatrixTest.cs" />
|
||||
<Compile Include="Strukturen\PackedVector\Bgr565Test.cs" />
|
||||
|
42
ANX.Framework.TestCenter/Strukturen/CurveTest.cs
Normal file
42
ANX.Framework.TestCenter/Strukturen/CurveTest.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
||||
using XNACurve = Microsoft.Xna.Framework.Curve;
|
||||
using ANXCurve = ANX.Framework.Curve;
|
||||
|
||||
namespace ANX.Framework.TestCenter.Strukturen
|
||||
{
|
||||
[TestFixture]
|
||||
class CurveTest
|
||||
{
|
||||
|
||||
[Test]
|
||||
public void Evaluate()
|
||||
{
|
||||
XNACurve xna = new XNACurve();
|
||||
ANXCurve anx = new ANXCurve();
|
||||
|
||||
Random r = new Random();
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
float value = r.Next(-10, 10);
|
||||
xna.Keys.Add(new Microsoft.Xna.Framework.CurveKey(i, value));
|
||||
anx.Keys.Add(new CurveKey(i, value));
|
||||
}
|
||||
xna.PreLoop = Microsoft.Xna.Framework.CurveLoopType.Constant;
|
||||
anx.PreLoop = ANX.Framework.CurveLoopType.Constant;
|
||||
|
||||
xna.PostLoop = Microsoft.Xna.Framework.CurveLoopType.Constant;
|
||||
anx.PostLoop = ANX.Framework.CurveLoopType.Constant;
|
||||
|
||||
xna.ComputeTangents(Microsoft.Xna.Framework.CurveTangent.Flat);
|
||||
anx.ComputeTangents(CurveTangent.Flat);
|
||||
|
||||
AssertHelper.CompareFloats(xna.Evaluate(3.5f), anx.Evaluate(3.5f), float.Epsilon);
|
||||
}
|
||||
}
|
||||
}
|
@ -99,7 +99,7 @@ namespace ANX.Framework
|
||||
//formulas from: http://msdn.microsoft.com/de-de/library/microsoft.xna.framework.curvetangent%28v=xnagamestudio.40%29.aspx
|
||||
public void ComputeTangent(Int32 index, CurveTangent tangentInOutType)
|
||||
{
|
||||
if (index < 0 || index > keys.Count)
|
||||
if (index < 0 || index >= keys.Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
@ -127,7 +127,7 @@ namespace ANX.Framework
|
||||
}
|
||||
public void ComputeTangent(Int32 index, CurveTangent tangentInType, CurveTangent tangentOutType)
|
||||
{
|
||||
if (index < 0 || index > keys.Count)
|
||||
if (index < 0 || index >= keys.Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
@ -223,7 +223,6 @@ namespace ANX.Framework
|
||||
//wanted point behind last point
|
||||
else if (position > last.Position)
|
||||
{
|
||||
int cycle;
|
||||
switch (this.PostLoop)
|
||||
{
|
||||
case CurveLoopType.Constant:
|
||||
|
Loading…
x
Reference in New Issue
Block a user