mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Performance improvement for triangulation
This commit is contained in:
parent
1097f0df96
commit
2fbe0c6ee6
1 changed files with 15 additions and 9 deletions
|
@ -366,16 +366,22 @@ def earclip_triangulation(verts, rings):
|
||||||
# Find the closet pair of points with the first
|
# Find the closet pair of points with the first
|
||||||
# from the current ring, and the second from the
|
# from the current ring, and the second from the
|
||||||
# next ring
|
# next ring
|
||||||
index_pairs = [
|
filtered_i, filtered_j = [
|
||||||
(i, j)
|
list(filter(
|
||||||
for i in range(0, end0)
|
lambda i: i not in loop_connections,
|
||||||
for j in range(end0, end1)
|
indices
|
||||||
if i not in loop_connections
|
))
|
||||||
if j not in loop_connections
|
for indices in (range(0, end0), range(end0, end1))
|
||||||
]
|
]
|
||||||
i, j = index_pairs[np.argmin([
|
|
||||||
norm_squared(verts[i] - verts[j])
|
i = filtered_i[np.argmin([
|
||||||
for i, j in index_pairs
|
# It's slightly faster to use L-infinity norm
|
||||||
|
max(abs(verts[i] - verts[end0]))
|
||||||
|
for i in filtered_i
|
||||||
|
])]
|
||||||
|
j = filtered_j[np.argmin([
|
||||||
|
max(abs(verts[i] - verts[j]))
|
||||||
|
for j in filtered_j
|
||||||
])]
|
])]
|
||||||
|
|
||||||
# Connect the polygon at these points so that
|
# Connect the polygon at these points so that
|
||||||
|
|
Loading…
Add table
Reference in a new issue