Plot Function library for OpenSCAD, with Cartesian, Polar, and Axial coordinates

Plot Function library for OpenSCAD, with Cartesian, Polar, and Axial coordinates

thingiverse

This is a general purpose function plotting library for OpenSCAD which will render functions with Cartesian coordinates (x & y input, z output), polar/cylindrical coordinates (r & angle input, z output), or axial coordinates (z & angle input, r output). This library is sufficiently flexible that it can be used for more than just plotting functions. As demonstrated in the included demo files, this can efficiently render ordinary objects with surfaces defined by mathematical functions. While there are a few other function plotting libraries out there for OpenSCAD, this one is particularly robust, fast, and flexible. It uses list comprehension to generate each plot as a single polyhedron, supports multiple user-defined functions of each type in one design, consistently creates properly manifold renders, and executes as quickly as any other rendered object of comparable size. Since OpenSCAD does not support passing functions as parameters, this library resolves it by allowing the user to declare functions Func1, Func2, etc, PolarFunc1, PolarFunc2, etc, and AxialFunc1, AxialFunc2, etc. Then the number 1, 2, etc is passed to the corresponding plot routine. For example, the following code will create a Cartesian coordinate plot of the following function #1 over the domain -40 through 40 in both x and y with a step size of 0.4: ~~~ include <plot_function.scad> function Func1(x, y) = 2*(1.5 + cos(x*x + y*y/4)); PlotFunction(1, [-40, 0.4, 40], [-40, 0.4, 40]); ~~~ The module call PlotFunction can occur anywhere a normal polyhedron could be generated, but the function definition Func1 must be declared at the top-level of the code so that it can be accessed from within the included plotting library. Note that it must "include" plot_function.scad rather than "use" it so that Func1 and others are accessible. A variety of usage demonstrations are in the demo_plot_function.scad file, and the API for the three plotting modules is as follows: ~~~ // Plots the numbered function Func1 through Func9, where FuncN is 1 through 9. // Each function is a function of x and y. // minx_stepx_maxx should be [minx, stepx, maxx], and likewise for y, // specifying the domain to be plotted. // To guarantee a properly manifold shape, the routine will only render // strictly positive values (z>0) of the defined function. Add an offset if // needed to achieve this. module PlotFunction(FuncN, minx_stepx_maxx, miny_stepy_maxy) // Plots the numbered function PolarFunc1 through PolarFunc9, where // PolarFuncN is 1 through 9. Each function is a function of radius and // angle. // max_r is the outer radius, and min_step is the smallest step size between // points. // To guarantee a properly manifold shape, the routine will only render // strictly positive values (z>0) of the defined function. Add an offset if // needed to achieve this. module PlotPolarFunction(PolarFuncN, max_r, min_step=-1) // Plots the numbered function AxialFunc1 through AxialFunc9, where // AxialFuncN is 1 through 9. Each function is a function of z-height and // angle, and returns the radius outward in the xy-plane. // max_r is the outer radius, and min_step is the smallest step size between // points. // minz_stepz_maxz should be [minz, stepz, maxz], and likewise for y, // specifying the domain to be plotted. // To guarantee a properly manifold shape, the routine will only render // strictly positive values (r>0) of the defined function. Add an offset if // needed to achieve this. module PlotAxialFunction(AxialFuncN, minz_stepz_maxz, num_circle_steps=360) ~~~

Download Model from thingiverse

With this file you will be able to print Plot Function library for OpenSCAD, with Cartesian, Polar, and Axial coordinates with your 3D printer. Click on the button and save the file on your computer to work, edit or customize your design. You can also find more 3D designs for printers on Plot Function library for OpenSCAD, with Cartesian, Polar, and Axial coordinates.