mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-01-16 21:58:27 +01:00
Added vnf_wireframe, tweaked reverse error message,
This commit is contained in:
parent
de7f8569bf
commit
f2bb9bcb4b
@ -290,7 +290,7 @@ function list_range(n=undef, s=0, e=undef, step=undef) =
|
||||
// Example:
|
||||
// reverse([3,4,5,6]); // Returns [6,5,4,3]
|
||||
function reverse(x) =
|
||||
assert(is_list(x)||is_string(x), "Input to reverse must be a list or string")
|
||||
assert(is_list(x)||is_string(x), str("Input to reverse must be a list or string. Got: ",x))
|
||||
let (elems = [ for (i = [len(x)-1 : -1 : 0]) x[i] ])
|
||||
is_string(x)? str_join(elems) : elems;
|
||||
|
||||
|
27
vnf.scad
27
vnf.scad
@ -357,6 +357,33 @@ module vnf_polyhedron(vnf, convexity=2, extent=true, cp=[0,0,0], anchor="origin"
|
||||
|
||||
|
||||
|
||||
// Module: vnf_wireframe()
|
||||
// Usage:
|
||||
// vnf_wireframe(vnf, [r|d]);
|
||||
// Description:
|
||||
// Given a VNF, creates a wire frame ball-and-stick model of the polyhedron with a cylinder for each edge and a sphere at each vertex.
|
||||
// Arguments:
|
||||
// vnf = A vnf structure
|
||||
// r|d = radius or diameter of the cylinders forming the wire frame. Default: r=1
|
||||
// Example:
|
||||
// $fn=32;
|
||||
// ball = sphere(r=20, $fn=6);
|
||||
// vnf_wireframe(ball,d=1);
|
||||
// Example:
|
||||
// include<BOSL2/polyhedra.scad>
|
||||
// $fn=32;
|
||||
// cube_oct = regular_polyhedron_info("vnf", name="cuboctahedron", or=20);
|
||||
// vnf_wireframe(cube_oct);
|
||||
module vnf_wireframe(vnf, r, d)
|
||||
{
|
||||
r = get_radius(r=r,d=d,dflt=1);
|
||||
vertex = vnf[0];
|
||||
edges = unique([for (face=vnf[1], i=idx(face))
|
||||
sort([face[i], select(face,i+1)])
|
||||
]);
|
||||
for (e=edges) extrude_from_to(vertex[e[0]],vertex[e[1]]) circle(r=r);
|
||||
move_copies(vertex) sphere(r=r);
|
||||
}
|
||||
|
||||
|
||||
// Function: vnf_volume()
|
||||
|
Loading…
x
Reference in New Issue
Block a user