# Clock problem

Pradeep bhatt
Ranch Hand
Posts: 8933
Find formula to compute angle between hour hand and minute hand.

fred rosenberger
lowercase baba
Bartender
Posts: 12203
35
it's trivial to figure out each hands postion, given the time. you can calculate the angle around from 12:00:00.
if you know each hands postion, the angle between them is the difference.

Pradeep bhatt
Ranch Hand
Posts: 8933
but how?

Jim Yingst
Wanderer
Sheriff
Posts: 18671
More info available here.

Arjun Shastry
Ranch Hand
Posts: 1899
1
Originally posted by Pradeep Bhat:
but how?

Input is some time ,like 5:37.How much is angular movement of hour hand from position 12? 30*5 = 150 degrees + 15 degrees(bcos of those first 30 minutes) = 165 degrees.
Now hour hand moves by 30 degrees when minutes hand moves by 360 degrees,right? so for 1 minute,30/360-->(1/12) degrees,correct?So for 7 minutes 7/12 degrees.So total angular movement of hour hand is 165+(7/12) degrees.
Now angular movement of minute hand is 180+30+12 = 222 degrees.
I hope now you can make a formula out of it.
Has anybody has used Theodolite for calculating the angle and the distance between the two objects on a surface?
[ November 25, 2003: Message edited by: Capablanca Kepler ]

Pravin Mhaske
Greenhorn
Posts: 2
Originally posted by Pradeep Bhat:
Find formula to compute angle between hour hand and minute hand.

angle = 30H - 5.5M
Example, at 2:35, angle = 30*2 - 5.5*35 = 60 - 192.5 = 132.5 degrees (ignore the sign)
[ January 17, 2005: Message edited by: Pravin Mhaske ]

P. Sagdeo
Ranch Hand
Posts: 67
I think that what has been posted so far is too complicated. All that is needed is to know that 1 minute should be 6 degrees (360 degrees in 60 minutes, so that follows). So when you have the minutes, to compute the degrees, you simply do:

Hours can be either much easier or a little harder. First the easy way:
Since you know there are 12 hours in 360 degrees, the difference between hours is simple 360/12 = 30 degrees. So the code is:

However, if you wanted to be like a real clock, where the hour hand slowly moves continuously over the hour, then you would have to take into account the amount of minutes that have passed. To do this, I would simply find the decimal between the hours (i.e. 6:30 would be 6.5) and then find the degrees. The code then would be something like:

Now that we have the two degree values, we can subtract their values. This can be done like:

Layne Lund
Ranch Hand
Posts: 3061
If minutes is an int, then

will not give the correct result as described above. This line of code should be changed to

in order to avoid integer division.

Layne

Pravin Mhaske
Greenhorn
Posts: 2
Hi P. Sangdeo, Why do you think your answer is not complicated? I don't understand 'C' or whatever the language is Would you pls give a simple mathematical formula? Also, can you please prove that the formula you've posted gives correct answer with an example? You may please refer to the above post of mine for the example.