Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2004.01.09;
Скачать: 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 вся ветка

Текущий архив: 2004.01.09;
Скачать: CL | DM;

Наверх




Память: 0.46 MB
Время: 0.034 c
4-25655
SergeySEM
2003-11-06 13:34
2004.01.09
hint у


14-25596
}|{yk
2003-12-03 14:12
2004.01.09
---|Ветка была без названия|---


14-25573
Alexander Vasjuk
2003-12-16 12:52
2004.01.09
Хакеры - санитары софта?


14-25536
Ega23
2003-12-18 14:29
2004.01.09
Прогноз: Россия - Финляндия?


8-25456
dzmitry_
2003-09-04 14:29
2004.01.09
ВЫВЕСТИ часть TMetafile в TImage или TPaint, или векторная график