# Points and Regions

**URL:** https://forum.kirupa.com/t/points-and-regions/103432
**Category:** Uncategorized
**Created:** [March 5, 2004, 12:05am UTC](https://forum.kirupa.com/t/points-and-regions/103432 "2004-03-05T00:05:47Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![GLOG](https://avatars.discourse-cdn.com/v4/letter/g/7c8e57/32.png) [@GLOG](https://forum.kirupa.com/u/GLOG)
#### Post date: [March 5, 2004, 12:05am UTC](https://forum.kirupa.com/t/points-and-regions/103432/1 "2004-03-05T00:05:47Z")

</div>

Hi guys,

I have a graphics question, that might not necessarily have anything to do with Flash, but I thought the people here might be able to help anyways. This is strictly a theory question, and may come up in a Flash project.

I have an image, lets say 100x100, and i have regions [polygons] being drawn on the image from a database of coordinates and these regions also become an image map. Now I have no problem with this, but I do have a set of points that also have co-ordinates, that I have to display, if their region is clicked on.

Lets take a simple example: I have a region mapped by 4 points:  
(0,0) (0,10) (10,0) (10,10)  
Now, it’s easy to test whether a point will fall into this region.  
A point, (5,5) will, and a point (11,11) will not. The test is simple… the region is a rectangle, test X ranges and Y ranges.

My problem is that my regions are not rectangles. They are complicated shapes that follow no pattern. Lets say one of these regions is a triangle with co-ordinates:  
(0,0) (10,0) (5,10)  
Which will look like:

…(0,0) \_\_\_\_\_\_\_\_\_ (10,0)  
…--------/  
…------/  
…—/  
…/ (5,10)

Now, it is clear that a point (4,10) or (6,10) will not fall into this region. But what about a point (4,9) or (4,6) … will that? And the shape can be anything, a star, a decagon, anything. Is there an algorithm anyone can provide (or get me started on) or a class that can check regions for points?

Thanks guys  
GLOG
