Mixed in with another discussion, the idea of extruding from a polygon in 3D space was brought up. I thought it was very useful and wondered it it could be done easily with some help from BOSL2. Well, it’s pretty simple. Linear_extrude3d does this rather nicely. The version below just does the simple extrusion, but the other arguments for extrusion can be added easily. A couple more asserts would probably also be appropriate. There’s a little bit of test code too.
It works on any path that describes a (non intersecting) coplanar polygon AFAICT.
include <BOSL2/std.scad>
module linear_extrude3d(path, h) {
d0 = assert(is_coplanar(path),
"Path Is Not Coplanar (from linear_extrude3d)");
r = polygon_normal(path);
c = centroid(path);
move([c.x, c.y, c.z])
rot(from = UP, to = r)
linear_extrude(h)
polygon(
path2d(
apply(rot(from=r, to=UP),
apply(move([-c.x, -c.y, -c.z]), path)
)
)
);
}
path = [[0, 0, 0], [0, 3, 4], [0, 3, 0]];
linear_extrude3d(path, 20);
p0 = apply(move([4, 3, 2]), path);
linear_extrude3d(p0, 20);
p1 = apply(rot(from = RIGHT, to = UP + RIGHT + FRONT), p0);
linear_extrude3d(p1, 20);

-Bob
Tucson AZ