# # bearing.cad # # # define limits and parameters # cad_xmin = -.7 cad_xmax = .7 cad_ymin = -.7 cad_ymax = .7 cad_zmin = -.2 cad_zmax = .2 cad_rx = 30 cad_rz = 45 cad_units = 'in' # coordinates units cad_bit_depth = '1' # bit depth cad_npts = 250 cad_nx = cad_npts # x points to render cad_ny = cad_npts # y points to render cad_nz = 100 # z points to render # # define shapes and transformation # def sphere(x0, y0, z0, r): string = "(((X-x0)**2 + (Y-y0)**2 + (Z-z0)**2) <= r**2)" string = replace(string,'x0',str(x0)) string = replace(string,'y0',str(y0)) string = replace(string,'z0',str(z0)) string = replace(string,'r',str(r)) return string def cylinder(x0, y0, z0, z1, r): string = "(((X-x0)**2 + (Y-y0)**2 <= r**2) & (Z >= z0) & (Z <= z1))" string = replace(string,'x0',str(x0)) string = replace(string,'y0',str(y0)) string = replace(string,'z0',str(z0)) string = replace(string,'z1',str(z1)) string = replace(string,'r',str(r)) return string def cube(x0, x1, y0, y1, z0, z1): string = "((X >= x0) & (X <= x1) & (Y >= y0) & (Y <= y1) & (Z >= z0) & (Z <= z1))" string = replace(string,'x0',str(x0)) string = replace(string,'x1',str(x1)) string = replace(string,'y0',str(y0)) string = replace(string,'y1',str(y1)) string = replace(string,'z0',str(z0)) string = replace(string,'z1',str(z1)) return string def translate(string,dx,dy,dz): string = replace(string,'X','(X-'+str(dx)+')') string = replace(string,'Y','(Y-'+str(dy)+')') string = replace(string,'Z','(Z-'+str(dz)+')') return string def union(string1, string2): string = "(string1) | (string2)" string = replace(string,'string1',string1) string = replace(string,'string2',string2) return string def intersect(string1, string2): string = "(string1) & (string2)" string = replace(string,'string1',string1) string = replace(string,'string2',string2) return string def subtract(string1, string2): string = "(string1) & ~(string2)" string = replace(string,'string1',string1) string = replace(string,'string2',string2) return string def rotate_x(string, theta): string = replace(string,'Y','(cos(theta)*Y+sin(theta)*z)') string = replace(string,'Z','(-sin(theta)*Y+cos(theta)*z)') string = replace(string,'z','Z') string = replace(string,'theta',theta) return string def rotate_y(string, theta): string = replace(string,'X','(cos(theta)*X+sin(theta)*z)') string = replace(string,'Z','(-sin(theta)*X+cos(theta)*z)') string = replace(string,'z','Z') string = replace(string,'theta',theta) return string def rotate_z(string, theta): string = replace(string,'X','(cos(theta)*X+sin(theta)*y)') string = replace(string,'Y','(-sin(theta)*X+cos(theta)*y)') string = replace(string,'y','Y') string = replace(string,'theta',theta) return string # # Amy Sun's bearing # origin_x = 0 origin_y = 0 height = 0.25 wall = 0.10 OD = 1.0 O_r = OD / 2 OD_O = cylinder(origin_x, origin_y, -height/2, height/2, O_r + wall/2) OD_I = cylinder(origin_x, origin_y, -height/2, height/2, O_r - wall/2) OD = subtract(OD_O,OD_I) ID = 0.5 I_r = ID / 2 ID_O = cylinder(origin_x, origin_y, -height/2, height/2, I_r + wall/2) ID_I = cylinder(origin_x, origin_y, -height/2, height/2, I_r - wall/2) ID = subtract(ID_O,ID_I) cage = union(OD,ID) # race radius R_r = ((O_r - I_r) / 2) + I_r # bearing radius bearing_diameter = .40 #b_r = bearing_diameter/2 b_r = bearing_diameter/4. race_O = cylinder(origin_x, origin_y, -(height/2.)/3., (height/2.)/3., R_r+b_r) race_I = cylinder(origin_x, origin_y, -(height/2.)/3., (height/2.)/3., R_r-b_r) race = subtract(race_O,race_I) frame = union(OD,ID) outer_part = subtract(frame,race) #bearings # num balls Nb = 6. ball1 = sphere(cos(2*pi/Nb)*R_r, sin(2*pi/Nb)*R_r, 0, b_r) ball2 = sphere(cos(2*2*pi/Nb)*R_r, sin(2*2*pi/Nb)*R_r, 0, b_r) ball3 = sphere(cos(3*2*pi/Nb)*R_r, sin(3*2*pi/Nb)*R_r, 0, b_r) ball4 = sphere(cos(4*2*pi/Nb)*R_r, sin(4*2*pi/Nb)*R_r, 0, b_r) ball5 = sphere(cos(5*2*pi/Nb)*R_r, sin(5*2*pi/Nb)*R_r, 0, b_r) ball6 = sphere(cos(6*2*pi/Nb)*R_r, sin(6*2*pi/Nb)*R_r, 0, b_r) balls = union(ball1,ball2) balls = union(balls,ball3) balls = union(balls,ball4) balls = union(balls,ball5) balls = union(balls,ball6) bearing = union(outer_part,balls) cutaway_bearing = subtract(bearing,cube(0,2,-2,0,-2,2)) # # assign part to SAT_function # SAT_function = cutaway_bearing