bug hunting

This commit is contained in:
masongreen 2009-07-19 01:30:50 -04:00
parent 6100a498ab
commit 3fcf75c49a
5 changed files with 13 additions and 11 deletions

View File

@ -65,6 +65,8 @@ class Poly2TriDemo extends BasicGame("Poly2Tri") {
def init(container: GameContainer) { def init(container: GameContainer) {
poly poly
val foo = 1.4
println(Math.round(foo.toDouble))
} }
def update(gc: GameContainer, delta: Int) { def update(gc: GameContainer, delta: Int) {
@ -171,14 +173,13 @@ class Poly2TriDemo extends BasicGame("Poly2Tri") {
val p16 = Point(300,312) val p16 = Point(300,312)
segments = new ArrayBuffer[Segment] segments = new ArrayBuffer[Segment]
segments += new Segment(p2, p3)
segments += new Segment(p1, p2) segments += new Segment(p1, p2)
segments += new Segment(p7, p1) segments += new Segment(p2, p3)
segments += new Segment(p4, p5)
segments += new Segment(p3, p4) segments += new Segment(p3, p4)
segments += new Segment(p4, p5)
segments += new Segment(p5, p6) segments += new Segment(p5, p6)
segments += new Segment(p6, p7) segments += new Segment(p6, p7)
segments += new Segment(p3, p4) segments += new Segment(p7, p8)
segments += new Segment(p8, p9) segments += new Segment(p8, p9)
segments += new Segment(p9, p10) segments += new Segment(p9, p10)
segments += new Segment(p10, p11) segments += new Segment(p10, p11)

View File

@ -44,13 +44,13 @@ class Segment(var p: Point, var q: Point) {
// Equation of a line: y = m*x + b // Equation of a line: y = m*x + b
// Slope of the line (m) // Slope of the line (m)
val slope = (q.y - p.y)/(q.x - p.x) val slope = ((q.y - p.y)/(q.x - p.x)).toDouble
// Y intercept // Y intercept
val b = p.y - (p.x * slope) val b = (p.y - (p.x * slope)).toDouble
// Determines if this segment lies above the given point // Determines if this segment lies above the given point
def > (point: Point) = (point.y < Math.floor(slope * point.x + b)) def > (point: Point) = (point.y.toFloat < Math.round(slope * point.x.toDouble + b))
// Determines if this segment lies below the given point // Determines if this segment lies below the given point
def < (point: Point) = (point.y > slope * point.x + b) def < (point: Point) = (point.y.toFloat > Math.round(slope * point.x.toDouble + b))
} }

View File

@ -34,6 +34,7 @@ object Sink {
def init(trapezoid: Trapezoid) = { def init(trapezoid: Trapezoid) = {
if(trapezoid.sink != null) if(trapezoid.sink != null)
// What about adding to the parent list?
trapezoid.sink trapezoid.sink
else else
new Sink(trapezoid) new Sink(trapezoid)

View File

@ -74,7 +74,7 @@ class Trapezoid(val leftPoint: Point, var rightPoint: Point, val top: Segment, v
} }
def lineIntersect(s: Segment, x: Float) = { def lineIntersect(s: Segment, x: Float) = {
val y = s.slope * x + s.b val y = (s.slope * x + s.b).toFloat
Point(x, y) Point(x, y)
} }

View File

@ -147,8 +147,8 @@ class Triangulator(segments: ArrayBuffer[Segment]) {
segs += new Segment(s.p.clone, s.q.clone) segs += new Segment(s.p.clone, s.q.clone)
// Randomized triangulation improves performance // Randomized triangulation improves performance
// See Seidel's paper, or O'Rourke's book, p. 57 // See Seidel's paper, or O'Rourke's book, p. 57
// Turn this off for now because of pointer bug somewhere in DAG / trapezoidal map // Turn this off for while bug hunting math robustness issues
Random.shuffle(segs) //Random.shuffle(segs)
segs segs
} }
} }