| Andrew Cooke | Contents | Latest | RSS | Twitter | Previous | Next


Welcome to my blog, which was once a mailing list of the same name and is still generated by mail. Please reply via the "comment" links.

Always interested in offers/projects/new ideas. Eclectic experience in fields like: numerical computing; Python web; Java enterprise; functional languages; GPGPU; SQL databases; etc. Based in Santiago, Chile; telecommute worldwide. CV; email.

Personal Projects

Lepl parser for Python.

Colorless Green.

Photography around Santiago.

SVG experiment.

Professional Portfolio

Calibration of seismometers.

Data access via web services.

Cache rewrite.

Extending OpenSSH.

Last 100 entries

Brandalism; Table of Shifter, Cassette and Derailleur Compatability; Lenovo Demonstrates How Bad HTTPS Is; Telegraph Owned by HSBC; Smaptop - Sunrise (Music); Equation Group (NSA); UK Torture in NI; And - A Natural Extension To Regexps; This Is The Future Of Religion; The Shazam (Music Matching) Algorithm; Tributes To Lesbian Community From AIDS Survivors; Nice Rust Summary; List of Good Fiction Books; Constructing JSON From Postgres (Part 2); Constructing JSON From Postgres (Part 1); Postgres in Docker; Why Poor Places Are More Diverse; Smart Writing on Graceland; Satire in France; Free Speech in France; MTB Cornering - Where Should We Point Our Thrusters?; Secure Secure Shell; Java Generics over Primitives; 2014 (Charlie Brooker); How I am 7; Neural Nets Applied to Go; Programming, Business, Social Contracts; Distributed Systems for Fun and Profit; XML and Scheme; Internet Radio Stations (Curated List); Solid Data About Placebos; Half of Americans Think Climate Change Is a Sign of the Apocalypse; Saturday Surf Sessions With Juvenile Delinquents; Ssh, tty, stdout and stderr; Feathers falling in a vacuum; Santiago 30m Bike Route; Mapa de Ciclovias en Santiago; How Unreliable is UDP?; SE Santiago 20m Bike Route; Cameron's Rap; Configuring libxml with Eclipse; Reducing Combinatorial Complexity With Occam - AI; Sentidos Comunes (Chilean Online Magazine); Hilary Mantel: The Assassination of Margaret Thatcher - August 6th 1983; NSA Interceptng Gmail During Delivery; General IIR Filters; What's happening with Scala?; Interesting (But Largely Illegible) Typeface; Retiring Essentialism; Poorest in UK, Poorest in N Europe; I Want To Be A Redneck!; Reverse Racism; The Lost Art Of Nomography; IBM Data Center (Photo); Interesting Account Of Gamma Hack; The Most Interesting Audiophile In The World; How did the first world war actually end?; Ky - Restaurant Santiago; The Black Dork Lives!; The UN Requires Unaninmous Decisions; LPIR - Steganography in Practice; How I Am 6; Clear Explanation of Verizon / Level 3 / Netflix; Teenage Girls; Formalising NSA Attacks; Switching Brakes (Tektro Hydraulic); Naim NAP 100 (Power Amp); AKG 550 First Impressions; Facebook manipulates emotions (no really); Map Reduce "No Longer Used" At Google; Removing RAID metadata; New Bike (Good Bike Shop, Santiago Chile); Removing APE Tags in Linux; Compiling Python 3.0 With GCC 4.8; Maven is Amazing; Generating Docs from a GitHub Wiki; Modular Shelves; Bash Best Practices; Good Emergency Gasfiter (Santiago, Chile); Readings in Recent Architecture; Roger Casement; Integrated Information Theory (Or Not); Possibly undefined macro AC_ENABLE_SHARED; Update on Charges; Sunburst Visualisation; Spectral Embeddings (Distances -> Coordinates); Introduction to Causality; Filtering To Help Colour-Blindness; ASUS 1015E-DS02 Too; Ready Player One; Writing Clear, Fast Julia Code; List of LatAm Novels; Running (for women); Building a Jenkins Plugin and a Jar (for Command Line use); Headphone Test Recordings; Causal Consistency; The Quest for Randomness; Chat Wars; Real-life Financial Co Without ACID Database...; Flexible Muscle-Based Locomotion for Bipedal Creatures; SQL Performance Explained

© 2006-2013 Andrew Cooke (site) / post authors (content).

Graphics Construction Primitives

From: "andrew cooke" <andrew@...>

Date: Sat, 24 Feb 2007 09:37:25 -0300 (CLST)

Kragen Sitaker (and wife Beatrice) is here for a couple of nights.  Last
night he was showing me a program he'd written in Javascript to display
images of 3D models.

Most of the program was the usual geometry stuff, but two things surprised
me.  First, the representation of objects, which was three arrays: an
array of points (coordinate triplets, then an array of lines (pairs of
indices into the array of points), then an array of polygons (lists of
indices into the array of lines).  In practice the polygons were always

Is this a standard representation?  I thought it was neat.  It extends
neatly to a further array of volumes, which would be lists of indices into
the polygons.  However, in some way it's too general - there's no
constraint that all the lines in a polygon are coplanar, or that they form
closed loops (you can try to evade this by joining first and last points,
but that doesn't work so well if these are more general 2D figures with
holes).  Similarly, in higher dimensions, there's no guarantee that a
volume is "sealed" by the surfaces.

An alternative would be a less general approach that used surfaces as the
fundamental component.  Each would be defined by a point and a normal
vector.  Lines would then be intersections of planes.  Volumes would still
need checks for completeness and/or 'superfluous' surfaces.

The second interesting idea was an "extrusion" function used to generate
models from simpler components.  The way I understood it first was as a
fairly simple mathematical operation which takes a component (point or
line) and adds a further dimension.  So the following returns a cube:

       extrude(I, O)))

where I, J, and K are the normal unit vectors and O is the origin.

However, as far as I can tell, the implementation is rather different.  It
seems to be implemented as an operation that transforms the points in a
component and then "reconnects" the new points in "the way you would
expect" given the description above.  So if there are two points P0 and
Q0, they are transformed to P1 and Q1.  Then p0 and P1 are joined by a
line (same for Q0 and Q1).  Next, if P0 and Q0 are connected then P1 and
Q1 are connected and a polygon constructed using P0, Q0, Q1, P1 (in fact,
two triangles).

Furthermore, this can be iterated, re-applying the transform to the new
set of points a specified number of times (and doing the connections).

This is very useful.  Not only does it give the cube construction earlier,
but it can be used to construct, for example a torus.  Start with a circle
and repeatedly extrude, rotating points about a point coplanar with the
initial circle, but lying outside.

But while it is useful it also seems to be ad-hoc.  Somehow although it
works like my original understanding of the function, it is rather
different.  It seems an odd primitive operation - maybe it is better
expressed as the function I originally described, plus rotation and
duplication.  One issue with doing that, though, is that you get
additional faces - the torus has internal faces where each "straight
tublet" joins the next.  Either that, or the cube is actually a
rectangular sleeve.


Re: Graphics Construction Primitives

From: "andrew cooke" <andrew@...>

Date: Wed, 16 May 2007 20:12:22 -0400 (CLT)

Someone else mailed something too, which I may have forgotten to forward. 
Sorry for the confusion - I was meaning to go back to it, but never got
the time...  Andrew

---------------------------- Original Message ----------------------------
Subject: Re: Graphics Construction Primitives
From:    "Kragen Javier Sitaker" <kragen@...>
Date:    Wed, May 16, 2007 11:14 am
To:      compute-GraphicsCo0@...

For what it's worth, the polygons are arrays of indices into the points
array, not the lines array.  The main reason I chose that representation
is that in a triangular mesh, each point is part of six polygons, and I
wanted to avoid transforming each point into camera-space and
perspective-projecting it six times to draw each frame.

It looks like you could extend it to volumes --- you can dissect a
triangular prism into three tetrahedra.  I'm not sure tetrahedra are a
particularly handy way to represent a volume, though, depending on what
you want to do with it.

I represented line segments by the points at their ends, rather than by
intersecting planes, because I wanted to be able to draw them.  It's
pretty straightforward to draw them if you have the coordinates at their
ends; somewhat more involved if you start out with two planes.

The extrusion function takes a general affine transform as an argument,
rather than just a translation vector, so you can generate a snailshell
from, say, an octagon, with a single call to it.  Maybe that would be a
cooler demo than the torus.  (FWIW the circle that starts the torus is
also generated, from a point, by the extrusion function.)  The cube has
ends because extruding a line makes a face; extruding a point doesn't.

Sorry the implementation is (apparently) so hard to read.

For others who are interested, this is all at
http://pobox.com/~kragen/sw/torus.html and was originally posted to
kragen-hacks at

Comment on this post