Главная страница
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.024 c
1-25300
Xtz
2003-12-22 22:22
2004.01.09
И Снова TreeView ,помогите разобратся млин уж неделю парюсь


1-25324
AndrewK
2003-12-22 14:50
2004.01.09
Как в TVirtualStringTree создать структуру?


1-25350
Александр Мих
2003-12-22 11:01
2004.01.09
Инициализация переменных


9-25168
Asrw
2003-06-05 21:41
2004.01.09
Сохранение в игре


14-25574
BlackTiger
2003-12-16 21:23
2004.01.09
ЛЮДИ!!! Помогите срочно с клавиатурой!