Face ID

mesh locations

Connecting moving points over a topographic model of Zermatt, Switzerland

Following the previous post this code shows how to use the twin-edge function to more quickly identify a point position’s corresponding face from an HEM. In that code we simply checked through every face until finding one which intersected the cutting plane. In some ways this was at first necessary because the plane’s origin began outside the boundaries of the mesh; however, once an intersection point was discovered, the proceeding intersections were calculated using a recursive function that identified adjacent faces using the HEM methods. Here we use the faceID (Lines 189 to 219 of the HEM_functions tab) function to identify the location of a point on the mesh.

This occurs in Lines 205-213
while (ct 0 && u[1]0 && u[0]<1){
   lastX=connectionTWIN(m, m.eTE[x], seg, Pt2);
  } else { x=m.eNE[x]; } //ELSE PREPARE TO TEST THE NEXT EDGE

This uses the line between the starting point and runs a loop over the edges of the known face searching for an intersection (in the XY-plane projection). When an intersection isn’t found, Next Edge – .eNE – is used to advance the tested edge. If an intersection does exist (for an explanation of if (u[1]>0 && u[1]0 && u[0]<1) see Paul Bourke’s explanation of Line-Line Intersection calculations) the function connectionTWIN is called. connectionTWIN is a recursive function which follows the same logic (Lines 174-182 of the same tab) but proceeds from face to face until reaching the target point or the edge of the mesh.

Once the appropriate face Index of the point is known, drawing the connection lines is done with the function ptptConnection, called in Line 97 of the main tab. Apart from a few additional lines necessary for saving the path of the line in a Pts the code is very similar to the above section, finding an initial edge by looping around a face, then continuing to connectionTWIN.

mesh locations

This sketch produced a web of 20 points (Line 30) with 190 connections and around 17,000 segments per frame.

(.pde download)
NB: the text file packaged in this example has over 27,000 faces. If you think this might be beyond the capabilities of your computer, you might want to copy the .txt files from the Mesh Import example into your sketch’s data folder and change the file names in Lines 55-56 to match. You’ll also need to adjust the camera location.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: