[gameprogrammer] RES: Re: RES: Re: 2D math question

Thank you very much!!!!
Dirso.

-----Mensagem original-----
De: gameprogrammer-bounce@xxxxxxxxxxxxx
[mailto:gameprogrammer-bounce@xxxxxxxxxxxxx] Em nome de Bob Pendleton
Enviada em: sexta-feira, 27 de abril de 2007 10:38
Para: gameprogrammer@xxxxxxxxxxxxx
Assunto: [gameprogrammer] Re: RES: Re: 2D math question

On Thu, 2007-04-26 at 22:58 -0300, Edilson Vasconcelos de Melo Junior
wrote:
> How would I do this test? Do you have any sample code for the testing?


http://www.google.com/search?hl=en&q=point+in+polygon+test&btnG=Google
+Search

This is one of those problems that has been worked to death :-). But
like so many you need to know the correct keywords to look it up. Go to
Google and search for "point in polygon test" (with out the quotations)
and you will find more information than you ever wanted.

Part of the problem is that you really do need to know if you are
working with concave or convex polygons, and if the polygons have holes
represented by separate contours. There are highly optimized methods for
working with triangles.

                Bob Pendleton

> 
> Thanks,
> Dirso
> 
> -----Mensagem original-----
> De: gameprogrammer-bounce@xxxxxxxxxxxxx
> [mailto:gameprogrammer-bounce@xxxxxxxxxxxxx] Em nome de Alan Wolfe
> Enviada em: quinta-feira, 26 de abril de 2007 22:18
> Para: gameprogrammer@xxxxxxxxxxxxx
> Assunto: [gameprogrammer] Re: 2D math question
> 
> since you know the polygon is convex, one way to do it would be to use
> the normal of each line segment to see if the point you are testing is
> on the inside or outside of the line. like this pseudo code
> 
> int i =0;
> 
> while i < numverts and the point tested is on the inside of the line
> segment defined by point i and i+1
>   i++;
> 
> if(i<numverts)
>   point is outside the polygon
> else
>   point is inside the polygon
> 
> 
> 
> 
> On 4/26/07, Edilson Vasconcelos de Melo Junior <dirso@xxxxxxxxxxxxxxxxxx>
> wrote:
> > Is there any generic math expression I could use to know if a given
point
> Po
> > (xo, yo) belongs to/is inside of convex polygon with 'n' vertex (where n
>
> > 2)? Maybe if I have have a function for n==3, I could split my polygon
in
> > several triangles, right?
> >
> > Thanks,
> > Dirso
> >
> >
> > ---------------------
> > To unsubscribe go to http://gameprogrammer.com/mailinglist.html
> >
> >
> >
> 
> ---------------------
> To unsubscribe go to http://gameprogrammer.com/mailinglist.html
> 
> 
> 
> 
> 
-- 
+--------------------------------------+
+ Bob Pendleton: writer and programmer +
+ email: Bob@xxxxxxxxxxxxx             +
+ web: www.GameProgrammer.com          +
+ www.Wise2Food.com                    +
+ nutrient info on 7,000+ common foods +
+--------------------------------------+



---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html





-- 
No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.467 / Virus Database: 269.6.1/777 - Release Date: 26/4/2007
15:23



---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: