Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Supposing the polygon descriptions obtained from M::G::Voronoi doesn't return different overlapping edges (that I think it doesn't):
  1. select all the points/polygons you want to merge: @points
  2. calculate the set of all the edges involved: @edges
  3. discard from @edges all the edges that have both side points belonging to @points
  4. reconstruct polygons from the remaining edges:
    1. calculate the set of all the vertices in @edges: @vertices
    2. set @polygon = (); $direction = vector (0, -1)
    3. get the leftmost $vertex from @vertices
    4. select from @edges the ones that have $vertex at some extreme: @departing
    5. for my $dep (@departing) { calculate the angle in the range (-π,π) between $direction and the vector ($dep->the_other_vertex - $vertex) } and select the edge $this_edge with minimum angle (minimum = most negative, not minimum in abs value!)
    6. push $polygon, $this_edge
    7. set $direction = previously calculated vector ($this_edge->the_other_vertex - $vertex)
    8. set $vertex = $this_edge->the_other_vertex
    9. repeat from 4.4 until $vertex is equal again to the starting vertex found in 4.3
    10. look for holes inside @polygon (left as an exercise for the reader :-) )
    11. remove the edges inside @polygon from @edges
    12. repeat from 4.1 until @edges is empty.

In reply to Re: Better maps with Math::Geometry::Voronoi, and a Challenge for Math Monks by salva
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 studying the Monastery: (6)
As of 2024-04-23 11:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found