OpenScad Helix Library

OpenScad Helix Library

Description

Yet another helix library (that nobody asked for). I wrote this library because I was learning OpenScad while working on a project that required a helix, and after doing a half-hearted search finding a half dozen libraries, I decided to write my own as an exercise. I added every feature that I thought I would ever want in a helix library and this is the result. Included is a file that contains a number of examples: * Spice Jar Cap - showing how an inside thread can be created by subtracting a helix from another solid shape * Drywall Screw - shows that a thread can be wrapped around a core with a non-constant radius * Pipe Bushing - another example showing a non-constant radius and an inside thread * Auger - an example showing the use of skew_compensation mode (see below) to thicken a profile when the pitch is high * Twist on a Sphere - Just an interesting shape that can be made by specifying each slice's scale, radius and height * Marble Lift - An example that shows use of a negative threads, fill_core true/false, and rotate_profile mode (see below) * Several other examples showing the differences of the default mode, shear_compensation and rotate_profile modes (see below). Below are a list of features; for more complete usage documentation, refer to the comments in the code and example file. * Specify the helix profile as a set of 2D points * Specify the whole number of profile slices per rotation (fn) * Specify the helix rotation (will be truncated to a whole number of slices) * Draw a helix with or without filling in the central core * Three ways to handle skewing the profile * Keep the profile vertical, make copies and skin them around the helix (default) * Scale the profile linearly to compensate for thinning of the threads due to shearing - In this mode, the profile will also be rotated to align with any changes in the helix core's radius from one revolution to the next (see non-constant radius below) * Rotate the profile at each slice, similar to extruding the profile along a path around a central core - In the case that the core is filled, the profile slices are kept vertical; an iterative algorithm is used non-linearly transform the profile points in a way that closely approximates the shape of the helix when there is no core. * Leading and/or trailing tapers for the profile * Scale profile slices in the X and/or Y direction * Support to scale the profile down to 0 in X and/or Y direction and (usually) provide a valid manifold * Constant or non-constant core radius * Specify an r1 and r2 similar to the built-in cylinder function * Specify r1 and a taper angle * Specify a leading and/or trailing taper for the radius * Specify a radius for every profile slice * Constant or variable pitch * Specify a fixed pitch for the entire helix * Support for non-constant pitch by specifying the height of each helix slice * When the core is filled, extend a cylinder beyond the top and/or the bottom of the helix * Support for handling helix layers that touch if the center is filled - the code will detect this condition and avoid drawing zero-area surfaces. * Two main functional interfaces * A wrapper function that provides several methods for specifying lead-in and lead-out tapers or variable radii as described above * The core function which requires specification of the X & Y scale factor, height and radius of every profile slice * A single call to helix or helix_core produces a single polyhedron * This is very fast, although a little slower in the case that the center is filled and the profile is virtually rotated due to heavy calculations that are made * Although the code handles many corner cases, it is possible to provide inputs that will result in a non-manifold polyhedron. e.g. helix layers that overlap or helix slices that bend into each other. * When creating a helix with a filled center, each slice segment is on the same vertical plane that intersects the Z axis. This ensures clean skinning between helix layers. Some useful helper functions are in the library: * transition_heights - provide a list of heights with a gradually changing pitch which provides a smooth transitions * <shape\>_taper - functions that provide a list of values used to define shaped start/end tapers * linear_taper - linear taper that has a sharp hip at both ends * sin_taper - sinusoidal taper that has a hip at the start (0) and a smooth transition at the end (1) * s_taper - sin^2 taper that has smooth transitions at the start (0) and end (1) * eliptic_taper - taper that is perpendicular at the start (0) and has a smooth transition at the end (1) * ones - a list of 1's * concat_elements - take 2 lists of length N to make an array that is N x 2. This can be useful to create an array of scale factors that specify a different scaling shape in the X and Y directions * dup_elements - take a list of length N and make an array that is N x 2, using the same value for each pair. This can be useful to create an array of scale factors that are the same in X and Y from a single list. * reverse - reverse a list; useful for taking the output of a taper function and reversing it for use at the end of a list of scale factors, heights or radii.

Statistics

Likes

2

Downloads

0

Category

Other