SRL Archive - SRL Bugs

[FIX] function rs_GetCompassAngleDegrees: Extended;


Home

2011-11-22 08:09:57

By Home:


(*
rs_GetCompassAngleRadians
~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function rs_GetCompassAngleRadians: Extended;

Returns the compass angle in radians.

.. note::

by Wizzup?

Example:

.. code-block:: pascal

*)
function rs_GetCompassAngleRadians: Extended;
var
Compass: TPointArray;
MyPoint: TPoint;
two_pi: extended;
begin
Result := -1;
FindColorsTolerance(Compass, 7699891, 520, 2, 560, 40, 0);
if (Length(Compass) < 1) then
Exit;
MyPoint := MiddleTPA(Compass);
Result := ArcTan2(-(MyPoint.Y - 24), MyPoint.X - 543) - Radians(80);

two_pi := 2*Pi;
while (Result > two_pi) do
Result := Result - two_pi;

while (Result < two_pi) do
Result := Result + two_pi;
end;

(*
rs_GetCompassAngleDegrees
~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function rs_GetCompassAngleDegrees: Extended;

Returns the compass angle in degrees.

.. note::

by Wizzup?

Example:

.. code-block:: pascal

*)
function rs_GetCompassAngleDegrees: Extended;
begin
Result := Degrees(rs_GetCompassAngleRadians()) - 360.0;
end;


~Home

Nava2

2011-11-22 08:51:35

… Are you sure its - 80? :s

Home

2011-11-22 08:55:05

From: Nava2
… Are you sure its - 80? :s


Well Yeah. I was thinking that too for a while.. If it's -90 It won't work. Mabey someone smarter can tell me :)


~Home

Nava2

2011-11-22 09:01:35

(*
rs_GetCompassAngleRadians
~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function rs_GetCompassAngleRadians: Extended;

Returns the compass angle in radians.

.. note::

by Wizzup?

Example:

.. code-block:: pascal

*)
function rs_GetCompassAngleRadians: Extended;
var
Compass: TPointArray;
MyPoint: TPoint;
two_pi: extended;
begin
Result := -1;
FindColorsTolerance(Compass, 7699891, 520, 2, 560, 40, 0);
if (Length(Compass) < 1) then
Exit;
MyPoint := MiddleTPA(Compass);
Result := ArcTan2(-(MyPoint.Y - 24), MyPoint.X - 543) - Radians(80);

two_pi := 2*Pi;
while (Result > two_pi) do
Result := Result - two_pi;

while (Result < two_pi) do
Result := Result + two_pi;
end;

(*
rs_GetCompassAngleDegrees
~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function rs_GetCompassAngleDegrees: Extended;

Returns the compass angle in degrees.

.. note::

by Wizzup?

Example:

.. code-block:: pascal

*)
function rs_GetCompassAngleDegrees: Extended;
begin
Result := Degrees(rs_GetCompassAngleRadians());
end;

Please test these. :)

Home

2011-11-22 09:11:02

Uulala what is that mambo jambo Nava ;)

Looks great. I will test when I come out from gym.


Updated mainpost with yours Nava.

~Home

Nava2

2011-11-22 09:32:27

From: Home
Uulala what is that mambo jambo Nava ;)

Looks great. I will test when I come out from gym.


Updated mainpost with yours Nava.

~Home


You wrote them.. I just rearranged! :)

Home

2011-11-22 14:07:37

From: Nava2
You wrote them.. I just rearranged! :)


Heh :)


Anyways. I tested + Fixed a bit.

You forgot this.


function rs_GetCompassAngleDegrees: Extended;
begin
Result := Degrees(rs_GetCompassAngleRadians()) - 360.0;
end;


See that -360.0

~Home

Coh3n

2011-11-22 16:20:01

Cool, I'll commit this tonight if no one else has.

Nava2

2011-11-22 17:57:08

I fail at maths.

(*
fixRad
~~~~~~

.. code-block:: pascal
function fixRad(rad: Extended): Extended;

Returns the periodic rad in the range (0,2PI].

.. note::
By Nava2

*)
const
__TWO_PI = 2 * Pi;

function fixRad(rad: Extended): Extended;
begin
result := rad;
while (result >= __TWO_PI) do
result := result - __TWO_PI;

while (result < 0) do
result := result + __TWO_PI;
end;

(*
rs_GetCompassAngleRadians
~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function rs_GetCompassAngleRadians: Extended;

Returns the compass angle in radians.

.. note::

by Wizzup?

Example:

.. code-block:: pascal

*)
function rs_GetCompassAngleRadians: Extended;
var
Compass: TPointArray;
MyPoint: TPoint;
begin
Result := -1;
FindColorsTolerance(Compass, 7699891, 520, 2, 560, 40, 0);
if (Length(Compass) < 1) then
Exit;
MyPoint := MiddleTPA(Compass);
Result := ArcTan2(-(MyPoint.Y - 24), MyPoint.X - 543) - Radians(80);

Result := fixRad(Result);
end;

(*
rs_GetCompassAngleDegrees
~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function rs_GetCompassAngleDegrees: Extended;

Returns the compass angle in degrees.

.. note::

by Wizzup?

Example:

.. code-block:: pascal

*)
function rs_GetCompassAngleDegrees: Extended;
begin
Result := Degrees(rs_GetCompassAngleRadians());
end;

Fixed version, please test this.

Coh3n

2011-11-22 20:12:22

Committed. :)

euphemism

2011-11-22 21:14:59

We are getting the angle in radians and then converting degrees? As far as I am aware, radians aren't as precise?

Flight

2011-11-22 21:41:41

From: Coh3n
Committed. :)


SRL is saying there's no update available. :huh:

Coh3n

2011-11-22 21:46:53

From: euphemism
We are getting the angle in radians and then converting degrees? As far as I am aware, radians aren't as precise?
I'm not sure. The previous system used degrees, then converted to radians. When I tested, MakeCompass didn't go exactly to N, E, S, W, but was pretty close.

From: Flight
SRL is saying there's no update available. :huh:
Can take up to an hour for Wizzup's server to get the updates. ;)

Flight

2011-11-22 22:33:15

From: Coh3n

Can take up to an hour for Wizzup's server to get the updates. ;)


Well that might explain a few things. :duh:

wudesan

2011-11-22 22:40:15

can't wait

Wanted

2011-11-22 23:04:55

It's not terribly accurate. Turn the compass to face east (270) then WriteLn the current angle.

wudesan

2011-11-22 23:47:53

script cant open bank :(

Wanted

2011-11-22 23:52:01

From: wudesan
script cant open bank :(


Wrong thread.

Happening because Bankscreen does not use UpChars anymore, it uses the old UpChars i.e. ScreenChars.

That and ChooseOption is not fixed yet.. needs at least a new font set i.e. OptionChars.

Nava2

2011-11-23 00:05:06

From: euphemism
We are getting the angle in radians and then converting degrees? As far as I am aware, radians aren't as precise?


Degrees do not actually exist, degrees are technically a converted form of radians.

Check this out: http://en.wikipedia.org/wiki/Radian

wudesan

2011-11-23 00:13:04

From: Wanted
Wrong thread.

Happening because Bankscreen does not use UpChars anymore, it uses the old UpChars i.e. ScreenChars.

That and ChooseOption is not fixed yet.. needs at least a new font set i.e. OptionChars.


How to set new font?

RISK

2011-11-23 00:17:16

Wait for it to be updated, that's all.

From: wudesan
How to set new font?

ReadySteadyGo

2011-11-23 13:46:02

I swear this is inverted from what it was before? All of my minimap functions have broken. Are you sure it doesn't need: Result := -Result + 360;

footballjds

2011-11-23 13:57:41

From: Nava2
Degrees do not actually exist, degrees are technically a converted form of radians.

Check this out: http://en.wikipedia.org/wiki/Radian


that's like saying grads don't exist because technically they're a converted form of Radian.
That's like saying a foot(12 inches) doesn't exist because technically it's a converted form of a meter…

ReadySteadyGo

2011-11-23 14:01:03

(*
fixRad
~~~~~~

.. code-block:: pascal
function fixRad(rad: Extended): Extended;

Returns the periodic rad in the range (0,2PI].

.. note::
By Nava2

*)
const
__TWO_PI = 2 * Pi;

function fixRad(rad: Extended): Extended;
begin
result := rad;
while (result >= __TWO_PI) do
result := result - __TWO_PI;

while (result < 0) do
result := result + __TWO_PI;
end;

(*
rs_GetCompassAngleRadians
~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function rs_GetCompassAngleRadians: Extended;

Returns the compass angle in radians.

.. note::

by Wizzup?

Example:

.. code-block:: pascal

*)
function rs_GetCompassAngleRadians: Extended;
var
Compass: TPointArray;
MyPoint: TPoint;
begin
Result := -1;
FindColorsTolerance(Compass, 7699891, 520, 2, 560, 40, 0);
if (Length(Compass) < 1) then
Exit;
MyPoint := MiddleTPA(Compass);
Result := ArcTan2(-(MyPoint.Y - 24), MyPoint.X - 543) - Radians(80);

Result := -fixRad(Result) + 2*Pi;
end;

(*
rs_GetCompassAngleDegrees
~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function rs_GetCompassAngleDegrees: Extended;

Returns the compass angle in degrees.

.. note::

by Wizzup?

Example:

.. code-block:: pascal

*)
function rs_GetCompassAngleDegrees: Extended;
begin
Result := Degrees(rs_GetCompassAngleRadians());
end;

Should be this. Change
Result := fixRad(Result);
to
Result := -fixRad(Result) + 2*Pi;

wudesan

2011-11-23 18:54:16

Bank option still broke:((((((((

euphemism

2011-11-23 19:28:44

From: wudesan
Bank option still broke:((((((((


Wrong thread, please post in the correct one: http://villavu.com/forum/showthread.php?t=68162

Main

2011-11-24 04:47:39

RsGetCompassAngleDegrees is a bit buggy for me.

Here is a test I've done, starting at N (clicking compass) and tap the left key on keyboard until its pass or at the N again

Here is the test script
Program Test;
{$i SRL\SRL.scar}

Begin
SetupSRl;
Cleardebug;
Repeat
Writeln( IntToStr(Round( RS_GetCompassAngleDegrees)));//WalkCoord;
Until False;
End.

Heres a filtered (removed duplicate) version of the test result
359
10
37
21
352
37
10
47
55
69
63
73
89
55
86
100
118
127
111
82
114
127
100
145
156
176
190
208
217
204
172
208
224
190
235
224
253
246
266
235
280
298
307
262
307
262
280
314
325
280
325
343
359

Home

2011-11-24 04:49:18

There is other version which is better I believe. It just needs to be committed.


~Home