Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^3: Contour mapping?

by graff (Chancellor)
on Apr 28, 2016 at 07:02 UTC ( #1161734=note: print w/replies, xml ) Need Help??

in reply to Re^2: Contour mapping?
in thread Contour mapping?


I'd say don't worry about ordering (until later). Take one triangle at a time, and look at its three edges in whatever sequence is given.

  • If one edge crosses a given whole-number Z value, then exactly one other edge in that triangle will cross that same value, so you'll get exactly one iso-contour line segment per whole-number Z per triangle, and its position and angle in the overall XY coordinate space can be worked out.
  • While a single vertex (XY point) can be shared among a variable number of triangles (2 to ...8? 9?), a given vertex pair (i.e. an edge) will appear in at most two triangles. (Edges appearing in only one triangle define the outer boundary of the XY plane being charted.)
  • Putting those two things together, as you march through each triangle, watch for the case where you come to an edge you've seen before (of course, its end points will be presented in opposite order, relative to the first time you saw this edge). If you've already seen it, you already know if it crosses any whole-number Z value(s), and you have the coordinates of the end points for that iso-contour line in the adjacent (previously done) triangle.
  • When you find the other edge(s) of the current triangle crossing the same whole-number Z value(s) -- these also may be edges you've seen before -- you have what you need to maintain a linked list of the nodes for the given iso-contour line, in addition to knowing the position and angle of each line segment.

For 2.4 million vertices (how many triangles?), it's a lot to keep track of, but it seems like just a matter of looping over triangles, and for each of those, looping over edges, keeping track of the edges you've done, and keeping a properly indexed list of iso-contour line segments as they come up, so that you know when you encounter each interior edge the second time, and can traverse the connections of linked contour lines.

Regarding that first point above, the logical possibilities are:

  1. None of the three edges contain a whole-number Z value
  2. One or more of the vertices is itself a whole-number Z value
  3. An edge contains just one whole-number Z value, so that value appears on one other edge (or may be the at the opposite vertex)
  4. An edge contains two or more whole-number Z values; either all those values will also appear on one other edge, or else they'll be divvied up among the other two edges (or one of them may be at the opposite vertex)
I hope you have a generous schedule (and are getting paid enough) for doing this. Sounds like a lot of work.

(updated wording in a couple bullet points)

Replies are listed 'Best First'.
Re^4: Contour mapping?
by pryrt (Monsignor) on Apr 28, 2016 at 13:24 UTC

    I think this is going in a better direction than my suggestion.

    Regarding ordering:

    • If you find edges that appear in only one triangle (a boundary edge), then any contour line that intersects that edge will "start" or "end" there.
      • You can then traverse it to the other edge/vertex of that first triangle; that other edge will be shared with a new triangle, and so forth, for a continuous line in the proper order.
      • It will get a bit more complicated when you hit a vertex instead of an edge for that contour, because then you have to try a couple of adjacent triangles to see which direction the contour flows... but in general, it's pretty straightforward
      • Keep track of all the triangles you've processed for a given contour height as you're going
      • Keep going until you reach another edge (or until you find a second intersection with a triangle you've already hit (for example, if the contour line were shaped like a number 9)
    • If you don't have any "start" edges for a given contour height, you can just start at any edge/vertex that crosses the height under question, and start another contour loop/line from there.
    • For a given contour height, you may have more than one starting point (like my two-island example), or if you've got a Y-shaped contour going off to the edges. So after you've ended one loop or line, check to see if there are any other edges/vertexes that you haven't processed yet that cross through your given height, and start again.
    • Once you've used all the edges/vertexes that go thru a given height, move on to the next height.

    Those triangles ended up being a lot more help than I originally thought they would (++graff).

    Very interesting discussion, and I'll have to store away some of these concepts if I ever need the details of the contours, rather than just being able to visually see them.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1161734]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2021-02-26 15:06 GMT
Find Nodes?
    Voting Booth?

    No recent polls found