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) {
poly
val foo = 1.4
println(Math.round(foo.toDouble))
}
def update(gc: GameContainer, delta: Int) {
@ -171,14 +173,13 @@ class Poly2TriDemo extends BasicGame("Poly2Tri") {
val p16 = Point(300,312)
segments = new ArrayBuffer[Segment]
segments += new Segment(p2, p3)
segments += new Segment(p1, p2)
segments += new Segment(p7, p1)
segments += new Segment(p4, p5)
segments += new Segment(p2, p3)
segments += new Segment(p3, p4)
segments += new Segment(p4, p5)
segments += new Segment(p5, p6)
segments += new Segment(p6, p7)
segments += new Segment(p3, p4)
segments += new Segment(p7, p8)
segments += new Segment(p8, p9)
segments += new Segment(p9, p10)
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
// 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
val b = p.y - (p.x * slope)
val b = (p.y - (p.x * slope)).toDouble
// 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
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) = {
if(trapezoid.sink != null)
// What about adding to the parent list?
trapezoid.sink
else
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) = {
val y = s.slope * x + s.b
val y = (s.slope * x + s.b).toFloat
Point(x, y)
}

View File

@ -147,8 +147,8 @@ class Triangulator(segments: ArrayBuffer[Segment]) {
segs += new Segment(s.p.clone, s.q.clone)
// Randomized triangulation improves performance
// 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
Random.shuffle(segs)
// Turn this off for while bug hunting math robustness issues
//Random.shuffle(segs)
segs
}
}