This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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 ]
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:
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.