Skip to content

Instantly share code, notes, and snippets.

@mressler
Created May 22, 2019 16:06
Show Gist options
  • Save mressler/645a0e4be4a3e3cb66fa6a0c6fe70c44 to your computer and use it in GitHub Desktop.
Save mressler/645a0e4be4a3e3cb66fa6a0c6fe70c44 to your computer and use it in GitHub Desktop.
Spin Axis to Spin Direction
def map_to_clock(spin_axis):
sp_x = spin_axis[0]
sp_z = spin_axis[2]
angle = np.arctan2(sp_z, sp_x)
angle_deg = angle / np.pi * 180
angle_clock = -angle_deg / 30.0 + 3.0
if angle_clock < 0:
angle_clock += 12
hour = int(angle_clock)
minute = int((angle_clock - hour) * 60)
return hour, minute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment