Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

To solve the general case requires that you allow for more than just polygons because you can end up with a topologically interesting shape, that is, a shape with one or more holes in it.

I have usually seen this handled by having a clock-wise polygon around the outside and zero or more counter-clock-wise polygons describing the holes. And often those are simplified by having them joined by lines contained within the shape.

So your best bet is probably to only remove a "shared" edge that appears twice in one polygon if both instances of the edge are adjacent in the list. This will remove useless internal lines (and each such removal can make a new removal possible) while preventing you from splitting your shape into two shapes (the outer edge and the hole).

The next trick is to flag shared edges that you end up being unable to remove so that you don't draw lines for those. You fill the polygon like normal but you need to just skip over self-shared edges when you go to draw a line around the border of the polygon. Even better is to draw the "internal" (self-shared) edges using the "fill" color so you don't end up with unshaded pixels when they fall too precisely onto such a line. If you draw the internal / self-shared edges before the other edges, then that is best of all (to make sure you don't have single-pixel gaps in your border line).

- tye        


In reply to Re: Better maps with Math::Geometry::Voronoi, and a Challenge for Math Monks (holes) by tye
in thread Better maps with Math::Geometry::Voronoi, and a Challenge for Math Monks by samtregar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-04-26 05:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found