ANGLE BETWEEN HOUR AND MINUTE HANDS
namespace AngleBetweenHrAndMinHands
{
/*Hour hand moves 360 degree in 12 hours (i.e 12 * 60 = 720 minutes) So 0.5 degree per minute.
* Minute hand moves 360 degree in 60 minutes, so 6 degrees per minute.
* So given a time, hr hand's angle from 12 would be (((h*60)+m)*0.5)
* similarly min hand's angle from 12 would be (m*6)
* Now take the absolute diff between the 2
*/
class Program
{
static void Main(string[] args)
{
int hour = 3;
int min = 40;
float hrhandangle = ((hour * 60) + min) * 0.5F;
hrhandangle = hrhandangle % 360;
float Minhandangle = min * 6;
float AngleDiff = Math.Abs(hrhandangle - Minhandangle);
Console.WriteLine(AngleDiff);
}
}
}
No comments:
Post a Comment