mirror of
https://github.com/jhasse/poly2tri.git
synced 2024-11-05 13:59:53 +01:00
fixed seidel numerical accuracy bug
This commit is contained in:
parent
48805d55db
commit
7f473799ac
@ -11,7 +11,7 @@ class Poly2Tri(Game):
|
||||
super(Poly2Tri, self).__init__(*self.screen_size)
|
||||
|
||||
# Load point set
|
||||
file_name = "../data/dude.dat"
|
||||
file_name = "../data/nazca_monkey.dat"
|
||||
self.points = self.load_points(file_name)
|
||||
|
||||
# Triangulate
|
||||
@ -30,7 +30,7 @@ class Poly2Tri(Game):
|
||||
pass
|
||||
|
||||
def render(self):
|
||||
reset_zoom(2.0, (400, 500), self.screen_size)
|
||||
reset_zoom(8, (0, 0), self.screen_size)
|
||||
red = 255, 0, 0
|
||||
for t in self.triangles:
|
||||
draw_polygon(t, red)
|
||||
|
@ -30,7 +30,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
from random import shuffle
|
||||
from math import atan2, floor
|
||||
from math import atan2
|
||||
|
||||
##
|
||||
## Based on Raimund Seidel'e paper "A simple and fast incremental randomized
|
||||
@ -94,10 +94,12 @@ class Edge(object):
|
||||
self.mpoints.append(q)
|
||||
|
||||
def is_above(self, point):
|
||||
return (floor(point.y) < floor(self.slope * point.x + self.b))
|
||||
# NOTE rounding can effect numerical robustness
|
||||
return (round(point.y, 10) < round(self.slope * point.x + self.b, 10))
|
||||
|
||||
def is_below(self, point):
|
||||
return (floor(point.y) > floor(self.slope * point.x + self.b))
|
||||
# NOTE rounding can effect numerical robustness
|
||||
return (round(point.y, 10) > round(self.slope * point.x + self.b, 10))
|
||||
|
||||
def intersect(self, c, d):
|
||||
a = self.p
|
||||
|
Loading…
Reference in New Issue
Block a user