Skip to content

Commit 05c5190

Browse files
authored
Merge pull request sseemayer#8 from hsharrison/master
Python3 compatibility
2 parents 97bdc69 + adc6623 commit 05c5190

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

‎py2d/Math/Polygon.py‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ def inorder_extend(v, v1, v2, ints):
211211

212212

213213
# extend vector rings by intersections
214-
for k, v in intersections_a.iteritems():
214+
for k, v in intersections_a.items():
215215
inorder_extend(v_a, k[0], k[1], v)
216216

217-
for k, v in intersections_b.iteritems():
217+
for k, v in intersections_b.items():
218218
inorder_extend(v_b, k[0], k[1], v)
219219

220220

@@ -249,7 +249,7 @@ def print_edge():
249249

250250
output = []
251251
while edge_fragments:
252-
start = edge_fragments.keys()[0]
252+
start = list(edge_fragments.keys())[0]
253253
current = edge_fragments[start][0]
254254
sequence = [start]
255255

@@ -427,7 +427,7 @@ def inorder_extend(v, v1, v2, ints):
427427

428428

429429
# add self-intersection points to poly
430-
for k, v in ints.iteritems():
430+
for k, v in ints.items():
431431
inorder_extend(pts, k[0], k[1], v)
432432

433433
# build a list of loops
@@ -833,8 +833,9 @@ def contains_point_s(pts, p) :
833833
# p is not on the boundary, cast ray and intersect to see if we are inside
834834
intersections = set(intersect_poly_ray(pts, p, p + Vector(1,0)))
835835

836+
836837
# filter intersection points that are boundary points
837-
for int_point in filter(lambda x: x in pts, intersections):
838+
for int_point in set(filter(lambda x: x in pts, intersections)):
838839

839840
i = pts.index(int_point)
840841
prv = pts[i-1]

‎py2d/Math/Vector.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ def __mul__(self, val):
7575
else:
7676
return Vector(self.x * val, self.y * val)
7777

78+
def __truediv__(self, val):
79+
return Vector(self.x / val, self.y / val)
80+
7881
def __div__(self, val):
7982
return Vector(self.x / val, self.y / val)
8083

0 commit comments

Comments
 (0)