Predicting Sunrise and Sunset with HMG

Discuss anything else that does not suite other forums.

Moderator: Rathinagiri

Post Reply
User avatar
dhaine_adp
Posts: 457
Joined: Wed Aug 06, 2008 12:22 pm
Location: Manila, Philippines

Predicting Sunrise and Sunset with HMG

Post 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
Regards,

Danny
Manila, Philippines
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Predicting Sunrise and Sunset with HMG

Post 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
Viva INTERNATIONAL HMG :D
User avatar
dhaine_adp
Posts: 457
Joined: Wed Aug 06, 2008 12:22 pm
Location: Manila, Philippines

Re: Predicting Sunrise and Sunset with HMG

Post by dhaine_adp »

Thank you very much for the suggestion. I appreciate that.
Regards,

Danny
Manila, Philippines
Post Reply