Predicting Sunrise and Sunset with HMG
Posted: Mon Oct 13, 2008 5:37 am
Good day everyone,
I have ported a routine from Java script to harbour regarding sunrise/sunset prediction. As much as possible I used the same variables but when I run the routine, the result does not mach the prediction made from the original routine. Well it could be my mistake or is there any problem with Harbour Trigonometric function?
Once I received the permission of the javascript author, I will post the ported code to HMG from javascript. For the time being I was trying to sort out what went wrong with habour math functions.
A code snippet look like's this:
Javascript:
obliq := 23.4391666666667 - 1.30041666666666E-02 * t - 0.000000163888888 * t * t + 5.03611111111E-08 * t * t * t
sunra := Degrees( ATAN2( COS( OBLIQ) * SIN( al ), COS( al ) ) ) // Sun's Right Ascension
HMG:
obliq := 23.4391666666667 - 1.30041666666666^-02 * t - 0.000000163888888 * t * t + ; 5.03611111111^-08 * t * t * t
sunra := Degrees( ATN2( COS( OBLIQ) * SIN( al ), COS( al ) ) ) // Sun's Right Ascension
Actually, HMG produces different result, maybe perhaps I should need to break-down the calculation to Harbour. Maybe the precedence of operation is handled differently. Patience and time is needed to troubleshoot this problem, but if all else fails, I would try to used the #pragma and use c code but I think they would be the same since during compilation all the codes is translated to c already.
I posted this maybe some of you out there have encounter this problem?
- Danny
I have ported a routine from Java script to harbour regarding sunrise/sunset prediction. As much as possible I used the same variables but when I run the routine, the result does not mach the prediction made from the original routine. Well it could be my mistake or is there any problem with Harbour Trigonometric function?
Once I received the permission of the javascript author, I will post the ported code to HMG from javascript. For the time being I was trying to sort out what went wrong with habour math functions.
A code snippet look like's this:
Javascript:
obliq := 23.4391666666667 - 1.30041666666666E-02 * t - 0.000000163888888 * t * t + 5.03611111111E-08 * t * t * t
sunra := Degrees( ATAN2( COS( OBLIQ) * SIN( al ), COS( al ) ) ) // Sun's Right Ascension
HMG:
obliq := 23.4391666666667 - 1.30041666666666^-02 * t - 0.000000163888888 * t * t + ; 5.03611111111^-08 * t * t * t
sunra := Degrees( ATN2( COS( OBLIQ) * SIN( al ), COS( al ) ) ) // Sun's Right Ascension
Actually, HMG produces different result, maybe perhaps I should need to break-down the calculation to Harbour. Maybe the precedence of operation is handled differently. Patience and time is needed to troubleshoot this problem, but if all else fails, I would try to used the #pragma and use c code but I think they would be the same since during compilation all the codes is translated to c already.
I posted this maybe some of you out there have encounter this problem?
- Danny