public void It_Returns_Parameter_At_The_Given_Length(double segmentLength, double tValueExpected) { // Arrange NurbsBase curve = NurbsCurveCollection.PlanarCurveDegreeThree(); // Act double parameter = curve.ParameterAtLength(segmentLength); // Assert parameter.Should().BeApproximately(tValueExpected, GSharkMath.MinTolerance); }
public void It_Returns_Parameter_At_The_Given_Length_Of_A_Bezier() { // Arrange NurbsBase curve = NurbsCurveCollection.PlanarCurveDegreeThree(); double[] tValuesExpected = new[] { 0, 0.122941, 0.265156, 0.420293, 0.579707, 0.734844, 0.877059, 1 }; int steps = 7; double length = curve.Length / steps; double sumLengths = 0.0; for (int i = 0; i < steps + 1; i++) { // Act double t = curve.ParameterAtLength(sumLengths); double segmentLength = curve.LengthAt(t); // Assert t.Should().BeApproximately(tValuesExpected[i], GSharkMath.MaxTolerance); segmentLength.Should().BeApproximately(sumLengths, GSharkMath.MaxTolerance); sumLengths += length; } }