I need to select the points with in the regions that closest match the template, with the knowlede that the region may not contain any valid points.

A Voronoi diagram of your template will give you a set of "nearest-neighbour" regions. That is, each template point will have a Voronoi cell associated with it; every input point in that cell is closer to that cell's template point than to any other template point. (That would be so much easier to say in LaTeX math-mode.)

If your points are on a grid, you can build a bitmap from the Voronoi diagram, with a unique colour for each template point's Voronoi cell. Checking inputs is simply a matter of looking up their position in the bitmap (finding the colour, and thus which template point they're closest to), and calculating the distance to that point. Simple and O(n) once you have the Voronoi diagram.

In the continuous domain, things are probably a bit trickier. Find a good computational geometry text in your local university library; it should have plenty of stuff on this matter.

--
F o x t r o t U n i f o r m
Found a typo in this node? /msg me
% man 3 strfry


In reply to Re: Interesting problem fitting points to a template (algorithm?) by FoxtrotUniform
in thread Interesting problem fitting points to a template (algorithm?) by doowah2004

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.