📄 38355
字号:
Path: cantaloupe.srv.cs.cmu.edu!crabapple.srv.cs.cmu.edu!bb3.andrew.cmu.edu!news.sei.cmu.edu!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!howland.reston.ans.net!noc.near.net!uunet!mcsun!sun4nl!bsoatr!bskewe!keweFrom: kewe@bskewe.atr.bso.nl (Cornelis Wessels)Newsgroups: comp.graphicsSubject: Point within a polygon Message-ID: <734977280snx@bskewe.atr.bso.nl>References: <1993Apr14.102007.20664@uk03.bull.co.uk>Date: Fri, 16 Apr 93 16:21:20 GMTOrganization: MATHEMAGICLines: 71In article <1993Apr14.102007.20664@uk03.bull.co.uk> scrowe@hemel.bull.co.uk writes: > > 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); }Cornelis WesselsKrommenoord 143079 ZT ROTTERDAMThe Netherlands+31 10 4826394kewe@bskewe.atr.bso.nl
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -