mirror of
https://github.com/jhasse/poly2tri.git
synced 2024-11-30 01:03:30 +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)
|
super(Poly2Tri, self).__init__(*self.screen_size)
|
||||||
|
|
||||||
# Load point set
|
# Load point set
|
||||||
file_name = "../data/dude.dat"
|
file_name = "../data/nazca_monkey.dat"
|
||||||
self.points = self.load_points(file_name)
|
self.points = self.load_points(file_name)
|
||||||
|
|
||||||
# Triangulate
|
# Triangulate
|
||||||
@ -30,7 +30,7 @@ class Poly2Tri(Game):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def render(self):
|
def render(self):
|
||||||
reset_zoom(2.0, (400, 500), self.screen_size)
|
reset_zoom(8, (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)
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#
|
#
|
||||||
from random import shuffle
|
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
|
## Based on Raimund Seidel'e paper "A simple and fast incremental randomized
|
||||||
@ -94,10 +94,12 @@ class Edge(object):
|
|||||||
self.mpoints.append(q)
|
self.mpoints.append(q)
|
||||||
|
|
||||||
def is_above(self, point):
|
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):
|
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):
|
def intersect(self, c, d):
|
||||||
a = self.p
|
a = self.p
|
||||||
|
Loading…
Reference in New Issue
Block a user