*“Revolve2:**Better stability, clarity and added functionalities.**If you liked Revolve, you will love Revolve2!*

*Introduction**This OpenSCAD module allows for rotational extrusion of generic user-defined profiles,**introducing a pitch in the longitudinal direction, the most common application being**the creation of screws.**The solid is built as a single polyhedron by transforming the 2D points found in the**profile vector. No boolean operation is necessary, aiming at obtaining the ultimate**performance by producing the simplest possible object for the desired level of detail.*

*Arguments**revolve(profile = [[]], length, nthreads=1, scale=1,**preserve_thread_depth=false, preserve_thread_shape=false,**$fn=$fn, force_alternate_construction=false)**profile vector of 2D points defined as: [[z_1, f(z_1)], [z_2, f(z_2)] … [z_n,f(z_n)]].**f(z) is defined over a closed interval (including the extremes) representing one period of the thread; it describes the shape of the thread with no fundamental restriction, that means that a square profile can be defined exactly, with points sharing the same $z$. Dovetail-like profiles are also possible.**The shape of the profile can be made finer by adding more points. The linspace helper function might be used to create the profile from a mathematical function (see example below).**length how far to go in the longitudinal direction, note that the mesh size increases linearly with this parameter.**nthreads allows the creation of screws with multiple threads, it should be an integer. Negative values are also accepted, generating left threads. nthreads=0 results in no pitch, similar to rotate_extrude.**scale enable scaling in the longitudinal direction: the top faces will be scale-times larger than the bottom one. Similar to scale in linear_extrude, however this only accepts a scalar value in the interval ]0, +inf[.**preserve_thread_depth allows preserving the depth of the thread which otherwise may be “flattened”. Only useful if scale!=1.**preserve_thread_shape allows preserving the shape of the thread. When true, it overrides preserve_thread_depth. Only useful if scale!=1.**$fn: the number of subdivisions in the angular direction, similar to $fn for a cylinder. In the longitudinal direction the number of subdivisions is controlled directly by the number of points in the profile. Note that if this parameter is too small, it might be necessary to cut the thread faces, this will be accomplished by triggering the alternate construction.**force_alternate_construction The alternate construction allows for properly cutting the top and bottom faces when these intercept the thread. This is typically needed when the number of angular steps is small and/or the number of threads is large and/or depending on the thread profile. The switch to the alternate construction is handled automatically (an info message is echoed when this happens). If you know that your design will need the alternate construction, you may force it here making the code slightly faster.**Example**// The simplest possible example:**revolve(profile=[[0,5],[1,6],[2,5]], length=10, nthreads=1, $fn=8);*

*// Now going a bit wilder**// Define a sinusoidal profile function…**period = 3;**function prof_sin(z) = [z, 10+sin(z*360/period)];**// …which becomes a profile vector with the help of linspace**sin_prof = [for (z=linspace(start=0, stop=period, n=15)) prof_sin(z)];**translate([30,0,0])revolve( sin_prof, length=20, nthreads=-5, $fn=30);*

*// Using the scale functionality**// A square profile defined manually**sqr_prof = [[0,11],[2,11],[2,9],[4,9],[4,11]];**intersection() {**translate([-20,10,-10]) cube([20,100,50]);**union () {**color(“red”) translate([0,30])**revolve( sqr_prof, length=30, scale=0.2, nthreads=-1, $fn=30);**color(“blue”) translate([0,60])**revolve( sqr_prof, length=30, scale=0.2, preserve_thread_depth=true, nthreads=-1, $fn=30);**color(“green”) translate([0,90])**revolve( sqr_prof, length=30, scale=0.2, preserve_thread_shape=true, nthreads=-1, $fn=30);**}**}*

*// To reproduce the sample STL:**// revolve_demo_scene();”*