Three-dimensional shape generation and rendering

Return to the Math APIs page.
creator:  Peter Knipp
repo:  https://github.com/pknipp/polyhedron

Overview: This endpoint enables the user to generate and render a 3-dimensional structure that consists of vertices and edges. The user may also rotate this structure in order to view from any perspective.

Instructions: There are two different ways that the user can create a structure for rendering. The first ("polyhedron") uses the side-side-side method for solving triangles, whereas the second ("stick figure") simply uses Cartesian coordinates. Examples for each may be copy-and-pasted from below.
  1. polyhedron, ie any three dimensional shape consisting of faces that are polygons and edges that are straight line segments. (The easiest polyhedra to generate via this approach are simplicial polyhedron, ie any 3-dimensional shape whose faces are triangular.)
    After ...herokuapp.com above the user should type /edges/<triangle>/<details>, where the <triangle> path fragment describes the shape's foundational triangle, and the <details> path fragment describes each step in expanding this shape, as follows
    • <triangle>:
      This is a six-item comma-separated list that characterizes the first triangular face of the polyhedron. The first three items are vertex names, and the last three are lengths of the edges connecting the 1st and 2nd vertices, the 2nd and 3rd vertices, and the 1st and 3rd vertices respectively.
    • <details> (optional):
      This is a comma-separated list of parenthesis-enclosed lists, each containing either seven, six, or two items, described below.
      • seven:
        This characterizes a tetrahedron that defines a vertex added to the existing polyhedron. The list's first three items specify the names of existing polyhedron vertices (tetrahedron "base"), and the fourth names the vertex added here (tetrahedron "apex"). The last three items are the lengths of the three edges that connect the tetrahedron's base vertices with the apex. Note that there are two such tetrahedra defined by these numbers. The convention here is to take the tetrahedron such that the apex is above the triangle formed by the existing vertices when the existing ones are viewed clockwise.
      • six:
        This increases by one the number of sides of an existing polygonal face. The first three items are the names of three existing non-collinear vertices, and the fourth item is the name of a new vertex which is in the same plane as the former three. The next two items are lengths to the new vertex, the first from the first vertex in the trio of existing ones and the second from the second. (See "pyramid" example below for an instance of this.)
      • two:
        This toggles on or off the rendering of any edge. Each item in this is the name of an existing vertex. (See below either the "pyramid" or "icosahedron" examples for instances of this.)
  2. "stick figure":
    After ...herokuapp.com above the user should type /points/<vertices>/<edges>, where the <vertices> path fragment describes the vertices of the shape, and the <edges> path fragment specifies which pairs of vertices should be connected by a line segment, as follows
    • <vertices>:
      This is a comma-separated list of five-item tuples, each describing a vertex. For each tuple the first item is the vertex's key, the second (optional) item provides a human-readable label to use when rendering, and the last three are the vertex's Cartesian coordinates.
    • <edges>:
      This is a comma-separated list of two-item tuples. Each tuple contains the keys for each pair of vertices that should be connected by line segments.
Notes:
This will only return html (not json), even for the case of errors.
Guidelines for urls:

Examples:
  1. polyhedra:
  2. stick figure: