Polygons with rounded corners and edges
thingiverse
# How to program Polygons with rounded edges/corners in OpenSCAD ### Some preliminaries: Given a polygon in OpenSCAD [[x1,y1],[x2,y2],....[xn,yn]],it might be an advantage, to "smooth" one or more of its corners. In the following program, you can decide for every corner separately, if it should be rounded and if, at which places on the edges from the chosen corner to the directly foregoing and following corners the smoothed region will change to the linear part of the edge. The corner itself will disappear in the result. With the following functions, you can achieve just this: First of all, you have to define for each point of the polygon, how far away from the point in both directions the bended parts end. You can do this using an extended point definition with the ratios from bent part to total length of both edges connected to the chosen corner. All ratios have to be between 0.0 and 1.0. Replace every term [xi,yi] in the polygon description by another term [li,[xi,yi],ri] where li and ri describe the ratios of the part of the edges before and behind the actual corner which are replaced by the corner bending. Starting with this modified polygon definition, innerPoints will calculate with the help from innerPoint another polygon with the new points on its edges defining the intended endings of the smoothed parts. This is just the beginning. For every point Pi = [xi,yi] you have new points Li left and Ri right from Pi where the local bends end. These three points define a triangle which is the start of the bending process, initially with the function 'smooth' over all triangles in the modified Polygon. You will end in a less and less "angled" sort of polygon, for which you can repeat the last procedure again (and maybe again, but not too often). To this behalf, I added the recursive function reSmooth, which will repeat the smoothing process n times. Unfortunately, this process of producing many triangles starting with less triangle will produce multiple points with identical coordinates. To eliminate the redundant points, you have to use the function reduce. After all, to put it all in one step after the extended polygon definition , you can use the condensed function version polygon(smoothFromRaw(your_extended_definition,count_of_smoothing_repetitions)); For the moment, you should not not use 0 for count_of_smoothing_repetitions! Please use the program v-220521.scad to achieve the described possibilities
With this file you will be able to print Polygons with rounded corners and edges 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 Polygons with rounded corners and edges.