0x686169 - 9 months ago 43

Objective-C Question

`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 Source

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