Вниз
Скачать: CL | DM;

Point In Poligon   Найти похожие ветки 

 
NikB   (2003-09-09 01:02) [0]

Zdravstvuite!

Segodnia mne muchit problema opredelenie pronadlejit li odno point (x,y) poligonu ((x0,y0),(x1,y1),..,(x3,y3)).

Prochital to cto nashel, no ne ponial pochemu ne vsegda poluchaetsa. (Navernoie points poligona nado sortirowat ili chert znaet)

Budu ochen blagodaren, esli pokajete kak bistro opredelit prinadlejnost.

Zdes vnizu napishu dva metoda, kotorie ne vsegda rabotaiut:


Function PointInPolygon(Const P:TPoint; Const Poly:Array of TPoint):Boolean;
{ slow... Var Region:HRGN;
begin
Region:=CreatePolygonRgn(Poly,1+High(Poly),0);
result:=(Region>0) and PtInRegion(Region,p.x,p.y);
DeleteObject(Region);
end;
}
Var i,j : Integer;
begin
result:=False;
j:=High(Poly);
for i:=0 to High(Poly) do
begin
if (((( Poly[i].Y <= P.Y ) and ( P.Y < Poly[j].Y ) ) or
(( Poly[j].Y <= P.Y ) and ( P.Y < Poly[i].Y ) )) and
( P.X < ( Poly[j].X - Poly[i].X ) * ( P.Y - Poly[i].Y )
/ ( Poly[j].Y - Poly[i].Y ) + Poly[i].X )) then begin
result:=not result;
end;
j:=i; { +1? }
end;
end;


 
NikB   (2003-09-09 17:37) [1]

Okonchiwaem diskusiu :)
Okazalos, chto problema ne v PointInPolygon (perfectno rabotaet) sobitie OnMouseEnter tSurfaceSerie in TeeChart rabotaet vsegda kak 2D (i v 3D mode).
Spasibo vsem, kto hotel ili dumal chto hochet otvetit mne!



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.031 c
14-25509
РВА
2003-12-16 13:27
2004.01.09
Подключение к сети


1-25290
JB
2003-12-23 13:03
2004.01.09
TCollectionItem


4-25650
Prov
2003-11-06 09:35
2004.01.09
MessageBoxIndirect - don t work


1-25428
Viktor
2003-12-23 22:15
2004.01.09
Что такое Unsafe type Pointer


3-25207
Inkotex
2003-12-11 19:20
2004.01.09
Печать




   Наверх