简体   繁体   English

小时分钟秒针之间的角度

[英]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 时间11:54:29这是我的结果

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

Your angleminute calculation is wrong. 您的angleminute计算错误。 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. 它每分钟移动6度,但每秒钟是1/60分钟,因此每秒移动1/60 * 6度,而不是1/60度。

Also, what are the types of minutes , seconds , hour ? 还有什么类型的minutessecondshour If they're int s, then there's another problem: in the calculation of anglehour , (seconds/60) will be integer division, and will come out as 0 . 如果它们是int ,那么还有另一个问题:在计算anglehour(seconds/60)将是整数除法,并将出现为0 You need (seconds/60.0) . 你需要(seconds/60.0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM