mirror of
https://github.com/jhasse/poly2tri.git
synced 2024-11-26 15:26:12 +01:00
changed ynode
This commit is contained in:
parent
3d9b6d8a83
commit
243adc1865
@ -104,37 +104,17 @@ class Edge(object):
|
||||
self.mpoints.append(p)
|
||||
self.mpoints.append(q)
|
||||
|
||||
##
|
||||
## NOTE Rounding accuracy significantly effects numerical robustness!!!
|
||||
##
|
||||
|
||||
def is_above(self, point):
|
||||
cdef double *a = [self.p.x, self.p.y]
|
||||
cdef double *b = [self.q.x, self.q.y]
|
||||
cdef double *c = [point.x, point.y]
|
||||
return orient2d(a, b, c) < 0
|
||||
return orient2d(a, b, c) < 0.0
|
||||
|
||||
def is_below(self, point):
|
||||
cdef double *a = [self.p.x, self.p.y]
|
||||
cdef double *b = [self.q.x, self.q.y]
|
||||
cdef double *c = [point.x, point.y]
|
||||
return orient2d(a, b, c) > 0
|
||||
|
||||
def intersect(self, c, d):
|
||||
a = self.p
|
||||
b = self.q
|
||||
a1 = self.signed_area(a, b, d)
|
||||
a2 = self.signed_area(a, b, c)
|
||||
if a1 != 0.0 and a2 != 0.0 and (a1 * a2) < 0.0:
|
||||
a3 = self.signed_area(c, d, a)
|
||||
a4 = a3 + a2 - a1
|
||||
if a3 * a4 < 0.0:
|
||||
t = a3 / (a3 - a4)
|
||||
return a + ((b - a) * t)
|
||||
return 0.0
|
||||
|
||||
def signed_area(self, a, b, c):
|
||||
return (a.x - c.x) * (b.y - c.y) - (a.y - c.y) * (b.x - c.x)
|
||||
return orient2d(a, b, c) > 0.0
|
||||
|
||||
class Trapezoid(object):
|
||||
|
||||
@ -497,7 +477,7 @@ class YNode(Node):
|
||||
return self.rchild.locate(edge)
|
||||
if self.edge.is_below(edge.p):
|
||||
return self.lchild.locate(edge)
|
||||
if edge.slope < self.edge.slope:
|
||||
if self.edge.is_above(edge.q):
|
||||
return self.rchild.locate(edge)
|
||||
return self.lchild.locate(edge)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user