Nitriq is a product by
Home
|
Console Edition
|
Features
|
Getting Started
|
Documentation
|
Support
|
Blog
|
About
Programming Job Interview Challenge Answer Week #14
Here is the question:
Programming Job Interview Challenge Question Week #14
This week was a fun and interesting question. Here is the answer
Step 1. As you're adding points to the polygon, determine a bounding rectangle by keeping track of the min x/y and the max x/y.
Step 2. Draw a line from the point you're interested in, to any point outside the bounding rectangle (because you know the outside point can't be within the polygon).
Step 3. Count the number of intersections between your newly created line and the polygon, if the number is even (0 included) the point in question is not within the polygon, if the number of intersections is odd, then the point is within the polygon.
Examples:
Outside = Even Intersections
Inside = Odd Intersections
Tuesday, August 5, 2008 - 2:33 PM CST -
Permalink
-
Comments [0]
Tags:
Comments are closed.
Click
Download Nitriq Now
for download options on the
NimblePros download page.
RSS
Tags
Atomiq
Blend
CopyPasteKiller
Design
Flamebait
fun
Hacker News
IADNUG
Nitriq
Projects
Stuff
Tips and Tricks
Wishlist
XAML
Archive
November, 2011 (2)
April, 2011 (1)
March, 2011 (2)
November, 2010 (1)
September, 2010 (1)
July, 2010 (2)
June, 2010 (2)
May, 2010 (1)
April, 2010 (1)
March, 2010 (1)
November, 2009 (1)
October, 2009 (5)
September, 2009 (1)
August, 2009 (1)
July, 2009 (1)
June, 2009 (1)
May, 2009 (1)
April, 2009 (2)
March, 2009 (1)
February, 2009 (2)
January, 2009 (1)
October, 2008 (1)
September, 2008 (1)
August, 2008 (1)
July, 2008 (2)
June, 2008 (2)
May, 2008 (2)
March, 2008 (2)
February, 2008 (8)
January, 2008 (4)
December, 2007 (6)
November, 2007 (2)