Controls:
seconds
OpenSCAD Code
Input Params
HTML Form
Output Params
STL Viewer
Rotate:
Draw:
flat
smooth
wireframe
// These are global parameters of the figure. /* [ Low Polygon Vase ] */ // Total height h = 100; // [1:1:200] // Number of layers layers = 20; // [10:1:100] // Number of sides sides = 8; // [3:1:50] // These are parameters to rfunction(), the function that // determines the radius for a particular vertical point. // Different variations on rfunction might use different // parameters. // Basic radius r = 20; // [10:1:50] // Radius varies sinusoidally this much ramplitude = 10; // [10:1:15] // Sine wave has this wavelength rwavelength = 100; // [40:1:200] // Start this many degrees into the sine wave rphase = 0; //[0:1:359] // This is the one parameter to afunction(), the function that // Different variations on afunction might use different // parameters. // Determines the twist at a particular vertical point. twist = 90; //[0:1:359] // Given a vertical index in [0:layers], return the radius // at that point. // This function varies radius by a sine wave. function rfunction(i) = r + ramplitude*sin(rphase + 360*h/rwavelength*i/layers); // Given a vertical index in [0:layers], return the twist // (from zero, not from the previous layer) at that point. function afunction(i) = twist*i/layers; // The rest is pretty independent of the shape, generating // a circle-ish thing with per-layer radius and twist. // Generate the points for a single layer // a - start angle for this layer // r - radius for this layer // z - altitude for this layer function layer(a, r, z) = let(step = 360/sides) [ for (i=[0:sides-1]) let(theta=i*step + a) [ r*cos(theta), r*sin(theta), z ] ]; // Generate all of the points for the object. points = [ for(i=[0:layers]) each layer(afunction(i), rfunction(i), h*i/layers), [0,0,0], // bottom center [0,0,h] // top center ]; // Total number of points in the exterior of the figure, not // counting the bottom and top center points. npoints = (layers+1)*sides; bottomcenter = npoints; topcenter = npoints+1; // Generate the faces faces = [ // The bottom for (j = [0:sides-1]) let(k = (j+1)%sides) [j, k, bottomcenter], // The body for(i=[0:layers-1]) for(j=[0:sides-1]) // k is the index of the next point counterclockwise. let(k = (j+1)%sides) // Build triangles one way or the other, depending on // which way we are twisting in this layer. if (afunction(i) > afunction(i+1)) // Divide quad bottom-left to top-right each [ [i*sides + j, (i+1)*sides + k, i*sides + k], [i*sides + j, (i+1)*sides + j, (i+1)*sides + k] ] else // Divide quad top-left to bottom-right each [ [i*sides + j, (i+1)*sides + j, i*sides + k], [(i+1)*sides + j, (i+1)*sides + k, i*sides + k] ], // The top for (j = [0:sides-1]) let(k = (j+1)%sides) [layers*sides+k, layers*sides+j, npoints+1], ]; polyhedron(points=points, faces=faces, convexity=10);
Console