modify tests

This commit is contained in:
Laurent Le Goff 2011-05-18 23:34:41 +02:00
parent b7d000715e
commit 23ecc2d0d2
2 changed files with 7 additions and 7 deletions

View file

@ -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) 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 // subdivide the curve in straight lines using line approximation and Casteljau recursive subdivision
// and computing minimal distance tolerance
func (c *CubicCurveFloat64) SegmentRec(segments []float64) []float64 { func (c *CubicCurveFloat64) SegmentRec(segments []float64) []float64 {
// reinit segments // reinit segments
segments = segments[0 : len(segments)+2] segments = segments[0 : len(segments)+2]

View file

@ -15,7 +15,8 @@ import (
var ( var (
testsFloat64 = []CubicCurveFloat64{ testsFloat64 = []CubicCurveFloat64{
CubicCurveFloat64{100, 100, 200, 100, 100, 200, 200, 200}, 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 { for i, curve := range testsFloat64 {
d := curve.EstimateDistance() d := curve.EstimateDistance()
log.Printf("Distance estimation: %f\n", d) 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 { for i, curve := range testsFloat64 {
d := curve.EstimateDistance() d := curve.EstimateDistance()
log.Printf("Distance estimation: %f\n", d) 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 i := 0; i < b.N; i++ {
for _, curve := range testsFloat64 { for _, curve := range testsFloat64 {
d := curve.EstimateDistance() 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 i := 0; i < b.N; i++ {
for _, curve := range testsFloat64 { for _, curve := range testsFloat64 {
d := curve.EstimateDistance() d := curve.EstimateDistance()