Skip to content

Instantly share code, notes, and snippets.

@zeffii
Last active February 15, 2017 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/f06c49d67724d637aa258fac001497d9 to your computer and use it in GitHub Desktop.
Save zeffii/f06c49d67724d637aa258fac001497d9 to your computer and use it in GitHub Desktop.
"""
in gp_verts v
in filter_dist s d=0.2 n=2
out points v
"""
import math
def dist(a, b):
v = a[0]-b[0], a[1]-b[1], a[2]-b[2]
return math.sqrt((v[0] * v[0]) + (v[1] * v[1]) + (v[2] * v[2]))
points = []
for vecs in gp_verts:
new_points = []
append = new_points.append
append(vecs[0])
for idx in range(0, len(vecs)-2):
a = new_points[-1]
b = vecs[idx + 1]
d = dist(a, b)
if d < filter_dist:
continue
append(b)
append(vecs[-1])
points.append(new_points)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment