Small cleanups

This commit is contained in:
Grant Sanderson 2021-02-02 15:56:55 -08:00
parent dda9683fb7
commit 1097f0df96
2 changed files with 14 additions and 14 deletions

View file

@ -21,7 +21,7 @@ tex:
template_file: "tex_template.tex" template_file: "tex_template.tex"
intermediate_filetype: "dvi" intermediate_filetype: "dvi"
text_to_replace: "[tex_expression]" text_to_replace: "[tex_expression]"
# # For ctex, use the following configuration # For ctex, use the following configuration
# executable: "xelatex -no-pdf" # executable: "xelatex -no-pdf"
# template_file: "ctex_template.tex" # template_file: "ctex_template.tex"
# intermediate_filetype: "xdv" # intermediate_filetype: "xdv"

View file

@ -361,16 +361,15 @@ def earclip_triangulation(verts, rings):
n = len(verts) n = len(verts)
# Establish where loop indices should be connected # Establish where loop indices should be connected
loop_connections = dict() loop_connections = dict()
# for e0, e1 in zip(rings, rings[1:]): end0 = rings[0]
e0 = rings[0] for end1 in rings[1:]:
for e1 in rings[1:]: # Find the closet pair of points with the first
# Find closet pair of points with the first # from the current ring, and the second from the
# coming from the current ring, and the second # next ring
# coming from the next ring
index_pairs = [ index_pairs = [
(i, j) (i, j)
for i in range(0, e0) for i in range(0, end0)
for j in range(e0, e1) for j in range(end0, end1)
if i not in loop_connections if i not in loop_connections
if j not in loop_connections if j not in loop_connections
] ]
@ -383,14 +382,15 @@ def earclip_triangulation(verts, rings):
# it's treated as a single highly-convex ring # it's treated as a single highly-convex ring
loop_connections[i] = j loop_connections[i] = j
loop_connections[j] = i loop_connections[j] = i
e0 = e1 end0 = end1
# Setup linked list # Setup linked list
after = [] after = []
e0 = 0 end0 = 0
for e1 in rings: for end1 in rings:
after.extend([*range(e0 + 1, e1), e0]) after.extend(range(end0 + 1, end1))
e0 = e1 after.append(end0)
end0 = end1
# Find an ordering of indices walking around the polygon # Find an ordering of indices walking around the polygon
indices = [] indices = []