| 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.

C-ORM: docs, API.

Last 100 entries

Small Success With Go!; Re: Quick message - This link is broken; Adding Reverb To The Echo Chamber; Sox Audio Tools; Would This Have Been OK?; Honesty only important economically before institutions develop; Stegangraphy via PS4; OpenCL Mess; More Book Recommendations; Good Explanation of Difference Between Majority + Minority; Musical Chairs - Who's The Privileged White Guy; I can see straight men watching this conversation and laffing; When it's Actually a Source of Indignation and Disgust; Meta Thread Defending POC Causes POC To Close Account; Indigenous People Of Chile; Curry Recipe; Interesting Link On Marginality; A Nuclear Launch Ordered, 1962; More Book Recs (Better Person); It's Nuanced, And I Tried, So Back Off; Marx; The Negative Of Positive; Jenny Holzer Rocks; Huge Article on Cultural Evolution and More; "Ignoring language theory"; Negative Finger Counting; Week 12; Communication Via Telecomm Bids; Finding Suspects Via Relatives' DNA From Non-Crime Databases; Statistics and Information Theory; Ice OK in USA; On The Other Hand; (Current Understanding Of) Chilean Taxes / Contributions; M John Harrison; Playing Games on a Cloud GPU; China Gamifies Real Life; Can't Help Thinking It's Thoughtcrime; Mefi Quotes; Spray Painting Bike Frame; Weeks 10 + 11; Change: No Longer Possible To Merge Metadata; Books on Old Age; Health Tree Maps; MRA - Men's Rights Activists; Writing Good C++14; Risk Assessment - Fukushima; The Future of Advertising and Surveillance; Travelling With Betaferon; I think I know what I dislike so much about Metafilter; Weeks 8 + 9; More; Pastamore - Bad Italian in Vitacura; History Books; Iraq + The (UK) Governing Elite; Answering Some Hard Questions; Pinochet: The Dictator's Shadow; An Outsider's Guide To Julia Packages; Nobody gives a shit; Lepton Decay Irregularity; An Easier Way; Julia's BinDeps (aka How To Install Cairo); Good Example Of Good Police Work (And Anonymity Being Hard); Best Santiago Burgers; Also; Michael Emmerich (Vibrator Translator) Interview (Japanese Books); Clarice Lispector (Brazillian Writer); Books On Evolution; Looks like Ara (Modular Phone) is dead; Index - Translations From Chile; More Emotion in Chilean Wines; Week 7; Aeon Magazine (Science-ish); QM, Deutsch, Constructor Theory; Interesting Talk Transcripts; Interesting Suggestion Of Election Fraud; "Hard" Books; Articles or Papers on depolarizing the US; Textbook for "QM as complex probabilities"; SFO Get Libor Trader (14 years); Why Are There Still So Many Jobs?; Navier Stokes Incomplete; More on Benford; FBI Claimed Vandalism; Architectural Tessellation; Also: Go, Blake's 7; Delusions of Gender (book); Crypto AG DID work with NSA / GCHQ; UNUMS (Universal Number Format); MOOCs (Massive Open Online Courses); Interesting Looking Game; Euler's Theorem for Polynomials; Weeks 3-6; Reddit Comment; Differential Cryptanalysis For Dummies; Japanese Graphic Design; Books To Be Re-Read; And Today I Learned Bugs Need Clear Examples; Factoring a 67 bit prime in your head; Islamic Geometric Art; Useful Julia Backtraces from Tasks; Nothing, however, is lost with less discomfort than that which, when lost, cannot be missed

© 2006-2015 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