2D Graphing Library
Description
NOTE: Without this[1] bug fix, this library functions VERY poorly (openscad crashes a lot) so I suggest getting the latest openscad source and compiling that if you want to try this library.
Maybe if I can wrap my head around polyhedrons in openscad I will extend this to 3d functions. :)
[1] github.com/openscad/openscad/commit/f0bd1eed9746e0349700c969292c9eeca58 c5635
Instructions
function f(x) = ... // for a cartesian equation
function r(theta) = ... // for a polar equation
function x(t) = ... // and
function y(t) = ... // for a parametric equation
//then
// param (optional) [lower bound, upper bound]
// param (optional) thickness of the line, without thickness it would be 1d!
// param (optional) number of polygons to draw (resolution)
// param (optional) polar=true or parametric=true, defaults to cartesian
2dgraph([-10, 10], 2, $fn=100);
You must be logged in to post a comment.
Some comments on your code itself:
If you use the '//' method of commenting, instead of the '/*' style, it's easier to uncomment the individual functions by simply doing Ctl-D/Shift-Ctl-D
You might want to introduce 'steps' instead of using $fn to represent the number of steps. $fn will have other side effects that you probably are not intending, particularly with surfaces of revolution. For example:
module 2dgraph(bounds = [-10,10], th=2, polar=false, parametric=false, steps=24
)
{
// and if you must
$fn=24;
.
.
.
}
But, I would not even use the $fn=24 inside the module. As it is a global thing, you can always apply it from the outside.
I really like the simplicity and modularity. If we had 'function pointers', it would be even more modular.
I really like this!
If you want to go for 3D, you might take a look at this library: http://www.thingiverse.com/thi... for solids of revolution
or this one: http://www.thingiverse.com/thi...
which deals with mesh surfaces in general.
There are two things you have to deal with for polyhedra. 1) surface normals. You must know these so you can calculate a thickness. 2) boundaries. You must know these so you can create closed polyhed
ra in bits and pieces.
License

Thanks for making this - I just used it for a picture frame project that includes Lissajous Curves.
http://www.thingiverse.com/thi...