Advertisement
WarPie90

OSR - GetCompassAngle

Jan 5th, 2015
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.58 KB | None | 0 0
  1. function GetCompassAngle(AsDegrees:Boolean=True): Extended;
  2. var
  3.   north,south: TPoint;
  4.   M:TPoint = [561,20];
  5.   TPA:TPointArray;
  6. begin
  7.   FindColorsTolerance(TPA, 1911089, 545,4,576,36, 20);
  8.   FilterPointsDist(TPA, 8,15, M.x,M.y);
  9.   north := MiddleTPA(SplitTPA(TPA,3)[0]);
  10.   south := RotatePoint(north,PI, M.x,M.y);
  11.   FindColorsTolerance(TPA, 920735, 545,4,576,36, 20);
  12.   FilterPointsDist(TPA, 0,6, south.x,south.y);
  13.   SortTPAFrom(TPA,M);
  14.   Result := FixRad(ArcTan2(TPA[high(tpa)].y-M.y, TPA[high(tpa)].x-M.x) - (PI/2));
  15.   if AsDegrees then
  16.     Result := Degrees(Result);
  17. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement