Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ExtractSector(TPA:TPointArray; angle,sector:Double; radLo,radHi:Int32; center:TPoint):TPointArray;
- var
- i,j:Int32;
- theta,dist,delta:Double;
- begin
- SetLength(Result, Length(TPA));
- angle := Radians(angle);
- for i:=0 to High(TPA) do
- begin
- dist := Sqrt(Sqr(TPA[i].x-center.x) + Sqr(TPA[i].y-center.y));
- theta := ArcTan2(TPA[i].y-center.y, TPA[i].x-center.x) + (PI / 2);
- delta := Degrees(ArcTan2(Sin(theta-angle), Cos(theta-angle)));
- if (Abs(delta) <= sector) and (dist >= radLo) and (dist <= radHi) then
- begin
- Result[j] := TPA[i];
- Inc(j);
- end;
- end;
- SetLength(Result, j);
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement