diff options
author | Anthony LaTorre <telatorre@gmail.com> | 2011-05-15 16:28:00 -0400 |
---|---|---|
committer | Anthony LaTorre <telatorre@gmail.com> | 2011-05-15 16:28:00 -0400 |
commit | 8ea783d053e817568b3e7d04f28a6fd2583f18cf (patch) | |
tree | 9529ff81a9e8b0b986cd125d310f65bbcb9df2b0 /zcurve.py | |
parent | 6df4500c56bd5f8c90ed18c07eac6eae1ca7e9fb (diff) | |
download | chroma-8ea783d053e817568b3e7d04f28a6fd2583f18cf.tar.gz chroma-8ea783d053e817568b3e7d04f28a6fd2583f18cf.tar.bz2 chroma-8ea783d053e817568b3e7d04f28a6fd2583f18cf.zip |
new geometry class. beginning to implement physics by defining a material class; each triangle will have a material linked to both of its sides
Diffstat (limited to 'zcurve.py')
-rw-r--r-- | zcurve.py | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/zcurve.py b/zcurve.py deleted file mode 100644 index 5ef37f3..0000000 --- a/zcurve.py +++ /dev/null @@ -1,25 +0,0 @@ -import numpy as np -from itertools import chain - -def interleave(*args): - return int("".join(chain(*zip(*[bin(x)[2:].zfill(x.nbytes*8) for x in args]))), 2) - -def morton_order(mesh, dtype=np.uint8): - vertices = mesh.reshape(mesh.shape[0]*3, 3) - - upper_bound = np.max(vertices, axis=0) - lower_bound = np.min(vertices, axis=0) - - quantize = lambda x: dtype((x-lower_bound)*np.iinfo(dtype).max/(upper_bound-lower_bound)) - - zvalue = [] - for triangle in mesh: - center = np.mean(np.vstack((triangle[0], triangle[1], triangle[2])), axis=0) - zvalue.append(interleave(*quantize(center))) - - ordered_mesh = np.empty(mesh.shape) - - for i, idx in enumerate(zip(*sorted(zip(zvalue, range(len(zvalue)))))[-1]): - ordered_mesh[i] = mesh[idx] - - return ordered_mesh |