User Tools

Rectangular Extrude

Extrude the path by following it with a rectangle (upright, perpendicular to the path direction), returns a CSG solid.

Simplified (openscad like, even though OpenSCAD doesn't provide this) via rectangular_extrude(), where as

  • w: width (default: 1),
  • h: height (default: 1),
  • fn: resolution (default: 8), and
  • closed: whether path is closed or not (default: false)
rectangular_extrude([ [10,10], [-10,10], [-20,0], [-10,-10], [10,-10] ],  // path is an array of 2d coords
    {w: 1, h: 3, closed: true});

or more low-level via rectangularExtrude(), with following unnamed variables:

  • width of the extrusion, in the z=0 plane
  • height of the extrusion in the z direction
  • resolution, number of segments per 360 degrees for the curve in a corner
  • roundEnds: if true, the ends of the polygon will be rounded, otherwise they will be flat
// first creating a 2D path, and then extrude it
var path = new CSG.Path2D([ [10,10], [-10,10], [-20,0], [-10,-10], [10,-10] ], /*closed=*/true);
var csg = path.rectangularExtrude(3, 4, 16, true);   // w, h, resolution, roundEnds
return csg;