mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Added octahedron(), fixed bug in VNF extent anchoring.
This commit is contained in:
parent
3cf00d8fd7
commit
cbab1b9a61
3 changed files with 44 additions and 14 deletions
|
@ -1649,10 +1649,8 @@ function _find_anchor(anchor, geom) =
|
|||
rpts = apply(rot(from=anchor, to=RIGHT) * move(point3d(-cp)), vnf[0]),
|
||||
maxx = max(columns(rpts,0)),
|
||||
idxs = [for (i = idx(rpts)) if (approx(rpts[i].x, maxx)) i],
|
||||
mm = pointlist_bounds(select(rpts,idxs)),
|
||||
avgy = (mm[0].y+mm[1].y)/2,
|
||||
avgz = (mm[0].z+mm[1].z)/2,
|
||||
mpt = approx(point2d(anchor),[0,0])? [maxx,0,0] : [maxx, avgy, avgz],
|
||||
avep = sum(select(rpts,idxs))/len(idxs),
|
||||
mpt = approx(point2d(anchor),[0,0])? [maxx,0,0] : avep,
|
||||
pos = point3d(cp) + rot(from=RIGHT, to=anchor, p=mpt)
|
||||
) [anchor, pos, anchor, oang]
|
||||
) : type == "rect"? ( //size, size2, shift
|
||||
|
|
14
masks.scad
14
masks.scad
|
@ -70,17 +70,11 @@ module chamfer_edge_mask(l=1, chamfer=1, excess=0.1, anchor=CENTER, spin=0, orie
|
|||
// corner_mask(TOP+FWD+RIGHT)
|
||||
// chamfer_corner_mask(chamfer=20);
|
||||
// }
|
||||
// Example: Anchors
|
||||
// chamfer_corner_mask(chamfer=20)
|
||||
// show_anchors();
|
||||
module chamfer_corner_mask(chamfer=1, anchor=CENTER, spin=0, orient=UP) {
|
||||
pts = 2 * chamfer * [
|
||||
[0,0,1], [1,0,0], [0,1,0], [-1,0,0], [0,-1,0], [0,0,-1]
|
||||
];
|
||||
faces = [
|
||||
[0,2,1], [0,3,2], [0,4,3], [0,1,4], [5,1,2], [5,2,3], [5,3,4], [5,4,1]
|
||||
];
|
||||
attachable(anchor,spin,orient, size=[4,4,4]*chamfer) {
|
||||
polyhedron(pts, faces, convexity=2);
|
||||
children();
|
||||
}
|
||||
octahedron(chamfer*4, anchor=anchor, spin=spin, orient=orient) children();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -641,6 +641,44 @@ function prismoid(
|
|||
) reorient(anchor,spin,orient, size=[s1.x,s1.y,h], size2=s2, shift=shift, p=vnf);
|
||||
|
||||
|
||||
// Function&Module: octahedron()
|
||||
// Usage: As Module
|
||||
// octahedron(size, ...);
|
||||
// Usage: With Attachments
|
||||
// octahedron(size, ...) { attachments }
|
||||
// Usage: As Function
|
||||
// vnf = octahedron(size, ...);
|
||||
// Description:
|
||||
// When called as a module, creates an octahedron with axis-aligned points.
|
||||
// When called as a function, creates a [[VNF|vnf.scad]] of an octahedron with axis-aligned points.
|
||||
// Arguments:
|
||||
// size = Width of the octahedron, tip to tip.
|
||||
// ---
|
||||
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#anchor). Default: `CENTER`
|
||||
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#spin). Default: `0`
|
||||
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#orient). Default: `UP`
|
||||
// Example:
|
||||
// octahedron(size=40);
|
||||
// Example: Anchors
|
||||
// octahedron(size=40) show_anchors();
|
||||
module octahedron(size=1, anchor=CENTER, spin=0, orient=UP) {
|
||||
vnf = octahedron(size=size);
|
||||
attachable(anchor,spin,orient, vnf=vnf, extent=true) {
|
||||
vnf_polyhedron(vnf, convexity=2);
|
||||
children();
|
||||
}
|
||||
}
|
||||
|
||||
function octahedron(size=1, anchor=CENTER, spin=0, orient=UP) =
|
||||
let(
|
||||
s = size / 2,
|
||||
vnf = [
|
||||
[ [0,0,s], [s,0,0], [0,s,0], [-s,0,0], [0,-s,0], [0,0,-s] ],
|
||||
[ [0,2,1], [0,3,2], [0,4,3], [0,1,4], [5,1,2], [5,2,3], [5,3,4], [5,4,1] ]
|
||||
]
|
||||
) reorient(anchor,spin,orient, vnf=vnf, extent=true, p=vnf);
|
||||
|
||||
|
||||
// Module: rect_tube()
|
||||
// Usage: Typical Rectangular Tubes
|
||||
// rect_tube(h, size, isize, [center], [shift]);
|
||||
|
|
Loading…
Reference in a new issue