Polytope play made easy by rasarmg 3d model
3dmdb logo
Thingiverse
Polytope play made easy by rasarmg

Polytope play made easy by rasarmg

by Thingiverse
Last crawled date: 3 years ago
Polygons and polyhedrons are the most powerful shapes available in OpenSCAD. However, it can sometimes be a challenge to construct them correctly. Consider this library to help you construct and work with your Polytopes..
Tools
module polytope_number (c, f, e, vi=true, fi=true, ei=true, sp=false, ts, th, to, tr=0)
Label the vertices, paths, and edges of a polytope.
module polytope_frame (c, f, e, vi=true, fi=true, ei=true, vc=1, fc=2, ec=0)
Assemble a polytope skeletal frame using child objects.
module polytope_bbox (c, f, a)
The 3d or 2d bounding box shape for a polytope.
Math Functions
function polytope_faces2edges (f)
List the edge coordinate index pairs of a polytope.
function polytope_limits (c, f, a, d=[0:2], s=true)
Determine the bounding limits of a polytope.
function polytope_bbox_pf (c, f, a)
Generate a bounding box polytope for another polytope in 3d or 2d.
function polytope_line (c, f, e, i, l, r=false)
Get a line from an edge or any two vetices of a polytope.
function polytope_vertex_av (f, i)
List the adjacent vertices for a given polytope vertex.
function polytope_vertex_af (f, i)
List the adjacent face indexes for a polytope vertex.
function polytope_edge_af (f, e, i)
List the adjacent face indexes for a polytope edge.
function polytope_vertex_n (c, f, i)
Get a normal vector for a polytope vertex.
function polytope_edge_n (c, f, e, i)
Get a normal vector for a polytope edge.
function polytope_face_n (c, f, i, l, cw=true)
Get the normal vector of a polytope face.
function polytope_face_m (c, f, i, l)
Get the mean coordinate of all vertices of a polytope face.
function polytope_face_mn (c, f, i, l, cw=true)
Get the mean coordinate and normal vector of a polytope face.
function polytope_plane (c, f, i, l, cw=true)
Get a plane for a polytope face.
function polytope_face_vcounts (f)
List the vertex counts for all polytope faces.
function polytope_face_angles (c, f)
List the angles between all adjacent faces of a polyhedron.
function polytope_edge_lengths (c, e)
List the edge lengths of a polytope.
function polytope_edge_angles (c, f)
List the adjacent edge angles for each polytope vertex.
function polytope_faces_are_regular (c, f, e, d=6)
Test if the faces of a polytope are all regular.
function polytope_triangulate_ft (f)
Triangulate the faces of a convex polytope using fan triangulation.
function polygod2d_perimeter (c, p)
Calculate the perimeter length of a polygon in 2d.
function polygod2d_area (c, p, s=false)
Compute the signed area of a polygon in a Euclidean 2d-space.
function polygod3d_area (c, p, n)
Compute the area of a polygon in a Euclidean 3d-space.
function polygod2d_centroid (c, p)
Compute the center of mass of a polygon in a Euclidean 2d-space.
function polygod2d_is_cw (c, p)
Test the vertex ordering of a polygon in a Euclidean 2d-space.
function polygod2d_is_convex (c, p)
Test the convexity of a polygon in a Euclidean 2d-space.
function polygod2d_winding (c, p, t)
Compute the winding number of a polygon about a point in a Euclidean 2d-space.
function polygod2d_is_pip_wn (c, p, t)
Test if a point is inside a polygon in a Euclidean 2d-space using winding number.
function polygod2d_is_pip_as (c, p, t)
Test if a point is inside a polygon in a Euclidean 2d-space using angle summation.
function polyhedron_area (c, f)
Compute the surface area of a polyhedron in a Euclidean 3d-space.
function polyhedron_volume_tf (c, f)
Compute the volume of a triangulated polyhedron in a Euclidean 3d-space.
function polyhedron_centroid_tf (c, f)
Compute the center of mass of a triangulated polyhedron in a Euclidean 3d-space.
function linear_extrude_pp2pf (c, p, h=1, centroid=false, center=false)
Convert a polygon to a polyhedron by adding a height dimension.
Examples
Numbering
include ;
include ;

tc = dtc_polyhedra_johnson;
tr = dtr_polyhedra_johnson;
id = "metagyrate_diminished_rhombicosidodecahedron";

c = get_table_v(tr, tc, id, "c");
f = get_table_v(tr, tc, id, "f");
v = coordinates_csc(c, 100);

polytope_number(v, f, sp=true);
Framing
include ;
include ;

tc = dtc_polyhedra_cupolas;
tr = dtr_polyhedra_cupolas;
id = "pentagonal_cupola";

c = get_table_v(tr, tc, id, "c");
f = get_table_v(tr, tc, id, "f");

v1 = coordinates_csc(c, 100);
v2 = coordinates_csc(c, 100, true);

grid_repeat(2, 225, center=true)
{
polytope_frame(v1, f) {circle(r=4); color("grey") sphere(r=6);}
polytope_frame(v2, f) {circle(r=4); color("grey") sphere(r=6);}
}
Shapes on edge, vertex, face
include ;
include ;

tc = dtc_polyhedra_archimedean;
tr = dtr_polyhedra_archimedean;
id = "truncated_cuboctahedron";

c = get_table_v(tr, tc, id, "c");
f = get_table_v(tr, tc, id, "f");
v = coordinates_csc(c, 100);

polytope_frame(v, f, fi="even")
{
circle(r=2);
color("grey") sphere(r=4);
color("red") star3d(20);
}

polytope_frame(v, f, fi="odd", fc=0, vc=-1, ec=-1)
color("blue") star3d(20);

polyhedron(v, f);
omdl
This design uses omdl. To render the design, this library must be available. More information is available in omdl on thingiverse.
To install omdl open a BASH shell and type:
$ mkdir tmp && cd tmp
$ wget https://git.io/setup-omdl.bash
$ chmod +x setup-omdl.bash

$ ./setup-omdl.bash --branch v0.6.1 --yes --install

Tags