Newer
Older
#
# This work may be reproduced, modified, distributed,
# performed, and displayed for any purpose, but must
# acknowledge this project. Copyright is retained and
# must be preserved. The work is provided as is; no
# warranty is provided, and users accept all liability.
#
############################################################
# uncomment for desired output
############################################################
output = "top, labels, and exterior"
#output = "top, labels, holes, and exterior"
#output = "bottom traces reversed and exterior"
#output = "holes"
############################################################
############################################################
############################################################
############################################################
# circle(x,y,r)
# cylinder(x,y,z0,z1,r)
# cone(x,y,z0,z1,r)
# sphere(x,y,z,r)
# torus(x,y,z,r0,r1)
# rectangle(x0,x1,y0,y1)
# cube(x0,x1,y0,y1,z0,z1)
# line(x0,y0,x1,y1,z,width)
# right_triangle(x,y,h)
# triangle(x0,y0,x1,y1,x2,y2) (points in clockwise order)
# pyramid(x0,x1,y0,y1,z0,z1)
# function(Z_of_XY)
# functions(upper_Z_of_XY,lower_Z_of_XY)
# add(part1,part2)
# subtract(part1,part2)
# intersect(part1,part2)
# move(part,dx,dy)
# translate(part,dx,dy,dz)
# rotate(part, angle)
# rotate_x(part,angle)
# rotate_y(part,angle)
# rotate_z(part,angle)
# rotate_90(part)
# rotate_180(part)
# rotate_270(part)
# reflect_x(part,x0)
# reflect_y(part,y0)
# reflect_z(part,z0)
# reflect_xy(part)
# reflect_xz(part)
# reflect_yz(part)
# scale_x(part,x0,sx)
# scale_y(part,y0,sy)
# scale_z(part,z0,sz)
# scale_xy(part,x0,y0,sxy)
# scale_xyz(part,x0,y0,z0,sxyz)
# coscale_x_y(part,x0,y0,y1,angle0,angle1,amplitude,offset)
# coscale_x_z(part,x0,z0 z1,angle0,angle1,amplitude,offset)
# coscale_xy_z(part,x0,y0,z0,z1,angle0,angle1,amplitude,offset)
# taper_x_y(part,x0,y0,y1,s0,s1)
# taper_x_z(part,x0,z0,z1,s0,s1)
# taper_xy_z(part,x0,y0,z0,z1,s0,s1)
# shear_x_y(part,y0,y1,dx0,dx1)
# shear_x_z(part,z0,z1,dx0,dx1)
part = '('+str(color)+'*(('+part+')!=0))'
return part
Red = (225 << 0)
Green = (225 << 8)
Blue = (225 << 16)
Gray = (128 << 16) + (128 << 8) + (128 << 0)
White = (255 << 16) + (255 << 8) + (255 << 0)
Teal = (255 << 16) + (255 << 8)
Pink = (255 << 16) + (255 << 0)
Yellow = (255 << 8) + (255 << 0)
Brown = (45 << 16) + (82 << 8) + (145 << 0)
Navy = (128 << 16) + (0 << 8) + (0 << 0)
Tan = (60 << 16) + (90 << 8) + (125 << 0)
part = "(((X-(x0))*(X-(x0)) + (Y-(y0))*(Y-(y0))) <= (r*r))"
part = part.replace('x0',str(x0))
part = part.replace('y0',str(y0))
part = part.replace('r',str(r))
return part
part = "(((X-(x0))*(X-(x0)) + (Y-(y0))*(Y-(y0)) <= (r*r)) & (Z >= (z0)) & (Z <= (z1)))"
part = part.replace('x0',str(x0))
part = part.replace('y0',str(y0))
part = part.replace('z0',str(z0))
part = part.replace('z1',str(z1))
part = part.replace('r',str(r))
return part
part = cylinder(x0, y0, z0, z1, r0)
part = taper_xy_z(part, x0, y0, z0, z1, 1.0, 0.0)
return part
part = "(((X-(x0))*(X-(x0)) + (Y-(y0))*(Y-(y0)) + (Z-(z0))*(Z-(z0))) <= (r*r))"
part = part.replace('x0',str(x0))
part = part.replace('y0',str(y0))
part = part.replace('z0',str(z0))
part = part.replace('r',str(r))
return part
part = "(((r0 - sqrt((X-(x0))*(X-(x0)) + (Y-(y0))*(Y-(y0))))*(r0 - sqrt((X-(x0))*(X-(x0)) + (Y-(y0))*(Y-(y0))) + (Z-(z0))*(Z-(z0))) <= (r1*r1))"
part = part.replace('x0',str(x0))
part = part.replace('y0',str(y0))
part = part.replace('z0',str(z0))
part = part.replace('r0',str(r0))
part = part.replace('r1',str(r1))
return part
part = "((X >= (x0)) & (X <= (x1)) & (Y >= (y0)) & (Y <= (y1)))"
part = part.replace('x0',str(x0))
part = part.replace('x1',str(x1))
part = part.replace('y0',str(y0))
part = part.replace('y1',str(y1))
return part
part = "((X >= (x0)) & (X <= (x1)) & (Y >= (y0)) & (Y <= (y1)) & (Z >= (z0)) & (Z <= (z1)))"
part = part.replace('x0',str(x0))
part = part.replace('x1',str(x1))
part = part.replace('y0',str(y0))
part = part.replace('y1',str(y1))
part = part.replace('z0',str(z0))
part = part.replace('z1',str(z1))
return part
def line(x0,y0,x1,y1,z,width):
dx = x1-x0
dy = y1-y0
l = math.sqrt(dx*dx+dy*dy)
nx = dx/l
ny = dy/l
rx = -ny
ry = nx
roundoff = 1e-6
part = "((((X-(x0))*(nx)+(Y-(y0))*(ny)) >= 0) & (((X-(x0))*(nx)+(Y-(y0))*(ny)) <= l) & (((X-(x0))*(rx)+(Y-(y0))*(ry)) >= (-width/2)) & (((X-(x0))*(rx)+(Y-(y0))*(ry)) <= (width/2)) & (Z > (z-roundoff)) & (Z < (z+roundoff)))"
part = part.replace('x0',str(x0))
part = part.replace('x1',str(x1))
part = part.replace('y0',str(y0))
part = part.replace('y1',str(y1))
part = part.replace('nx',str(nx))
part = part.replace('ny',str(ny))
part = part.replace('rx',str(rx))
part = part.replace('ry',str(ry))
part = part.replace('l',str(l))
part = part.replace('z',str(z))
part = part.replace('roundoff',str(roundoff))
part = part.replace('width',str(width))
return part
def right_triangle(x0,y0,l):
part = "((X > x0) & (X < x0 + l - (Y-y0)) & (Y > y0))"
part = part.replace('x0',str(x0))
part = part.replace('y0',str(y0))
part = part.replace('l',str(l))
return part
def triangle(x0,y0,x1,y1,x2,y2): # points in clockwise order
part = "(((((y1)-(y0))*(X-(x0))-((x1)-(x0))*(Y-(y0))) >= 0) & ((((y2)-(y1))*(X-(x1))-((x2)-(x1))*(Y-(y1))) >= 0) & ((((y0)-(y2))*(X-(x2))-((x0)-(x2))*(Y-(y2))) >= 0))"
Loading
Loading full blame...