Created
May 22, 2019 16:06
-
-
Save mressler/645a0e4be4a3e3cb66fa6a0c6fe70c44 to your computer and use it in GitHub Desktop.
Spin Axis to Spin Direction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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