Is this what you are wanting to know?

int IsPtInPoly(Point dPtIn, std::vector< double > Xpts, std::vector< double > 
Ypts)
{
        double Ax = dPtIn.x;
        double Ay = dPtIn.y;
        double Xl; 
        double Yl; 
        double Xr; 
        double Yr; 
        const double Fx = Xpts[0]; 
        const double Fy = Ypts[0]; 
        double Yc; 

        long lLoopCtrl = 0; 
        long lCrossings = 0; 

        double Xtemp; 
        double Ytemp;
        
        //int intRes;
        const int iNumEntry = Xpts.size();

        for(lLoopCtrl = 0; lLoopCtrl < iNumEntry; )
        {
                Xl = Xpts[lLoopCtrl];
                Yl= Ypts[lLoopCtrl];

                if(!(lLoopCtrl + 1 > iNumEntry - 1))
                {
                        Xr = Xpts[lLoopCtrl + 1];
                        Yr = Ypts[lLoopCtrl + 1];
                }
                else
                {
                        Xr = Fx;
                        Yr = Fy;
                }

                if((Xl < Ax) && (Xr < Ax))
                {
                        lLoopCtrl=lLoopCtrl + 1;
                        continue;
                }
                if((Xl > Ax) && (Xr > Ax))
                {
                        lLoopCtrl=lLoopCtrl + 1;
                        continue;
                }
                if((Yl < Ay) && (Yr < Ay))
                {
                        lLoopCtrl=lLoopCtrl + 1;
                        continue;
                }

                
                if(((Yl > Ay) && (Yr > Ay)) && ((Xl > Ax) || (Xr > Ax)))
                {
                        lCrossings = lCrossings + 1;
                        lLoopCtrl=lLoopCtrl + 1;
                        continue;
                }
                if(Xl > Xr)
                {
                        Xtemp = Xl;
                        Ytemp = Yl;
                        Xl = Xr;
                        Yl = Yr;
                        Xr = Xtemp;
                        Yr = Ytemp;
                }

                Yc = Yl + (((Yr - Yl) / (Xr - Xl)) * (Ax - Xl));
                if(Yc > Ay)
                {
                        lCrossings = lCrossings + 1;
                }

                lLoopCtrl=lLoopCtrl + 1;
        }
        
return lCrossings & 1;
}

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] Behalf Of
sagent100
Sent: Friday, April 07, 2006 1:04 PM
To: [email protected]
Subject: [mitab] How to know if a point object is Within a polygon


Hi all!
Is it possible to know if a point object (x-y coordinates) is within a 
polygon object ?

I will appreciate a lot an example using VB or in other case C.

Thanks !!
Alejandro










 
Yahoo! Groups Links



 






 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/mitab/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to