* Math routines -UNLIST DEFINE('SQRT(x)') DEFINE('MIN(MIN,b)') DEFINE('MAX(MAX,b)') DEFINE('ABS(ABS)') DEFINE('cos(x)xi,xd,yd,y1,y2,y3') DEFINE('sin(x)') DEFINE('tan(x)') DEFINE('arcsin(x)a,y1,y2,yd,xd') * sin cos of angle in degrees.. accurate to about 4 places using linear interpolation costab = ARRAY('0:359') costab< 0 > = +1.00000000 costab< 1 > = +0.99984771 costab< 2 > = +0.99939084 costab< 3 > = +0.99862951 costab< 4 > = +0.99756408 costab< 5 > = +0.99619472 costab< 6 > = +0.99452192 costab< 7 > = +0.99254614 costab< 8 > = +0.99026805 costab< 9 > = +0.98768836 costab< 10 > = +0.98480773 costab< 11 > = +0.98162717 costab< 12 > = +0.97814763 costab< 13 > = +0.97437006 costab< 14 > = +0.97029573 costab< 15 > = +0.96592581 costab< 16 > = +0.96126169 costab< 17 > = +0.95630479 costab< 18 > = +0.95105654 costab< 19 > = +0.94551855 costab< 20 > = +0.93969262 costab< 21 > = +0.93358040 costab< 22 > = +0.92718387 costab< 23 > = +0.92050487 costab< 24 > = +0.91354543 costab< 25 > = +0.90630776 costab< 26 > = +0.89879405 costab< 27 > = +0.89100653 costab< 28 > = +0.88294756 costab< 29 > = +0.87461972 costab< 30 > = +0.86602539 costab< 31 > = +0.85716730 costab< 32 > = +0.84804809 costab< 33 > = +0.83867055 costab< 34 > = +0.82903761 costab< 35 > = +0.81915206 costab< 36 > = +0.80901700 costab< 37 > = +0.79863554 costab< 38 > = +0.78801078 costab< 39 > = +0.77714592 costab< 40 > = +0.76604444 costab< 41 > = +0.75470960 costab< 42 > = +0.74314481 costab< 43 > = +0.73135370 costab< 44 > = +0.71933979 costab< 45 > = +0.70710677 costab< 46 > = +0.69465840 costab< 47 > = +0.68199837 costab< 48 > = +0.66913056 costab< 49 > = +0.65605903 costab< 50 > = +0.64278764 costab< 51 > = +0.62932038 costab< 52 > = +0.61566150 costab< 53 > = +0.60181504 costab< 54 > = +0.58778524 costab< 55 > = +0.57357645 costab< 56 > = +0.55919290 costab< 57 > = +0.54463899 costab< 58 > = +0.52991927 costab< 59 > = +0.51503807 costab< 60 > = +0.49999997 costab< 61 > = +0.48480958 costab< 62 > = +0.46947160 costab< 63 > = +0.45399052 costab< 64 > = +0.43837115 costab< 65 > = +0.42261824 costab< 66 > = +0.40673661 costab< 67 > = +0.39073107 costab< 68 > = +0.37460664 costab< 69 > = +0.35836798 costab< 70 > = +0.34202015 costab< 71 > = +0.32556814 costab< 72 > = +0.30901697 costab< 73 > = +0.29237166 costab< 74 > = +0.27563739 costab< 75 > = +0.25881907 costab< 76 > = +0.24192190 costab< 77 > = +0.22495104 costab< 78 > = +0.20791166 costab< 79 > = +0.19080906 costab< 80 > = +0.17364822 costab< 81 > = +0.15643449 costab< 82 > = +0.13917311 costab< 83 > = +0.12186933 costab< 84 > = +0.10452842 costab< 85 > = +0.08715580 costab< 86 > = +0.06975651 costab< 87 > = +0.05233597 costab< 88 > = +0.03489950 costab< 89 > = +0.01745238 costab< 90 > = 0.0000000 costab< 91 > = -0.01745235 costab< 92 > = -0.03489946 costab< 93 > = -0.05233594 costab< 94 > = -0.06975648 costab< 95 > = -0.08715577 costab< 96 > = -0.10452851 costab< 97 > = -0.12186929 costab< 98 > = -0.13917308 costab< 99 > = -0.15643445 costab< 100 > = -0.17364819 costab< 101 > = -0.19080903 costab< 102 > = -0.20791174 costab< 103 > = -0.22495100 costab< 104 > = -0.24192187 costab< 105 > = -0.25881904 costab< 106 > = -0.27563736 costab< 107 > = -0.29237175 costab< 108 > = -0.30901703 costab< 109 > = -0.32556811 costab< 110 > = -0.34202012 costab< 111 > = -0.35836795 costab< 112 > = -0.37460661 costab< 113 > = -0.39073116 costab< 114 > = -0.40673670 costab< 115 > = -0.42261833 costab< 116 > = -0.43837112 costab< 117 > = -0.45399061 costab< 118 > = -0.46947157 costab< 119 > = -0.48480955 costab< 120 > = -0.50000006 costab< 121 > = -0.51503801 costab< 122 > = -0.52991933 costab< 123 > = -0.54463905 costab< 124 > = -0.55919284 costab< 125 > = -0.57357645 costab< 126 > = -0.58778518 costab< 127 > = -0.60181510 costab< 128 > = -0.61566144 costab< 129 > = -0.62932032 costab< 130 > = -0.64278764 costab< 131 > = -0.65605897 costab< 132 > = -0.66913068 costab< 133 > = -0.68199831 costab< 134 > = -0.69465846 costab< 135 > = -0.70710677 costab< 136 > = -0.71933973 costab< 137 > = -0.73135376 costab< 138 > = -0.74314481 costab< 139 > = -0.75470966 costab< 140 > = -0.76604444 costab< 141 > = -0.77714586 costab< 142 > = -0.78801078 costab< 143 > = -0.79863548 costab< 144 > = -0.80901706 costab< 145 > = -0.81915206 costab< 146 > = -0.82903761 costab< 147 > = -0.83867055 costab< 148 > = -0.84804803 costab< 149 > = -0.85716730 costab< 150 > = -0.86602539 costab< 151 > = -0.87461978 costab< 152 > = -0.88294756 costab< 153 > = -0.89100647 costab< 154 > = -0.89879405 costab< 155 > = -0.90630776 costab< 156 > = -0.91354549 costab< 157 > = -0.92050487 costab< 158 > = -0.92718381 costab< 159 > = -0.93358046 costab< 160 > = -0.93969262 costab< 161 > = -0.94551861 costab< 162 > = -0.95105648 costab< 163 > = -0.95630479 costab< 164 > = -0.96126169 costab< 165 > = -0.96592581 costab< 166 > = -0.97029573 costab< 167 > = -0.97437006 costab< 168 > = -0.97814763 costab< 169 > = -0.98162717 costab< 170 > = -0.98480773 costab< 171 > = -0.98768836 costab< 172 > = -0.99026805 costab< 173 > = -0.99254614 costab< 174 > = -0.99452192 costab< 175 > = -0.99619472 costab< 176 > = -0.99756408 costab< 177 > = -0.99862951 costab< 178 > = -0.99939084 costab< 179 > = -0.99984771 costab< 180 > = -1.00000000 costab< 181 > = -0.99984771 costab< 182 > = -0.99939084 costab< 183 > = -0.99862951 costab< 184 > = -0.99756408 costab< 185 > = -0.99619472 costab< 186 > = -0.99452192 costab< 187 > = -0.99254614 costab< 188 > = -0.99026805 costab< 189 > = -0.98768836 costab< 190 > = -0.98480773 costab< 191 > = -0.98162717 costab< 192 > = -0.97814757 costab< 193 > = -0.97437006 costab< 194 > = -0.97029573 costab< 195 > = -0.96592581 costab< 196 > = -0.96126169 costab< 197 > = -0.95630473 costab< 198 > = -0.95105654 costab< 199 > = -0.94551861 costab< 200 > = -0.93969262 costab< 201 > = -0.93358046 costab< 202 > = -0.92718381 costab< 203 > = -0.92050487 costab< 204 > = -0.91354543 costab< 205 > = -0.90630782 costab< 206 > = -0.89879411 costab< 207 > = -0.89100653 costab< 208 > = -0.88294762 costab< 209 > = -0.87461966 costab< 210 > = -0.86602539 costab< 211 > = -0.85716736 costab< 212 > = -0.84804809 costab< 213 > = -0.83867061 costab< 214 > = -0.82903755 costab< 215 > = -0.81915206 costab< 216 > = -0.80901694 costab< 217 > = -0.79863548 costab< 218 > = -0.78801084 costab< 219 > = -0.77714592 costab< 220 > = -0.76604450 costab< 221 > = -0.75470954 costab< 222 > = -0.74314481 costab< 223 > = -0.73135376 costab< 224 > = -0.71933979 costab< 225 > = -0.70710683 costab< 226 > = -0.69465834 costab< 227 > = -0.68199837 costab< 228 > = -0.66913050 costab< 229 > = -0.65605903 costab< 230 > = -0.64278752 costab< 231 > = -0.62932032 costab< 232 > = -0.61566150 costab< 233 > = -0.60181516 costab< 234 > = -0.58778507 costab< 235 > = -0.57357633 costab< 236 > = -0.55919290 costab< 237 > = -0.54463911 costab< 238 > = -0.52991939 costab< 239 > = -0.51503789 costab< 240 > = -0.49999991 costab< 241 > = -0.48480961 costab< 242 > = -0.46947163 costab< 243 > = -0.45399067 costab< 244 > = -0.43837097 costab< 245 > = -0.42261818 costab< 246 > = -0.40673664 costab< 247 > = -0.39073122 costab< 248 > = -0.37460679 costab< 249 > = -0.35836777 costab< 250 > = -0.34202006 costab< 251 > = -0.32556817 costab< 252 > = -0.30901709 costab< 253 > = -0.29237190 costab< 254 > = -0.27563721 costab< 255 > = -0.25881898 costab< 256 > = -0.24192193 costab< 257 > = -0.22495118 costab< 258 > = -0.20791192 costab< 259 > = -0.19080885 costab< 260 > = -0.17364813 costab< 261 > = -0.15643452 costab< 262 > = -0.13917325 costab< 263 > = -0.12186912 costab< 264 > = -0.10452834 costab< 265 > = -0.08715571 costab< 266 > = -0.06975655 costab< 267 > = -0.05233612 costab< 268 > = -0.03489929 costab< 269 > = -0.01745230 costab< 270 > = 0.0000000 costab< 271 > = +0.01745232 costab< 272 > = +0.03489931 costab< 273 > = +0.05233615 costab< 274 > = +0.06975657 costab< 275 > = +0.08715574 costab< 276 > = +0.10452836 costab< 277 > = +0.12186914 costab< 278 > = +0.13917327 costab< 279 > = +0.15643454 costab< 280 > = +0.17364815 costab< 281 > = +0.19080888 costab< 282 > = +0.20791148 costab< 283 > = +0.22495121 costab< 284 > = +0.24192195 costab< 285 > = +0.25881901 costab< 286 > = +0.27563721 costab< 287 > = +0.29237148 costab< 288 > = +0.30901712 costab< 289 > = +0.32556820 costab< 290 > = +0.34202009 costab< 291 > = +0.35836780 costab< 292 > = +0.37460679 costab< 293 > = +0.39073125 costab< 294 > = +0.40673667 costab< 295 > = +0.42261818 costab< 296 > = +0.43837100 costab< 297 > = +0.45399067 costab< 298 > = +0.46947166 costab< 299 > = +0.48480964 costab< 300 > = +0.49999991 costab< 301 > = +0.51503789 costab< 302 > = +0.52991945 costab< 303 > = +0.54463911 costab< 304 > = +0.55919290 costab< 305 > = +0.57357633 costab< 306 > = +0.58778507 costab< 307 > = +0.60181516 costab< 308 > = +0.61566150 costab< 309 > = +0.62932038 costab< 310 > = +0.64278752 costab< 311 > = +0.65605885 costab< 312 > = +0.66913074 costab< 313 > = +0.68199837 costab< 314 > = +0.69465834 costab< 315 > = +0.70710665 costab< 316 > = +0.71933961 costab< 317 > = +0.73135382 costab< 318 > = +0.74314487 costab< 319 > = +0.75470954 costab< 320 > = +0.76604432 costab< 321 > = +0.77714610 costab< 322 > = +0.78801084 costab< 323 > = +0.79863554 costab< 324 > = +0.80901694 costab< 325 > = +0.81915194 costab< 326 > = +0.82903767 costab< 327 > = +0.83867061 costab< 328 > = +0.84804809 costab< 329 > = +0.85716724 costab< 330 > = +0.86602533 costab< 331 > = +0.87461978 costab< 332 > = +0.88294762 costab< 333 > = +0.89100653 costab< 334 > = +0.89879400 costab< 335 > = +0.90630770 costab< 336 > = +0.91354555 costab< 337 > = +0.92050487 costab< 338 > = +0.92718387 costab< 339 > = +0.93358040 costab< 340 > = +0.93969256 costab< 341 > = +0.94551861 costab< 342 > = +0.95105654 costab< 343 > = +0.95630473 costab< 344 > = +0.96126163 costab< 345 > = +0.96592587 costab< 346 > = +0.97029579 costab< 347 > = +0.97437006 costab< 348 > = +0.97814757 costab< 349 > = +0.98162717 costab< 350 > = +0.98480779 costab< 351 > = +0.98768836 costab< 352 > = +0.99026805 costab< 353 > = +0.99254614 costab< 354 > = +0.99452186 costab< 355 > = +0.99619472 costab< 356 > = +0.99756408 costab< 357 > = +0.99862951 costab< 358 > = +0.99939084 costab< 359 > = +0.99984771 :(mathsetupend) tan tan = sin(x) / cos(x) :(RETURN) sin sin = cos(x - 90) :(RETURN) cos x = LT(x,0) -x xi = REMDR(CONVERT(x,"INTEGER"),360) x = x - (CONVERT(x,"INTEGER") / 360) * 360.0 xd = x - xi * given points: (-1,Y1) (0,Y2) (1,Y3) * quadratic interpolation point (x,y) is y=a*x**2 + bx + c * where: * a=(y3-2*y2+y1)/2 * b=(y3-y1)/2 * c=y2 * or: * y=x*(x*((y1+y3)/2-y2)+(y3-y1)/2)+y2 y1 = costab y2 = costab y3 = costab x = -1.0 + xd cos = x * (x * ((y1 + y3) / 2 - y2) + (y3 - y1) / 2) + y2 y1 = costab y2 = costab y3 = costab x = xd cos = (cos + (x * (x * ((y1 + y3) / 2 - y2) + (y3 - y1) / 2) + y2)) / 2.0 :(RETURN) arcsin a = 1 arcsinlp LT(x,costab) GE(x,costab) :s(arcsinf) a = a + 1 LT(a,180) :F(FRETURN)S(arcsinlp) arcsinf y1 = costab y2 = costab yd = y2 - y1 xd = x - y1 arcsin = 90.0 - (a + 1 - xd / yd) :(RETURN) SQRT SQRT = x ** 0.5 :(RETURN) MIN MIN = LT(b,MIN) b :(RETURN) MAX MAX = GT(b,MAX) b :(RETURN) ABS ABS = LT(ABS) -ABS :(RETURN) mathsetupend -LIST * program to generate stl file for acoustic lens * this version has round base for midrange driver pi = 3.141592653 * scale factor scale = 1.00 * sizes are in millimeters * main height and hemisphere radius and * hemisphere radius center z point mh = 105.0 hr = 125.00 hrcz = mh - hr * wave's exiting channel width wave = 6.0 * partition thickness pth = 1.0 * center hole radius cr = wave / 4.0 * outer lens radial size or = 95.0 * adjust radial size to proper multiple to * make each concentric layer uniform orn = CONVERT((or - pth - cr) / (pth + wave),'INTEGER') or = pth + cr + orn * (pth + wave) * outer flange radial size ofr = 133.0 * outer flange height ofh = 4.7 * mounting hole center distance from overall center mhc = 124.0 * mounting hole radius mhr = 4.2 * offset to make coordinates not negative (rs * scale) offset = 135.0 * scale * degree granularity d0 = 1.0 dn = 360.0 / d0 dn = CONVERT(dn,'INTEGER') getdlp EQ(REMDR(360 * 64,dn)) :S(gotd) dn = dn + 1 :(getdlp) gotd d = 360.0 / dn * define angle adjust routine DEFINE('aa(a)') * define other drawing routines DEFINE('section(sr1,sa1,sz1,sr2,sa2,sz2,sr3,sa3,sz3,' + 'sr4,sa4,sz4)dn,n,dd,sr14d,sr23d,sz14d,sz23d,' + 'tx3,ty3,tz3,tr3,ta3,tx4,ty4,tz4,tr4,ta4,sx1,' + 'sy1,sx2,sy2') DEFINE('rect(rx1,ry1,rz1,rx2,ry2,rz2,rx3,ry3,rz3,rx4,' + 'ry4,rz4)') DEFINE('facet(fx1,fy1,fz1,fx2,fy2,fz2,fx3,fy3,fz3)Vx,' + 'Vy,Vz,Wx,Wy,Wz,Nx,Ny,Nz,N') * routine to make sure there is at least a zero after a * decimal point in the output for FreeCAD DEFINE('PAD(x)') OUTPUT('print3d',7,,'lens.stl') * first line of STL file: print3d = "solid simplicity" ************************************************************* * make center cylinder first using d degree chunks radius = cr; z = hr + hrcz section(cr,0.0,0.0,cr,0.0,z,cr,360.0,z,cr,360.0,0.0) rad = cr + pth * make top cap for center section(cr,0.0,z,rad,0.0,z,rad,360.0,z,cr,360.0,z) * make bottom cap for center z = 0.0 section(cr,360.0,z,rad,360.0,z,rad,0.0,z,cr,0.0,z) * previous height ph = hr + hrcz * previous radius pr = rad ************************************************************* * now do layers of twisted channels lplayer m = m + 1 * make last layer partition thickness larger NE(m,14) :S(nochng) pth = pth * 2.0 orn = CONVERT((or - pth - cr) / (pth + wave),'INTEGER') or = pth + cr + orn * (pth + wave) radiusAT = radiusA + pth nochng * this radial layer * layer's inner radius radius = pr * layer's outer radius radiusA = radius + wave * layer's outer wall radius radiusAT = radiusA + pth * layer's inner height ih = ph * layer's outer height oh = cos(arcsin(radiusA / hr)) * hr + hrcz * sound's exit height eh = MIN(oh + wave / 2.0,(ih + oh) / 2.0) * sound path desired length spdl = SQRT( ((radius + radiusA) / 2.0) ** 2 + eh * eh) * tilt angle of channel tilt = 90.0 - arcsin(eh / spdl) tiltD = sin(tilt) / cos(tilt) * calculate total horizontal twist angle hta = aa(eh * tiltD * 360.0 / (pi * (radius + radiusA))) * radial separator thickness increases with tilt angle rth = pth / cos(tilt) * tangential separator thickness tth = pth * vertical angle delta vad = d * vertical height delta vd = vad * 2.0 * pi * radius / (360.0 * tiltD) * channel angle span for walls and overall anglei = 360.0 * (wave + rth) / ((radius + radiusA) * + pi * cos(tilt)) angled = CONVERT(anglei,'INTEGER') anglenn = 360 / angled angled = aa(360.0 / anglenn) anglen = CONVERT(360 / angled,"INTEGER") angled = aa(360.0 / anglen) anglet = aa(360.0 * rth / ((radius + radius) * pi)) anglet = d EQ(anglet) :F(noatwarn) noatwarn anglew = angled - anglet * angle remainder to add d by d angler = 360 - anglen * angled * outward top cap all the way around r1 = radiusA; a1 = 0.0; z1 = oh r2 = radiusAT; a2 = 0.0; z2 = oh r3 = radiusAT; a3 = 360.0; z3 = oh r4 = radiusA; a4 = 360.0; z4 = oh * cap: section(r1,a1,z1,r2,a2,z2,r3,a3,z3,r4,a4,z4) * outward bottom cap all the way around r1 = radiusA; a1 = 360.0; z1 = 0.0 r2 = radiusAT; a2 = 360.0; z2 = 0.0 r3 = radiusAT; a3 = 0.0; z3 = 0.0 r4 = radiusA; a4 = 0.0; z4 = 0.0 * cap: section(r1,a1,z1,r2,a2,z2,r3,a3,z3,r4,a4,z4) anglea = 0.0; anglerem = angler channel = 0 * do next concentric layer lparound angle = anglea angledi = angled; anglewi = anglew EQ(anglerem) :S(noangleadjust) angledi = angled + d; anglewi = anglew + d anglerem = anglerem - d noangleadjust channel = channel + 1 za = ih; zb = oh; zc = oh; zd = ih zad = oh - vd; zbd = oh - vd; zcd = oh - vd; zdd = oh - vd n = 0 * radial wall chunk 1 - clockwise side r1 = radius; a1 = angle; z1 = za; r2 = radiusA; a2 = angle; z2 = zb r3 = radiusA; a3 = angle + hta; z3 = 0.0 r4 = radius; a4 = angle + hta; z4 = 0.0 * wall: section(r1,a1,z1,r2,a2,z2,r3,a3,z3,r4,a4,z4) * radial wall chunk 2 - outer wall r1 = radiusA; a1 = angle; z1 = zb r2 = radiusA; a2 = angle + anglewi; z2 = zc r3 = radiusA; a3 = angle + anglewi + hta; z3 = 0.0 r4 = radiusA; a4 = angle + hta; z4 = 0.0 * wall: section(r1,a1,z1,r2,a2,z2,r3,a3,z3,r4,a4,z4) * radial wall chunk 3 - counterclockwise side r1 = radiusA; a1 = angle + anglewi; z1 = zc r2 = radius; a2 = angle + anglewi; z2 = zd r3 = radius; a3 = angle + hta + anglewi; z3 = 0.0 r4 = radiusA; a4 = angle + hta + anglewi; z4 = 0.0 * wall: section(r1,a1,z1,r2,a2,z2,r3,a3,z3,r4,a4,z4) * counterclockwise side bottom cap r1 = radius; a1 = angle + hta + anglewi + anglet; z1 = 0.0 r2 = radiusA; a2 = angle + hta + anglewi + anglet; z2 = 0.0 r3 = radiusA; a3 = angle + hta + anglewi; z3 = 0.0 r4 = radius; a4 = angle + hta + anglewi; z4 = 0.0 * wall: section(r1,a1,z1,r2,a2,z2,r3,a3,z3,r4,a4,z4) * radial wall chunk 4 - inner wall r1 = radius; a1 = angle + anglewi; z1 = zd r2 = radius; a2 = angle; z2 = za r3 = radius; a3 = angle + hta; z3 = 0.0 r4 = radius; a4 = angle + anglewi + hta; z4 = 0.0 * wall: section(r1,a1,z1,r2,a2,z2,r3,a3,z3,r4,a4,z4) * side cap inner part r1 = radius; a1 = angle + anglewi; z1 = zd r2 = radiusA; a2 = angle + anglewi; z2 = zc r3 = radiusA; a3 = angle + angledi; z3 = zc r4 = radius; a4 = angle + angledi; z4 = zd * cap: section(r1,a1,z1,r2,a2,z2,r3,a3,z3,r4,a4,z4) anglea = anglea + angledi GE(anglea,360.0) :F(lparound) * check layer loop pr = radiusAT; ph = oh LT(radiusA,or) :S(lplayer) * make outside main wall radius = pr; r1 = radius; a1 = 0.0 z1 = ph; r2 = radius; a2 = 0.0 z2 = ofh + ofh; r3 = radius; a3 = 360.0 z3 = ofh + ofh; r4 = radius; a4 = 360.0 z4 = ph * Vertical outer wall: section(r1,a1,z1,r2,a2,z2,r3,a3,z3,r4,a4,z4) * make outside main wall fillet radius = pr r1 = radius; a1 = 0.0; z1 = ofh + ofh r2 = radius + ofh; a2 = 0.0; z2 = ofh r3 = radius + ofh; a3 = 360.0; z3 = ofh r4 = radius; a4 = 360.0; z4 = ofh + ofh * Vertical outer wall fillet: section(r1,a1,z1,r2,a2,z2,r3,a3,z3,r4,a4,z4) * inner radius for bottom iradius = radius * radius starting from fillet radius = radius + ofh * make outer flange * outer flange wall: r1 = ofr; a1 = 0.0; z1 = ofh r2 = ofr; a2 = 0.0; z2 = 0.0 r3 = ofr; a3 = 360.0; z3 = 0.0 r4 = ofr; a4 = 360.0; z4 = ofh section(r1,a1,z1,r2,a2,z2,r3,a3,z3,r4,a4,z4) * outer flange top: r1 = radius; a1 = 0.0; z1 = ofh r2 = ofr; a2 = 0.0; z2 = ofh r3 = ofr; a3 = 360.0; z3 = ofh r4 = radius; a4 = 360.0; z4 = ofh section(r1,a1,z1,r2,a2,z2,r3,a3,z3,r4,a4,z4) * outer flange bottom: section(iradius,a4,0.,r3,a3,0.,r2,a2,0.,iradius,a1,0.) * make 8 mounting holes holea = 0.0 holelp mhx = mhc * cos(holea); mhy = mhc * sin(holea) angle = 0.0 * making hole at holea drilllp angled = angle + 5.0 x1 = mhx + mhr * cos(angle); y1 = mhy + mhr * sin(angle); x2 = mhx + mhr * cos(angle); y2 = mhy + mhr * sin(angle); x3 = mhx + mhr * cos(angled); y3 = mhy + mhr * sin(angled); x4 = mhx + mhr * cos(angled); y4 = mhy + mhr * sin(angled); z1 = 0.0; z2 = ofh; z3 = ofh; z4 = 0.0; x5 = mhx; y5 = mhy * Vertical center wall of mounting hole: rect(x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4) * bottom and top of mounting hole facet(x5,y5,z1,x2,y2,z1,x3,y3,z1) facet(x5,y5,z2,x3,y3,z2,x2,y2,z2) angle = angled LT(angled,360.0) :S(drilllp) holea = holea + 45.0 LT(holea,315.0) :S(holelp) * done with mounting holes :(done) * draw curved surface based on polar coordinate corner points * center of curvature is around z axiz at d angle increments * so that all facets match boundaries section dd = d; dd = -d LT(sa4 - sa1) dn = CONVERT(ABS((dd * 0.25 + sa4 - sa1) / d),'INTEGER') sr14d = ABS(d / (sa4 - sa1)) * (sr4 - sr1) sr23d = ABS(d / (sa3 - sa2)) * (sr3 - sr2) sz14d = ABS(d / (sa4 - sa1)) * (sz4 - sz1) sz23d = ABS(d / (sa3 - sa2)) * (sz3 - sz2) n = 0 sectionflp sx1 = sr1 * cos(sa1); sy1 = sr1 * sin(sa1) sx2 = sr2 * cos(sa2); sy2 = sr2 * sin(sa2) EQ(n,dn - 1) :F(sectionnae) tx3 = sr3 * cos(sa3); ty3 = sr3 * sin(sa3); tz3 = sz3 tr3 = sr3; ta3 = sa3 tx4 = sr4 * cos(sa4); ty4 = sr4 * sin(sa4) tz4 = sz4; tr4 = sr4; ta4 = sa4 :(sectionae) sectionnae tx3 = (sr2 + sr23d) * cos(sa2 + dd) ty3 = (sr2 + sr23d) * sin(sa2 + dd) tz3 = sz2 + sz23d; tr3 = sr2 + sr23d ta3 = sa2 + dd tx4 = (sr1 + sr14d) * cos(sa1 + dd) ty4 = (sr1 + sr14d) * sin(sa1 + dd) tz4 = sz1 + sz14d; tr4 = sr1 + sr14d; ta4 = sa1 + dd sectionae EQ(sa1,sa2) :S(sectionrect) EQ(sz2,tz3) :S(sectionrect) section(sr2,sa2,sz2,tr3,ta3,tz3,tr4,ta4,tz4,sr1,sa1,sz1) :(sectionnext) sectionrect rect(sx1,sy1,sz1,sx2,sy2,sz2,tx3,ty3,tz3,tx4,ty4,tz4) sectionnext n = n + 1 LT(n,dn - 1) :F(RETURN) sa1 = sa1 + dd; sa2 = sa2 + dd sz1 = sz1 + sz14d; sz2 = sz2 + sz23d sr1 = sr1 + sr14d; sr2 = sr2 + sr23d :(sectionflp) * draw a rectangle using two triangle facets rect facet(rx1,ry1,rz1,rx2,ry2,rz2,rx3,ry3,rz3) :F(FRETURN) facet(rx1,ry1,rz1,rx3,ry3,rz3,rx4,ry4,rz4) :F(FRETURN) :(RETURN) * draw a triangle facet facet Vx = fx2 - fx1; Vy = fy2 - fy1; Vz = fz2 - fz1 Wx = fx3 - fx2; Wy = fy3 - fy2; Wz = fz3 - fz2 Nx = Vy * Wz - Vz * Wy; Ny = Vz * Wx - Vx * Wz Nz = Vx * Wy - Vy * Wx N = SQRT(Nx * Nx + Ny * Ny + Nz * Nz) Nx = Nx / N; Ny = Ny / N; Nz = Nz / N print3d = "facet normal " PAD(Nx) " " PAD(Ny) " " PAD(Nz) print3d = "outer loop" print3d = "vertex " PAD((fx1 + offset) * scale) ' ' +PAD((fy1 + offset) * scale) ' ' PAD(fz1 * scale) :F(FRETURN) print3d = "vertex " PAD((fx2 + offset) * scale) ' ' +PAD((fy2 + offset) * scale) ' ' PAD(fz2 * scale) :F(FRETURN) print3d = "vertex " PAD((fx3 + offset) * scale) ' ' +PAD((fy3 + offset) * scale) ' ' PAD(fz3 * scale) :F(FRETURN) print3d = "endloop"; print3d = "endfacet" facetcount = facetcount + 1 :(RETURN) * angle adjust : make angle nearest multiple of d aa aa = CONVERT((a + 0.5 * d) / d,'INTEGER') * d :(RETURN) PAD PAD = x + 0.0 * FreeCAD needs to see a trailing zero after a decimal point PAD RPOS(1) "." = ".0" :(RETURN) * last line of STL file: done print3d = "endsolid simplicity" END