diff --git a/draw2d/curve/curve_float64.go b/draw2d/curve/curve_float64.go index 0964dd6..40abf8d 100644 --- a/draw2d/curve/curve_float64.go +++ b/draw2d/curve/curve_float64.go @@ -82,8 +82,7 @@ func (c *CubicCurveFloat64) EstimateDistance() float64 { return math.Sqrt(dx1*dx1+dy1*dy1) + math.Sqrt(dx2*dx2+dy2*dy2) + math.Sqrt(dx3*dx3+dy3*dy3) } -// subdivide the curve in straight lines using straight line approximation and Casteljau recursive subdivision -// and computing minimal distance tolerance +// subdivide the curve in straight lines using line approximation and Casteljau recursive subdivision func (c *CubicCurveFloat64) SegmentRec(segments []float64) []float64 { // reinit segments segments = segments[0 : len(segments)+2] diff --git a/draw2d/curve/curve_test.go b/draw2d/curve/curve_test.go index f192c91..a490116 100644 --- a/draw2d/curve/curve_test.go +++ b/draw2d/curve/curve_test.go @@ -15,7 +15,8 @@ import ( var ( testsFloat64 = []CubicCurveFloat64{ CubicCurveFloat64{100, 100, 200, 100, 100, 200, 200, 200}, - CubicCurveFloat64{100, 100, 300, 200, 200, 200, 200, 100}, + CubicCurveFloat64{100, 100, 300, 200, 200, 200, 300, 100}, + CubicCurveFloat64{100, 100, 0, 300, 200, 0, 300, 300}, } ) @@ -56,7 +57,7 @@ func savepng(filePath string, m image.Image) { } -func TestCubicCurveCasteljauRec(t *testing.T) { +func TestCubicCurveRec(t *testing.T) { for i, curve := range testsFloat64 { d := curve.EstimateDistance() log.Printf("Distance estimation: %f\n", d) @@ -71,7 +72,7 @@ func TestCubicCurveCasteljauRec(t *testing.T) { } } -func TestCubicCurveCasteljau(t *testing.T) { +func TestCubicCurve(t *testing.T) { for i, curve := range testsFloat64 { d := curve.EstimateDistance() log.Printf("Distance estimation: %f\n", d) @@ -87,7 +88,7 @@ func TestCubicCurveCasteljau(t *testing.T) { } -func BenchmarkCubicCurveCasteljauRec(b *testing.B) { +func BenchmarkCubicCurveRec(b *testing.B) { for i := 0; i < b.N; i++ { for _, curve := range testsFloat64 { d := curve.EstimateDistance() @@ -98,7 +99,7 @@ func BenchmarkCubicCurveCasteljauRec(b *testing.B) { } } -func BenchmarkCubicCurveCasteljau(b *testing.B) { +func BenchmarkCubicCurve(b *testing.B) { for i := 0; i < b.N; i++ { for _, curve := range testsFloat64 { d := curve.EstimateDistance()