1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 22:28:16 +01:00
dotSCAD/examples/platonic_solid_wireframe.scad

41 lines
1.1 KiB
OpenSCAD
Raw Normal View History

2021-10-26 09:33:47 +08:00
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>;
2021-10-26 10:25:49 +08:00
use <experimental/wireframe.scad>;
2021-10-26 09:33:47 +08:00
number_of_faces = 8; // [3, 6, 8, 12, 20]
radius = 10;
deep = 1;
2021-10-26 09:36:26 +08:00
outer_thickness = 1;
inner_thickness = 1;
detail = 0;
2021-10-26 09:33:47 +08:00
2021-10-26 10:29:10 +08:00
platonic_solid_wireframe(number_of_faces, radius, deep, outer_thickness, inner_thickness, detail);
2021-10-26 09:33:47 +08:00
2021-10-26 10:29:10 +08:00
module platonic_solid_wireframe(number_of_faces, radius, deep, outer_thickness, inner_thickness, detail) {
2021-10-26 09:33:47 +08:00
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);
2021-10-26 10:25:49 +08:00
wireframe(
2021-10-26 09:33:47 +08:00
geom[0],
geom[1],
deep,
outer_thickness,
inner_thickness,
[for(p = geom[0]) p / norm(p)]
);
}