From 93e9955a6610a37763c04b54f0ce9739d91c9560 Mon Sep 17 00:00:00 2001 From: zzzzrrr Date: Thu, 19 Nov 2009 12:27:34 -0500 Subject: [PATCH] added SHEAR setting --- python/poly2tri.py | 6 ++++-- python/seidel.py | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/python/poly2tri.py b/python/poly2tri.py index 9350017..aa2eb35 100644 --- a/python/poly2tri.py +++ b/python/poly2tri.py @@ -30,12 +30,12 @@ class Poly2Tri(Game): pass def render(self): - reset_zoom(8, (0, 0), self.screen_size) + reset_zoom(7, (0, 0), self.screen_size) red = 255, 0, 0 for t in self.triangles: draw_polygon(t, red) green = 0, 255, 0 - #draw_polygon(self.points, green) + draw_polygon(self.points, green) ''' yellow = 255, 255, 0 for t in self.trapezoids: @@ -54,6 +54,8 @@ class Poly2Tri(Game): break points.append((float(s[0]), float(s[1]))) return points + +bad = (544.80998999999997, 579.86046999999996), (544.80998999999997, 450.57477), (594.09569999999997, 450.57477), (643.38142000000005, 450.57477), (643.38142000000005, 525.26486999999997), (643.38142000000005, 599.95487000000003), (603.67391999999995, 654.55056999999999), (563.96655999999996, 709.14621999999997), (554.38819999999998, 709.14621999999997), (544.80998999999997, 709.14621999999997) if __name__ == '__main__': demo = Poly2Tri() \ No newline at end of file diff --git a/python/seidel.py b/python/seidel.py index 6c4c596..c2cac75 100644 --- a/python/seidel.py +++ b/python/seidel.py @@ -38,6 +38,9 @@ from math import atan2 ## (Ported from poly2tri) ## +# Shear transform. Can effect numerical robustness +SHEAR = 1e-6 + class Point(object): def __init__(self, x, y): @@ -297,11 +300,11 @@ class Triangulator(object): edges.append(Edge(q, p)) elif p.x < q.x: edges.append(Edge(p, q)) - #shuffle(edges) + shuffle(edges) return edges def shear_transform(self, point): - return Point(point.x + 1e-4 * point.y, point.y) + return Point(point.x + SHEAR * point.y, point.y) def merge_sort(l): if len(l)>1 :