Deg/Rad90 : 1.57079632679489661926E+0000I was under the impression that cos of 90 degrees is 0, sin at least seems to be correct. I'm almost certain that I miss something crucial but I spend 4 hours looking and I can't see it.
Cos -4.48073616129170152476E-0001:-2.71050543121376108502E-0020
Sin 8.93996663600557890477E-0001: 1.00000000000000000000E+0000
Deg/Rad90: 1.5707963267948966E+000 FALSE
Cos -4.4807361612917013E-001: 6.1232339957367660E-017 TRUE
Sin 8.9399666360055796E-001: 1.0000000000000000E+000 FALSE
@Munair: look at my answer, they crossed. There is no rule of thumb, there is a mathematical convention to test for zero.Yes, but with a certain precision in mind.
Then you should also look at the SameValue functions in math, etc...... You are doing double work...No, because any angle (a.Size) must be returned. I just need to make sure that angles are rounded to a specific number of digits so that later on IF a.Size = 0, or IF a.Size = 90 returns true. ;)
-2.71050543121376108502E-0020 seems close enough to zero, isn't it? I.e. that's all the accuracy digits the compiler actually has, and it isn't even able to determine Pi/2 with greater accuracy without special effort.Well after a good night's sleep I managed to scroll my eyes to the right far enough to see it too, thank you.
E-20? How accurate do you want it to be?Oh not much, its just for screen coordinates so 2 decimal digits should suffice. I just did not look far enough for 4 hours!!
That's correct. Note that the math unit has IsZero functions for the case you need to determine if a float value should be considered equal to zero:Thank you sir, that will prove very useful in the near future.
function IsZero(const A: Single; Epsilon: Single): Boolean; overload; function IsZero(const A: Single): Boolean;inline; overload; {$ifdef FPC_HAS_TYPE_DOUBLE} function IsZero(const A: Double; Epsilon: Double): Boolean; overload; function IsZero(const A: Double): Boolean;inline; overload; {$endif FPC_HAS_TYPE_DOUBLE} {$ifdef FPC_HAS_TYPE_EXTENDED} function IsZero(const A: Extended; Epsilon: Extended): Boolean; overload; function IsZero(const A: Extended): Boolean;inline; overload; {$endif FPC_HAS_TYPE_EXTENDED}
Which gives using your slightly modified code:Code: [Select]Deg/Rad90: 1.5707963267948966E+000 FALSE
Cos -4.4807361612917013E-001: 6.1232339957367660E-017 TRUE
Sin 8.9399666360055796E-001: 1.0000000000000000E+000 FALSE
Did you check the Epsilon parameters in that set?..... <slightly amused, not yet grumpy.. 8-)>Yes I did. Already back then. What you're looking at is part of a general procedure spitting out angles at a given time T. So it is not a comparison right away. Rather, it's the level of accuracy that actually makes the given angles meaningful as a function of time. From there it is much simpler to test (because the difference is already computed) if a.Size is 0 or whatever depending on the request, than having to compare the angles again using SameValue getting either true or false, which would be completely meaningless. ;D