[OpenSCAD] User Poll: What do you want to see from OpenSCAD development?

Jordan Brown openscad at jordan.maileater.net
Fri Nov 22 20:07:36 EST 2019


On 11/22/2019 12:14 PM, nop head wrote:
> I use this:  https://github.com/nophead/NopSCADlib#Clip Not quite what
> you want but it can clip against any plane perpendicular to one of the
> axes.

Sure.  Like I said, easy enough, but you have to decide how big the cube
should be, and that's annoying.

BTW, why the polyhedron rather than a cube?  It sure seems like a
translated cube would be simpler.

Here's the one I wrote some time back:

// @brief Clip children against a specified plane
// @param o          point on the plane
// @param v          normal vector; retain only this direction
// @param <children> objects to clip
// @note
// Limited to 200x200x200 cube.
module clip(o=[0,0,0],v=[0,0,1]) {
    sz = 200;
    r = norm(v);
    intersection() {
        children();
        translate(o)
            rotate([0, 0, atan2(v[1], v[0])])
            rotate([0, acos(v[2]/r), 0])
            jcube([sz, sz, sz], centerx=true, centery=true);
    }
}

jcube is a cube that you can center on the three axes independently. 
Even that usage is legacy in this project; my current standard would be
jcube([sz,sz,sz], justify=[0,0,1]), which expands to
justify(justify=[0,0,1], dims=[sz,sz,sz]) cube([sz,sz,sz]).  I don't
immediately remember why jcube doesn't support a single size argument. 
Details of those left as an exercise for the reader.

(I wrote that a long time ago, and I never used the rotate capabilities
much if at all, and I haven't checked the trig today.  If I got it
wrong, please let me know and I'll be suitably embarrassed.)


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20191123/6807aff1/attachment.html>


More information about the Discuss mailing list