polyhedron-ops 0.1.3

Conway/Hart Polyhedron Operations
Documentation

Polyhedron Operators

This crate implements the Conway Polyhedron Operators and their extensions by George W. Hart and others.

Some brutalist Polyhedron, rendered with 3Delight|ɴsɪ

Some brutalist polyhedron; rendered with 3Delight|ɴsɪ and post processed in Darktable.

This is an experiment to improve my understanding of iterators in Rust. It is based on Kit Wallace’s OpenSCAD code. As OpenSCAD Language is functional it lends itself well to translation into functional Rust.

use polyhedron_ops::Polyhedron;
use std::path::Path;

// Conway notation: gapcD
let mut polyhedron =
    Polyhedron::dodecahedron()
        .chamfer(None, true)
        .propellor(None, true)
        .ambo(None, true)
        .gyro(None, None, true)
        .finalize();
// Export as ./polyhedron-gapcD.obj
polyhedron.export_as_obj(&Path::new("."), false);

The above code starts from a dodecahedron and iteratively applies four operators.

The resulting shape is shown below.

Caveat

This is in a rough shape. Probably buggy. Documentation sucks.

In short: use at your own risk.

Cargo Features

  • nsi – Adds support for sending a polyhedron to an offline renderer via the ɴsɪ crate.

Base Shapes

  • Platonic solids
  • Prisms
  • Antiprisms

Supported Operators

  • a - ambo
  • b - bevel (equiv. to ta)
  • c - chamfer
  • d - dual
  • e - expand (a.k.a. explode, equiv. to aa)
  • g - gyro
  • j - join (equiv. to dad)
  • M - medial (equiv. to dta)
  • m - meta (equiv. to k,,3j)
  • o - ortho (equiv. to jj)
  • p - propellor
  • k - kis
  • q - quinto
  • r - reflect
  • s - snub (equiv. to dgd)
  • t - truncate vertices (equiv. to dkNd)
  • w - whirl
  • z - zip (equiv. to dk)

Other Operators (TBD)

  • i - inset/loft
  • h - hexpropellor
  • l - stellate
  • x - extrude
  • z - triangulate
  • H - hollow (called ’intrude‘ in Wings3D)

Playing

There is a playground example app to test things & have fun:

cargo run --release --example playground"

If you want to produce images like the one above you need to download the free version of the 3Delight renderer and install that. After that, run the example with ɴsɪ support:

cargo run --release --example playground --features="nsi"

Keyboard Commands

Use keys matching the operator name from the above list to apply.

Use Up and Down to adjust the parameter of the the last operator. Combine with Shift for 10× the change.

Delete undoes the last (and only the last) operation.

Press Enter to render with 3Delight (requires a 3Delight|ɴsɪ installation). Combine with Shift to render with 3Delight Cloud (requires registration).

Press Space to save as $HOME/polyhedron-<type>.obj.

I use kiss3d for realtime preview which is close to the metal enough to limit meshes to 64k vertices. This means the preview will be broken if your mesh hits this limit.

The app may crash though if your graphics driver doesn't handle such ill-defined meshes gracefully. :)

Export & render will always yield a correct OBJ though. Which you can view in Wings, Blender or another DCC app.