![Inflate triangular mesh library for OpenSCAD](https://3dcrawler.ams3.digitaloceanspaces.com/thingiverse/4416566-Inflate-triangular-mesh-library-for-OpenSCAD-4014987563.png)
Inflate triangular mesh library for OpenSCAD
Description
This library lets you inflate 2D polygons into the third dimension, e.g., making them be thin around the edges and fat in the middle (as well as more complex effects). For instance, you can take a square and inflate it to look like a pillow. You need my [eval library](https://www.thingiverse.com/thing:2295309) as well. Usage is a bit complicated. * Your initial polygon needs to be triangulated: you can use my [triangulation library](https://www.thingiverse.com/thing:4413843) to triangulate it and then refine the triangulated mesh for the resolution you require. * Then you specify a function for the bottom of the inflated polygon and another for the top. These functions can depend on three variables: x, y and d, where [x,y] are the coordinates in the mesh and d is the distance from the mesh edge. The functions are passed as strings to the inflation, e.g., ("3*pow(d,0.5)"), using the variant subset of the OpenSCAD formula language supported by my eval library. The main module is: ``` inflateMesh(points=myPoints,triangles=myTriangles,top=myTopFunction,bottom=myBottomFunction); ``` You can also put `pointsAndFaces=[myPoints,myTriangles]`, which is handy for use with my triangulation library. For instance, suppose you want to make a pillow-like shape. Then do this: ``` use <triangulation.scad>; use <inflate.scad>; sq = [ [0,0], [20,0], [20,20], [0,20] ]; // a square triangulated = triangulate(sq); // triangulate it (easy enough to do manually, though!) refined = refineMesh(sq, triangulated, maxEdge=1); // refine the mesh so no edge exceeds length 1 inflateMesh(pointsAndFaces=refined,top="2+4*d^0.25",bottom="-2*d^0.25"); ``` And here is a very simple way to do an inflated heart with a flat base: ``` use <Bezier.scad>; use <triangulation.scad>; use <inflate.scad>; heart = Bezier([[0,0],POLAR(10,60),POLAR(10,-90),[20,35],SYMMETRIC(),POLAR(15,90),[0,30],REPEAT_MIRRORED([1,0])]); inflateMesh(refineMesh(heart,triangulate(heart),maxEdge=2),top="min(4,3*d^0.25)"); ``` This uses my [Bezier library](https://www.thingiverse.com/thing:2207518). You can also use Bezier splines for the profiles, by using the `interpolate()` function in my eval library, and the optional `params` parameter for `inflateMesh()` which lets you set values for additional variables besides x, y and d: ``` use <triangulation.scad>; use <inflate.scad>; use <Bezier.scad>; sq = [ [0,0], [20,0], [20,20], [0,20] ]; triangulated = triangulate(sq); refined = refineMesh(sq, triangulated, maxEdge=1.5); topProfile=Bezier([[0,0],POLAR(5,90),POLAR(5,180),[8,8],LINE(),LINE(),[8,8]]); inflateMesh(refined,top="interpolate(d,topProfile)",bottom="-2*d^0.25",params=[["topProfile",topProfile]]); ``` Finally, there is an `inflateMesh()` function which works just like the module but returns a `[points,faces]` pair that you can feed into `polyhedron()`. This is useful if you want to post-process the polyhedron instead of just drawing it. For an example, see wrapheart.scad.
Statistics
Likes
4
Downloads
0