public void GetLength() { Path3F empty = new Path3F(); empty.Sort(); Assert.AreEqual(0, empty.GetLength(0, 1, 100, 0.0001f)); Path3F path = CreatePath(); path.PreLoop = CurveLoopType.Constant; path.PostLoop = CurveLoopType.Oscillate; Assert.IsTrue(Numeric.AreEqual((new Vector3F(0, 0, 1) - new Vector3F(1, 2, 3)).Length, path.GetLength(-1, 12, 100, 0.0001f), 0.001f)); Assert.IsTrue(Numeric.AreEqual((new Vector3F(0, 0, 1) - new Vector3F(1, 2, 3)).Length, path.GetLength(-1, 20, 100, 0.0001f), 0.001f)); CatmullRomSegment3F catmullOscillate = new CatmullRomSegment3F() { Point1 = new Vector3F(10, 12, 14), Point2 = new Vector3F(10, 14, 8), Point3 = new Vector3F(20, 14, 8), Point4 = new Vector3F(30, 14, 8), }; float desiredLength = catmullOscillate.GetLength(0, 1, 20, 0.0001f); float actualLength = path.GetLength(40, 50, 20, 0.0001f); Assert.IsTrue(Numeric.AreEqual(desiredLength, actualLength, 0.001f)); desiredLength = catmullOscillate.GetLength(1, 0.8f, 20, 0.0001f); actualLength = path.GetLength(52, 50, 20, 0.0001f); Assert.IsTrue(Numeric.AreEqual(desiredLength, actualLength, 0.001f)); desiredLength = catmullOscillate.GetLength(1, 0.8f, 20, 0.0001f) * 2; actualLength = path.GetLength(52, 48, 20, 0.0001f); Assert.IsTrue(Numeric.AreEqual(desiredLength, actualLength, 0.001f)); path.PreLoop = CurveLoopType.Linear; path.PostLoop = CurveLoopType.Cycle; path.PreLoop = CurveLoopType.Cycle; path.PostLoop = CurveLoopType.CycleOffset; path.PreLoop = CurveLoopType.CycleOffset; path.PostLoop = CurveLoopType.Linear; path.PreLoop = CurveLoopType.Oscillate; path.PostLoop = CurveLoopType.Constant; }
public void TwoKeyCurvesTest() { Path3F curve = new Path3F(); curve.Add(new PathKey3F() { Parameter = 1, Point = new Vector3F(1, 2, 0), Interpolation = SplineInterpolation.CatmullRom, }); curve.Add(new PathKey3F() { Parameter = 3, Point = new Vector3F(3, 4, 0), Interpolation = SplineInterpolation.CatmullRom, }); curve.PreLoop = CurveLoopType.Constant; curve.PostLoop = CurveLoopType.Constant; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(2, 3, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(3, 4, 0), curve.GetPoint(3)); Assert.AreEqual(new Vector3F(3, 4, 0), curve.GetPoint(4)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(1, 1, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(1, 1, 0), curve.GetTangent(2)); Assert.AreEqual(new Vector3F(1, 1, 0), curve.GetTangent(3)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(4)); Assert.IsTrue(Numeric.AreEqual(new Vector3F(2, 2, 0).Length, curve.GetLength(0, 4, 10, 0.01f), 0.01f)); curve.PreLoop = CurveLoopType.Linear; curve.PostLoop = CurveLoopType.Linear; curve.PreLoop = CurveLoopType.Cycle; curve.PostLoop = CurveLoopType.Cycle; curve.PreLoop = CurveLoopType.CycleOffset; curve.PostLoop = CurveLoopType.CycleOffset; curve.PreLoop = CurveLoopType.Oscillate; curve.PostLoop = CurveLoopType.Oscillate; }
public void OneKeyCurvesTest() { // Test linear curves with 1 point Path3F curve = new Path3F(); curve.Add(new PathKey3F() { Parameter = 1, Point = new Vector3F(1, 2, 0), Interpolation = SplineInterpolation.Linear, }); curve.PreLoop = CurveLoopType.Constant; curve.PostLoop = CurveLoopType.Constant; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); curve.PreLoop = CurveLoopType.Linear; curve.PostLoop = CurveLoopType.Linear; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); curve.PreLoop = CurveLoopType.Cycle; curve.PostLoop = CurveLoopType.Cycle; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); curve.PreLoop = CurveLoopType.CycleOffset; curve.PostLoop = CurveLoopType.CycleOffset; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); curve.PreLoop = CurveLoopType.Oscillate; curve.PostLoop = CurveLoopType.Oscillate; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); // Test step curves with 1 point curve = new Path3F(); curve.Add(new PathKey3F() { Parameter = 1, Point = new Vector3F(1, 2, 0), Interpolation = SplineInterpolation.StepLeft, }); curve.PreLoop = CurveLoopType.Constant; curve.PostLoop = CurveLoopType.Constant; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); curve.PreLoop = CurveLoopType.Linear; curve.PostLoop = CurveLoopType.Linear; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); curve.PreLoop = CurveLoopType.Cycle; curve.PostLoop = CurveLoopType.Cycle; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); curve.PreLoop = CurveLoopType.CycleOffset; curve.PostLoop = CurveLoopType.CycleOffset; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); curve.PreLoop = CurveLoopType.Oscillate; curve.PostLoop = CurveLoopType.Oscillate; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); // Test B-spline curves with 1 point curve = new Path3F(); curve.Add(new PathKey3F() { Parameter = 1, Point = new Vector3F(1, 2, 0), Interpolation = SplineInterpolation.BSpline, }); curve.PreLoop = CurveLoopType.Constant; curve.PostLoop = CurveLoopType.Constant; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); curve.PreLoop = CurveLoopType.Linear; curve.PostLoop = CurveLoopType.Linear; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); curve.PreLoop = CurveLoopType.Cycle; curve.PostLoop = CurveLoopType.Cycle; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); curve.PreLoop = CurveLoopType.CycleOffset; curve.PostLoop = CurveLoopType.CycleOffset; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); curve.PreLoop = CurveLoopType.Oscillate; curve.PostLoop = CurveLoopType.Oscillate; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); // Test Catmull-Rom curves with 1 point curve = new Path3F(); curve.Add(new PathKey3F() { Parameter = 1, Point = new Vector3F(1, 2, 0), Interpolation = SplineInterpolation.CatmullRom, }); curve.PreLoop = CurveLoopType.Constant; curve.PostLoop = CurveLoopType.Constant; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); curve.PreLoop = CurveLoopType.Linear; curve.PostLoop = CurveLoopType.Linear; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); curve.PreLoop = CurveLoopType.Cycle; curve.PostLoop = CurveLoopType.Cycle; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); curve.PreLoop = CurveLoopType.CycleOffset; curve.PostLoop = CurveLoopType.CycleOffset; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); curve.PreLoop = CurveLoopType.Oscillate; curve.PostLoop = CurveLoopType.Oscillate; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); // Test Hermite curves with 1 point curve = new Path3F(); curve.Add(new PathKey3F() { Parameter = 1, Point = new Vector3F(1, 2, 0), Interpolation = SplineInterpolation.Hermite, TangentIn = new Vector3F(2, -2, 0), TangentOut = new Vector3F(2, 2, 0), }); curve.PreLoop = CurveLoopType.Constant; curve.PostLoop = CurveLoopType.Constant; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 20, 0.01f)); curve.PreLoop = CurveLoopType.Constant; curve.PostLoop = CurveLoopType.Linear; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(3, 4, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(2, 2, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(2, 2, 0), curve.GetTangent(2)); Assert.IsTrue(Numeric.AreEqual(new Vector3F(2, 2, 0).Length, curve.GetLength(0, 2, 10, 0.01f), 0.1f)); curve.PreLoop = CurveLoopType.Linear; curve.PostLoop = CurveLoopType.Constant; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(-1, 4, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(2, -2, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(2, -2, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.IsTrue(Numeric.AreEqual(new Vector3F(2, 2, 0).Length, curve.GetLength(0, 2, 10, 0.01f), 0.1f)); curve.PreLoop = CurveLoopType.Linear; curve.PostLoop = CurveLoopType.Linear; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(-1, 4, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(3, 4, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(2, -2, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(2, 2, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(2, 2, 0), curve.GetTangent(2)); Assert.IsTrue(Numeric.AreEqual(new Vector3F(4, 4, 0).Length, curve.GetLength(0, 2, 10, 0.01f), 0.1f)); curve.PreLoop = CurveLoopType.Cycle; curve.PostLoop = CurveLoopType.Cycle; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); curve.PreLoop = CurveLoopType.CycleOffset; curve.PostLoop = CurveLoopType.CycleOffset; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); curve.PreLoop = CurveLoopType.Oscillate; curve.PostLoop = CurveLoopType.Oscillate; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); // Test Bezier curves with 1 point curve = new Path3F(); curve.Add(new PathKey3F() { Parameter = 1, Point = new Vector3F(1, 2, 0), Interpolation = SplineInterpolation.Bezier, TangentIn = new Vector3F(1, 2, 0) - new Vector3F(2, -2, 0) / 3, TangentOut = new Vector3F(1, 2, 0) + new Vector3F(2, 2, 0) / 3, }); curve.PreLoop = CurveLoopType.Constant; curve.PostLoop = CurveLoopType.Constant; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); curve.PreLoop = CurveLoopType.Constant; curve.PostLoop = CurveLoopType.Linear; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.IsTrue(Vector3F.AreNumericallyEqual(new Vector3F(3, 4, 0), curve.GetPoint(2))); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.IsTrue(Vector3F.AreNumericallyEqual(new Vector3F(2, 2, 0), curve.GetTangent(1))); Assert.IsTrue(Vector3F.AreNumericallyEqual(new Vector3F(2, 2, 0), curve.GetTangent(2))); Assert.IsTrue(Numeric.AreEqual(new Vector3F(2, 2, 0).Length, curve.GetLength(0, 2, 10, 0.01f), 0.1f)); curve.PreLoop = CurveLoopType.Linear; curve.PostLoop = CurveLoopType.Constant; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(-1, 4, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.IsTrue(Vector3F.AreNumericallyEqual(new Vector3F(2, -2, 0), curve.GetTangent(0))); Assert.IsTrue(Vector3F.AreNumericallyEqual(new Vector3F(2, -2, 0), curve.GetTangent(1))); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.IsTrue(Numeric.AreEqual(new Vector3F(2, 2, 0).Length, curve.GetLength(0, 2, 10, 0.01f), 0.1f)); curve.PreLoop = CurveLoopType.Linear; curve.PostLoop = CurveLoopType.Linear; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(-1, 4, 0), curve.GetPoint(0)); Assert.IsTrue(Vector3F.AreNumericallyEqual(new Vector3F(3, 4, 0), curve.GetPoint(2))); Assert.IsTrue(Vector3F.AreNumericallyEqual(new Vector3F(2, -2, 0), curve.GetTangent(0))); Assert.IsTrue(Vector3F.AreNumericallyEqual(new Vector3F(2, 2, 0), curve.GetTangent(1))); Assert.IsTrue(Vector3F.AreNumericallyEqual(new Vector3F(2, 2, 0), curve.GetTangent(2))); Assert.IsTrue(Numeric.AreEqual(new Vector3F(4, 4, 0).Length, curve.GetLength(0, 2, 10, 0.01f), 0.1f)); curve.PreLoop = CurveLoopType.Cycle; curve.PostLoop = CurveLoopType.Cycle; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); curve.PreLoop = CurveLoopType.CycleOffset; curve.PostLoop = CurveLoopType.CycleOffset; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); curve.PreLoop = CurveLoopType.Oscillate; curve.PostLoop = CurveLoopType.Oscillate; Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(1)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(0)); Assert.AreEqual(new Vector3F(1, 2, 0), curve.GetPoint(2)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(0)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(1)); Assert.AreEqual(new Vector3F(0, 0, 0), curve.GetTangent(2)); Assert.AreEqual(0, curve.GetLength(0, 2, 10, 0.01f)); }