# Parametric hyperbolic worm gear scripts

6 messages
Open this post in threaded view
|

## Parametric hyperbolic worm gear scripts

Open this post in threaded view
|

## Re: Parametric hyperbolic worm gear scripts

Open this post in threaded view
|

## Re: Parametric hyperbolic worm gear scripts

Open this post in threaded view
|

## Re: Parametric hyperbolic worm gear scripts

 Found some more time, so I can further elaborate on the second and third approach.   The second approach I mentioned, "hulling", does not use hull(). It is a union of a series of slices that creates a hull and is best extruded using rotate_extrude(), currently only available in dev snapshots. In the following code I also skewed it a bit using a trial and error value in favor of a smoother slope approximation. F6-Rendering took 16 minutes and produced a valid result. use z=40; step = 6; skew_val = -0.06; skewZ = [ [ 1  , 0  , 0  , 0   ],       [ 0  , 1  , 0, 0   ],  // skew value; pushed along the y axis       [ 0  , skew_val  , 1  , 0   ],       [ 0  , 0  , 0  , 1   ] ] ; for(dw=[0:step:359]) {   rotate([0, 0, dw])   multmatrix(skewZ)             // skew transformation   rotate_extrude(angle = step+.001) // little overlapping to avoid CGAL problems   rotate([0, 0, 90])     difference()     {       translate([0, -12])       square([100, 20], center = true);       translate([0, -55])       rotate([0, 0, dw/z])       gear2D(m=2, z=z);     } } The third approach can also done with my lib code, but is a little more tricky, as it involves a trival export/import loop with OpenSCAD and an editor (or an external script). First we render our gear in 2D use // https://www.thingiverse.com/thing:636119 gear2D(m=2, z=40); and save it in SVG format (dev snapshot required). The SVG can be easily converted into a scad file using an editor. 1. delete the first 5 lines 2. replace "M" -> "mygear = [[" in first line 3. delete the last 2 lines 4. replace "z" -> "]];" in last line 5. search and replace all "L" -> "],[" 6. save as .scad file e.g. as mygear.scad Now you have an affine definition of the gear, which can be easily included into OpenSCAD and used to compose the trajectory data consumed by sweep(). See the following code which uses another library of mine defining a sweep() module and a bunch of valuable affine transformations - like Tx_ and Rz_ - for translation and rotation along/around an axis. While it can have some ugly F5-result, F6 workes well (with valid result). F6-Rendering took 2.5 minutes on my machine with most of the time consumed by the two Boolean operations. Note that I used a different radius and cylinder but the same gear as before.   use // https://www.thingiverse.com/thing:900137include // converted SVG, defines the variable mygear z = 40; Half1 = [for(i = [0:6:180]) Rz_(-i, Rx_(90, Tx_(50, Rz_(i/z, vec3D(mygear)))))]; Half2 = [for(i = [180:6:360]) Rz_(-i, Rx_(90, Tx_(50, Rz_(i/z, vec3D(mygear)))))]; difference() {   cylinder(r = 15, h= 100, center = true);   sweep(Half1);     sweep(Half2);   } -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org