Page 1 of 1

Predicting Sunrise and Sunset with HMG

Posted: Mon Oct 13, 2008 5:37 am
by dhaine_adp
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

Re: Predicting Sunrise and Sunset with HMG

Posted: Mon Oct 20, 2008 1:56 am
by esgici
dhaine_adp wrote: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
Hi Danny

HMG is only a GUI library based on Harbour Compiler and all math ( including trigonometrics of course) functions are from Harbour. Perhaps you have ask your questions to Harbour news group.

Harbour main page is :

http://www.harbour-project.org/

and mailing list info is :

http://www.harbour-project.org/mailinglist.htm

Regards

--

esgici

Re: Predicting Sunrise and Sunset with HMG

Posted: Wed Oct 22, 2008 12:48 pm
by dhaine_adp
Thank you very much for the suggestion. I appreciate that.