user3564573
user3564573

Reputation: 700

angle between hour minute second hands

I am writing a program to calculate the angle between the hour&min hand, hour&sec, minute&second.

I wrote my code but no matter how much I change my calculations I still can't get the answer that this paper wants..

I used a double

//I did this to calculate the minute angle precisely since I assume 
//the second hand is also moving and it affects 1degree when it moves to 60..
angleminute=((6.0*minutes)+((1/60.0)*seconds)); 

//Also this to calculate the hour angle, the normal formula is 0.5*minutes
//but i also added the "seconds/60" for more accuracy
anglehour=((30.0*hour12)+(0.5*((seconds/60)+minutes)))

anglesecond=(6.0*seconds) //this is to calculate the second hand angle...

Now when i find the difference between these angles i get different results...

For time 11:54:29 here are my results

Hour-minute= 32.52
Minute-second= 150.48
Second-hour=177.00

But the expected results are:

Hour-minute=30.34
Minute-second= 152.90
Second-hour=176.76

How is he getting those results?? I have also tried using the normal method but still can't get the same results. Many formulas but still can't get the same answers...

angleminute=6*minutes

anglehour=30*hour+0.5*minutes

anglesecond=6*seconds

Upvotes: 1

Views: 5013

Answers (1)

chiastic-security
chiastic-security

Reputation: 20520

Your angleminute calculation is wrong. It does move 6 degrees for each minute, but each second is 1/60 of a minute, so for each second it moves 1/60 * 6 degrees, not 1/60 degrees.

Also, what are the types of minutes, seconds, hour? If they're ints, then there's another problem: in the calculation of anglehour, (seconds/60) will be integer division, and will come out as 0. You need (seconds/60.0).

Upvotes: 3

Related Questions