
  > 
  > I am looking for an algorithm to determine if a given point is bound by a 
  > polygon. Does anyone have any such code or a reference to book containing
  > information on the subject ?
  > 
  >                 Regards
  > 
  >                         Simon
  > 
/* +-------------------------------------------------------------------+
   |                                                                   |
   | Function    : PuntBinnenPolygoon                                  |
   |                                                                   |
   +-------------------------------------------------------------------+
   |                                                                   |
   | Auteur      : Cornelis Wessels                                    |
   |                                                                   |
   | Datum       : 11-01-1993                                          |
   |                                                                   |
   | Omschrijving: Bepaalt of de aangeboden VECTOR2D p binnen of op de |
   |               rand van het polygoon P valt.                       |
   |                                                                   |
   +-------------------------------------------------------------------+
   |                                                                   |
   | Wijzigingen : -                                                   |
   |                                                                   |
   +-------------------------------------------------------------------+ */

CLIBSTATUS PuntBinnenPolygoon ( POLYGOON *P, VECTOR2D *p )
  {
  VECTOR2D o, v, w;
  INDEX    aantal_snijpunten, N, n;

  aantal_snijpunten = 0;
  N                 = GeefPolygoonLengte(P);
  GeefPolygoonRandpunt ( P, N, &o );

  for ( n=1; n<=N; n++ )
    {
    GeefPolygoonRandpunt ( P, n, &v );

    if ( o.x >= p->x && v.x <  p->x ||
	 o.x <  p->x && v.x >= p->x  )
      {
      w.x = p->x;
      InterpoleerLineair ( &o, &v, &w );

      if ( w.x == p->x && w.y == p->y )
	return(CLIBSUCCES);
      else if ( w.y > p->y )
	aantal_snijpunten++;
      }

    KopieerVector2d ( &v, &o );
    }

  if ( aantal_snijpunten%2 == 0 )
    return(CLIBERBUITEN);
  else
    return(CLIBSUCCES);
  }