summaryrefslogtreecommitdiff
path: root/make.py
diff options
context:
space:
mode:
authorAnthony LaTorre <tlatorre9@gmail.com>2011-08-17 11:54:41 -0400
committerAnthony LaTorre <tlatorre9@gmail.com>2011-08-17 11:54:41 -0400
commit11210ce25a543875eb51cff8efc06e7f02984214 (patch)
treec9f3dfc8a2540a7a23b3fb8b809791641a7082b1 /make.py
parentd036821cd62c5b2c913999feebd5bbe4549c16fa (diff)
downloadchroma-11210ce25a543875eb51cff8efc06e7f02984214.tar.gz
chroma-11210ce25a543875eb51cff8efc06e7f02984214.tar.bz2
chroma-11210ce25a543875eb51cff8efc06e7f02984214.zip
move useful bits from view.py into camera.py and get rid of view.py
Diffstat (limited to 'make.py')
-rw-r--r--make.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/make.py b/make.py
index 0375084..523b10f 100644
--- a/make.py
+++ b/make.py
@@ -6,7 +6,7 @@ from chroma.itertoolset import *
def mesh_grid(grid):
return np.vstack(zip(grid[:-1].flatten(),grid[1:].flatten(),np.roll(grid[1:],-1,1).flatten()) + zip(grid[:-1].flatten(),np.roll(grid[1:],-1,1).flatten(),np.roll(grid[:-1],-1,1).flatten()))
-def linear_extrude(x1, y1, height, x2=None, y2=None):
+def linear_extrude(x1, y1, height, x2=None, y2=None, center=None):
"""
Return the solid mesh formed by linearly extruding the polygon formed by
the x and y points `x1` and `y1` by a distance `height`. If `x2` and `y2`
@@ -41,6 +41,9 @@ def linear_extrude(x1, y1, height, x2=None, y2=None):
vertices = np.fromiter(flatten(roundrobin(*vertex_iterators)), float)
vertices = vertices.reshape((len(vertices)//3,3))
+ if center is not None:
+ vertices += center
+
triangles = mesh_grid(np.arange(len(vertices)).reshape((len(x1),len(vertices)//len(x1))).transpose()[::-1])
return Mesh(vertices, triangles, remove_duplicate_vertices=True)
@@ -65,6 +68,10 @@ def rotate_extrude(x, y, nsteps=64):
return Mesh(vertices, triangles, remove_duplicate_vertices=True)
+def box(dx, dy, dz, center=(0,0,0)):
+ "Return a box with linear dimensions `dx`, `dy`, and `dz`."
+ return linear_extrude([-dx/2.0,dx/2.0,dx/2.0,-dx/2.0],[-dy/2.0,-dy/2.0,dy/2.0,dy/2.0],height=dz,center=center)
+
def cube(size=1, height=None):
"Return a cube mesh whose sides have length `size`."
if height is None: