mirror of
https://github.com/jhasse/poly2tri.git
synced 2024-11-19 12:06:09 +01:00
added SHEAR setting
This commit is contained in:
parent
7f473799ac
commit
93e9955a66
@ -30,12 +30,12 @@ class Poly2Tri(Game):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def render(self):
|
def render(self):
|
||||||
reset_zoom(8, (0, 0), self.screen_size)
|
reset_zoom(7, (0, 0), self.screen_size)
|
||||||
red = 255, 0, 0
|
red = 255, 0, 0
|
||||||
for t in self.triangles:
|
for t in self.triangles:
|
||||||
draw_polygon(t, red)
|
draw_polygon(t, red)
|
||||||
green = 0, 255, 0
|
green = 0, 255, 0
|
||||||
#draw_polygon(self.points, green)
|
draw_polygon(self.points, green)
|
||||||
'''
|
'''
|
||||||
yellow = 255, 255, 0
|
yellow = 255, 255, 0
|
||||||
for t in self.trapezoids:
|
for t in self.trapezoids:
|
||||||
@ -55,5 +55,7 @@ class Poly2Tri(Game):
|
|||||||
points.append((float(s[0]), float(s[1])))
|
points.append((float(s[0]), float(s[1])))
|
||||||
return points
|
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__':
|
if __name__ == '__main__':
|
||||||
demo = Poly2Tri()
|
demo = Poly2Tri()
|
@ -38,6 +38,9 @@ from math import atan2
|
|||||||
## (Ported from poly2tri)
|
## (Ported from poly2tri)
|
||||||
##
|
##
|
||||||
|
|
||||||
|
# Shear transform. Can effect numerical robustness
|
||||||
|
SHEAR = 1e-6
|
||||||
|
|
||||||
class Point(object):
|
class Point(object):
|
||||||
|
|
||||||
def __init__(self, x, y):
|
def __init__(self, x, y):
|
||||||
@ -297,11 +300,11 @@ class Triangulator(object):
|
|||||||
edges.append(Edge(q, p))
|
edges.append(Edge(q, p))
|
||||||
elif p.x < q.x:
|
elif p.x < q.x:
|
||||||
edges.append(Edge(p, q))
|
edges.append(Edge(p, q))
|
||||||
#shuffle(edges)
|
shuffle(edges)
|
||||||
return edges
|
return edges
|
||||||
|
|
||||||
def shear_transform(self, point):
|
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):
|
def merge_sort(l):
|
||||||
if len(l)>1 :
|
if len(l)>1 :
|
||||||
|
Loading…
Reference in New Issue
Block a user