0x686169 0x686169 - 19 days ago 6
Objective-C Question

How to calculate hour value from degree?

0 Degree = 3 o'clock
90 Degree = 0 o'clock
180 Degree = 9 0 o'clock


so can we have a expression to convert from Degree to clock hour in objective-C?

Answer

This is a very basic maths problem.

degrees = ((3 - hour) % 12) * 30
  • When hour = 3 => 0
  • When hour = 9 => 180
  • When hour = 6 => 270
  • When hour = 0 => 90

To get the hour just reverse the problem...

(-degrees / 30 + 3) % 12 = hour

You can try this on Wolfram Alpha

Comments