Главная страница
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.039 c
14-25547
abr
2003-12-18 13:21
2004.01.09
архитектура VCL


14-25509
РВА
2003-12-16 13:27
2004.01.09
Подключение к сети


14-25511
MPS
2003-12-18 11:09
2004.01.09
Стоит ли задумываться о Linux?


1-25340
drummer
2003-12-19 15:02
2004.01.09
Excel with Delphi


6-25489
BJValentine
2003-11-06 11:12
2004.01.09
Сокеты