httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Hartill <hart...@hyperreal.com>
Subject (no subject) (fwd)
Date Tue, 03 Oct 1995 03:16:22 GMT

no ack sent

Forwarded message:
> From stein@gcomm.com  Mon Oct  2 17:02:49 1995
> Message-Id: <199510030002.RAA01551@taz.hyperreal.com>
> Date: Mon, 02 Oct 95 20:01:56 -0700
> From: Bob Stein <stein@gcomm.com>
> Organization: Galacticomm, Inc.
> X-Mailer: Mozilla 1.22 (Windows; I; 16bit)
> MIME-Version: 1.0
> To: apache-bugs@mail.apache.org
> Subject: (no subject)
> Content-Transfer-Encoding: 7bit
> Content-Type: text/plain; charset=us-ascii
> 
> Dear Apache folks,
> 
> Here is a function for determining whether a point is in a polygon.  It can be used by

> HTTP servers to support clickable image maps.  My friend Craig and I wrote the thing

> because we thought some existing code for this algorithm was pretty ridiculously 
> over-complicated.  If you have any use for it in the Apache project, please feel free,

> we'd be honored.  Please give credit where credit is due.
> 
> -- Bob Stein                          Internet mail:  stein@gcomm.com
>  ______________________________________________________________________
> |                                                                      |
> |  Galacticomm, Inc.                           (305) 583-5990 (voice)  |
> |  4101 SW 47 Avenue, Suite 101                (305) 583-7846 (FAX)    |
> |  Ft Lauderdale, Florida, USA, 33314          (305) 583-7808 (modem)  |
> |______________________________________________________________________|
> 
> 
> 
> /***************************************************************************
>  *                                                                         *
>  *   INPOLY.C                                                              *
>  *                                                                         *
>  *   Copyright (C) 1995 GALACTICOMM, Inc.  Freeware source code.           *
>  *                                                                         *
>  *   Please feel free to use this source code for any purpose, commercial  *
>  *   or otherwise, as long as you don't restrict anyone else's use of      *
>  *   this source code.  Please give credit where credit is due.            *
>  *                                                                         *
>  *   Point-in-polygon algorithm, created especially for World-Wide Web     *
>  *   servers to process image maps with mouse-clickable regions.           *
>  *                                                                         *
>  *   Home for this file:  ftp://gcomm.com/library/develop/inpoly.c         *
>  *                                                                         *
>  *                                       6/19/95 - Bob Stein & Craig Yap   *
>  *                                                                         *
>  ***************************************************************************/
> 
> #define FILREV "$Revision:   1.0$"
> 
> int                                /*   1=inside, 0=outside                */
> inpoly(                            /* is target point inside a 2D polygon? */
> unsigned int poly[][2],            /*   polygon points, [0]=x, [1]=y       */
> int npoints,                       /*   number of points in polygon        */
> unsigned int xt,                   /*   x (horizontal) of target point     */
> unsigned int yt)                   /*   y (vertical) of target point       */
> {
>      unsigned int xnew,ynew;
>      unsigned int xold,yold;
>      unsigned int x1,y1;
>      unsigned int x2,y2;
>      int i;
>      int inside;
> 
>      if (npoints < 3) {
>           return(0);
>      }
>      inside=0;
>      xold=poly[npoints-1][0];
>      yold=poly[npoints-1][1];
>      for (i=0 ; i < npoints ; i++) {
>           xnew=poly[i][0];
>           ynew=poly[i][1];
>           if (xnew > xold) {
>                x1=xold;
>                x2=xnew;
>                y1=yold;
>                y2=ynew;
>           }
>           else {
>                x1=xnew;
>                x2=xold;
>                y1=ynew;
>                y2=yold;
>           }
> 
>           if ((xnew < xt) == (xt <= xold)
>            && ((long)yt-(long)y1)*(long)(x2-x1)
>             < ((long)y2-(long)y1)*(long)(xt-x1)) {
>                inside=!inside;
>           }
>           xold=xnew;
>           yold=ynew;
>      }
>      return(inside);
> }
> 
> 
> 
> 
> 


Mime
View raw message