Skip to content

Instantly share code, notes, and snippets.

Created June 14, 2014 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/b6054b7a79b8427f41d2 to your computer and use it in GitHub Desktop.
Save anonymous/b6054b7a79b8427f41d2 to your computer and use it in GitHub Desktop.
test
from mathutils import Vector
from random import random
ul = [[[random(),random(),random()] for i in range(1000)]]
v1 = [[[random(),random(),random()] for i in range(1000)]]
v2 = [[[0,0,1]]]
def fullList(l, count):
d = count - len(l)
if d > 0:
l.extend([l[-1] for a in range(d)])
return
cross = lambda u,v:Vector(u).cross(v)[:]
def recurse_fxy( l1, l2, f, leve):
if not leve:
return f(l1, l2)
else:
max_obj = max(len(l1), len(l2))
fullList(l1, max_obj)
fullList(l2, max_obj)
return [recurse_fxy(l1[i], l2[i], f, leve-1) for i in range(len(l1))]
def recurse_fxy2(l1, l2, f, leve):
if leve==1:
max_obj = max(len(l1),len(l2))
res = []
res_append = res.append
for i,obj in enumerate(zip(l1,l2)):
res_append(f(obj[0], obj[1]))
if i < max_obj-1:
if len(l1)-1==i:
v_l1=l1[-1]
for i in range(i,max_obj):
res_append(f(v_l1,l2[i]))
else:
v_l2=Vector(l2[-1])
for i in range(i,max_obj):
res_append(f(l1[i],v_l2))
return res
elif leve > 1:
max_obj = max(len(l1),len(l2))
fullList(l1, max_obj)
fullList(l2, max_obj)
res = []
for i in range(len(l1)):
res.append(recurse_fxy2(l1[i], l2[i],f, leve-1))
return res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment