mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-03-14 02:59:42 +01:00
add platonic_solid_frame
This commit is contained in:
parent
c6b0c30fd8
commit
8dad1bd4b6
40
examples/platonic_solid_frame.scad
Normal file
40
examples/platonic_solid_frame.scad
Normal file
@ -0,0 +1,40 @@
|
||||
use <util/map/hashmap.scad>;
|
||||
use <util/map/hashmap_get.scad>;
|
||||
use <polyhedra/geom_tetrahedron.scad>;
|
||||
use <polyhedra/geom_hexahedron.scad>;
|
||||
use <polyhedra/geom_octahedron.scad>;
|
||||
use <polyhedra/geom_dodecahedron.scad>;
|
||||
use <polyhedra/geom_icosahedron.scad>;
|
||||
use <experimental/polyhedron_frame.scad>;
|
||||
|
||||
number_of_faces = 8; // [3, 6, 8, 12, 20]
|
||||
radius = 10;
|
||||
deep = 1;
|
||||
outer_thickness = .5;
|
||||
inner_thickness = .5;
|
||||
detail = 1;
|
||||
|
||||
platonic_solid_frame(number_of_faces, radius, deep, outer_thickness, inner_thickness, detail);
|
||||
|
||||
module platonic_solid_frame(number_of_faces, radius, deep, outer_thickness, inner_thickness, detail) {
|
||||
polyhedra = hashmap([
|
||||
[3, function(r, d) geom_tetrahedron(r, d)],
|
||||
[6, function(r, d) geom_hexahedron(r, d)],
|
||||
[8, function(r, d) geom_octahedron(r, d)],
|
||||
[12, function(r, d) geom_dodecahedron(r, d)],
|
||||
[20, function(r, d) geom_icosahedron(r, d)],
|
||||
]);
|
||||
|
||||
f_polyhedron = hashmap_get(polyhedra, number_of_faces);
|
||||
|
||||
geom = f_polyhedron(radius, detail);
|
||||
|
||||
polyhedron_frame(
|
||||
geom[0],
|
||||
geom[1],
|
||||
deep,
|
||||
outer_thickness,
|
||||
inner_thickness,
|
||||
[for(p = geom[0]) p / norm(p)]
|
||||
);
|
||||
}
|
@ -2,7 +2,7 @@ use <convex_offset.scad>;
|
||||
use <__comm__/_vertex_normals.scad>;
|
||||
use <util/reverse.scad>;
|
||||
|
||||
module polyhedron_frame(points, faces, deep, outer_thickness, inner_thickness = 0) {
|
||||
module polyhedron_frame(points, faces, deep, outer_thickness, inner_thickness = 0, normals = undef) {
|
||||
function hollow_face(pts, inner_pts) =
|
||||
let(
|
||||
leng = len(pts),
|
||||
@ -87,7 +87,7 @@ module polyhedron_frame(points, faces, deep, outer_thickness, inner_thickness =
|
||||
|
||||
|
||||
leng_faces = len(faces);
|
||||
vx_normals = _vertex_normals(points, faces);
|
||||
vx_normals = is_undef(normals) ? _vertex_normals(points, faces) : normals;
|
||||
inner_pts = [
|
||||
for(i = [0:len(vx_normals) - 1])
|
||||
points[i] - vx_normals[i] * deep
|
||||
|
Loading…
x
Reference in New Issue
Block a user