Skip to content

Instantly share code, notes, and snippets.

@vindard
Last active January 3, 2020 19:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vindard/24a3da1a631562d19a665618921c916b to your computer and use it in GitHub Desktop.
Save vindard/24a3da1a631562d19a665618921c916b to your computer and use it in GitHub Desktop.
Function that returns fixed intervals in degrees for one rotation of a circle
from math import sin, pi, degrees, radians
def print_angles(step=8, rad_shift=0, deg_shift=0):
shift = rad_shift or radians(deg_shift)
for i in range(step + 1):
radians_in_circle = 2*pi
degrees_in_circle = 360
phase_in_r = radians_in_circle * (i/step)
phase_in_d = degrees_in_circle * (i/step)
# assert phase_in_r == radians(phase_in_d)
sine = sin(phase_in_r + shift)
shift_str = f"+ {degrees(shift)}°" if shift else ""
print(f"Phase: {str(round(phase_in_d, 1))+'°':<6s}{shift_str} | sin:{round(sine, 4)}")
as_degrees = 180 * sine
print('>', round(as_degrees, 2), '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment