Last active
January 3, 2020 19:25
-
-
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
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
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