modify test

This commit is contained in:
Laurent Le Goff 2011-05-20 18:05:10 +02:00
parent b88f2dc3a3
commit 808d9ddb06
3 changed files with 3 additions and 17 deletions

View file

@ -47,9 +47,6 @@ func (curve *CubicCurveFloat64) Segment(t LineTracer, flattening_threshold float
var c *CubicCurveFloat64 var c *CubicCurveFloat64
var dx, dy, d2, d3 float64 var dx, dy, d2, d3 float64
var lx, ly float64
distance_threshold := flattening_threshold * 5
lx, ly = curve.X1, curve.Y1
for i >= 0 { for i >= 0 {
c = &curves[i] c = &curves[i]
@ -60,11 +57,7 @@ func (curve *CubicCurveFloat64) Segment(t LineTracer, flattening_threshold float
d3 = math.Fabs(((c.X3-c.X4)*dy - (c.Y3-c.Y4)*dx)) d3 = math.Fabs(((c.X3-c.X4)*dy - (c.Y3-c.Y4)*dx))
if (d2+d3)*(d2+d3) < flattening_threshold*(dx*dx+dy*dy) || i == len(curves)-1 { if (d2+d3)*(d2+d3) < flattening_threshold*(dx*dx+dy*dy) || i == len(curves)-1 {
if !(math.Fabs(lx - c.X4) < distance_threshold && math.Fabs(ly - c.Y4)< distance_threshold ) {
t.LineTo(c.X4, c.Y4) t.LineTo(c.X4, c.Y4)
lx, ly = c.X4, c.Y4
}
i-- i--
} else { } else {
// second half of bezier go lower onto the stack // second half of bezier go lower onto the stack

View file

@ -14,7 +14,7 @@ import (
var ( var (
flattening_threshold float64 = 0.25 flattening_threshold float64 = 0.5
testsCubicFloat64 = []CubicCurveFloat64{ testsCubicFloat64 = []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, 300, 100}, CubicCurveFloat64{100, 100, 300, 200, 200, 200, 300, 100},

View file

@ -34,9 +34,6 @@ func (curve *QuadCurveFloat64) Segment(t LineTracer, flattening_threshold float6
// current curve // current curve
var c *QuadCurveFloat64 var c *QuadCurveFloat64
var dx, dy, d float64 var dx, dy, d float64
var lx, ly float64
distance_threshold := flattening_threshold * 5
lx, ly = curve.X1, curve.Y1
for i >= 0 { for i >= 0 {
c = &curves[i] c = &curves[i]
@ -46,11 +43,7 @@ func (curve *QuadCurveFloat64) Segment(t LineTracer, flattening_threshold float6
d = math.Fabs(((c.X2-c.X3)*dy - (c.Y2-c.Y3)*dx)) d = math.Fabs(((c.X2-c.X3)*dy - (c.Y2-c.Y3)*dx))
if (d*d) < flattening_threshold*(dx*dx+dy*dy) || i == len(curves)-1 { if (d*d) < flattening_threshold*(dx*dx+dy*dy) || i == len(curves)-1 {
if !(math.Fabs(lx - c.X3) <= distance_threshold && math.Fabs(ly - c.Y3)<= distance_threshold ) {
t.LineTo(c.X3, c.Y3) t.LineTo(c.X3, c.Y3)
lx, ly = c.X3, c.Y3
}
i-- i--
} else { } else {
// second half of bezier go lower onto the stack // second half of bezier go lower onto the stack