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

C[omp]ute

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

Choochoo Training Diary

Last 100 entries

Surprise Paradox; [Books] Good Author List; [Computing] Efficient queries with grouping in Postgres; [Computing] Automatic Wake (Linux); [Computing] AWS CDK Aspects in Go; [Bike] Adidas Gravel Shoes; [Computing, Horror] Biological Chips; [Books] Weird Lit Recs; [Covid] Extended SIR Models; [Art] York-based Printmaker; [Physics] Quantum Transitions are not Instantaneous; [Computing] AI and Drum Machines; [Computing] Probabilities, Stopping Times, Martingales; bpftrace Intro Article; [Computing] Starlab Systems - Linux Laptops; [Computing] Extended Berkeley Packet Filter; [Green] Mainspring Linear Generator; Better Approach; Rummikub Solver; Chilean Poetry; Felicitations - Empowerment Grant; [Bike] Fixing Spyre Brakes (That Need Constant Adjustment); [Computing, Music] Raspberry Pi Media (Audio) Streamer; [Computing] Amazing Hack To Embed DSL In Python; [Bike] Ruta Del Condor (El Alfalfal); [Bike] Estimating Power On Climbs; [Computing] Applying Azure B2C Authentication To Function Apps; [Bike] Gearing On The Back Of An Envelope; [Computing] Okular and Postscript in OpenSuse; There's a fix!; [Computing] Fail2Ban on OpenSuse Leap 15.3 (NFTables); [Cycling, Computing] Power Calculation and Brakes; [Hardware, Computing] Amazing Pockit Computer; Bullying; How I Am - 3 Years Post Accident, 8+ Years With MS; [USA Politics] In America's Uncivil War Republicans Are The Aggressors; [Programming] Selenium and Python; Better Walking Data; [Bike] How Fast Before Walking More Efficient Than Cycling?; [COVID] Coronavirus And Cycling; [Programming] Docker on OpenSuse; Cadence v Speed; [Bike] Gearing For Real Cyclists; [Programming] React plotting - visx; [Programming] React Leaflet; AliExpress Independent Sellers; Applebaum - Twilight of Democracy; [Politics] Back + US Elections; [Programming,Exercise] Simple Timer Script; [News] 2019: The year revolt went global; [Politics] The world's most-surveilled cities; [Bike] Hope Freehub; [Restaurant] Mama Chau's (Chinese, Providencia); [Politics] Brexit Podcast; [Diary] Pneumonia; [Politics] Britain's Reichstag Fire moment; install cairo; [Programming] GCC Sanitizer Flags; [GPU, Programming] Per-Thread Program Counters; My Bike Accident - Looking Back One Year; [Python] Geographic heights are incredibly easy!; [Cooking] Cookie Recipe; Efficient, Simple, Directed Maximisation of Noisy Function; And for argparse; Bash Completion in Python; [Computing] Configuring Github Jekyll Locally; [Maths, Link] The Napkin Project; You can Masquerade in Firewalld; [Bike] Servicing Budget (Spring) Forks; [Crypto] CIA Internet Comms Failure; [Python] Cute Rate Limiting API; [Causality] Judea Pearl Lecture; [Security, Computing] Chinese Hardware Hack Of Supermicro Boards; SQLAlchemy Joined Table Inheritance and Delete Cascade; [Translation] The Club; [Computing] Super Potato Bruh; [Computing] Extending Jupyter; Further HRM Details; [Computing, Bike] Activities in ch2; [Books, Link] Modern Japanese Lit; What ended up there; [Link, Book] Logic Book; Update - Garmin Express / Connect; Garmin Forerunner 35 v 230; [Link, Politics, Internet] Government Trolls; [Link, Politics] Why identity politics benefits the right more than the left; SSH Forwarding; A Specification For Repeating Events; A Fight for the Soul of Science; [Science, Book, Link] Lost In Math; OpenSuse Leap 15 Network Fixes; Update; [Book] Galileo's Middle Finger; [Bike] Chinese Carbon Rims; [Bike] Servicing Shimano XT Front Hub HB-M8010; [Bike] Aliexpress Cycling Tops; [Computing] Change to ssh handling of multiple identities?; [Bike] Endura Hummvee Lite II; [Computing] Marble Based Logic; [Link, Politics] Sanity Check For Nuclear Launch; [Link, Science] Entropy and Life

© 2006-2017 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
triangles.

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(K,
    extrude(J,
       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.

Andrew

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
http://lists.canonical.org/pipermail/kragen-hacks/2007-February/000448.html

Comment on this post