Skip to content

Instantly share code, notes, and snippets.

@baryluk
Created April 26, 2020 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baryluk/ca21490d94cd4286ce92849bbb693032 to your computer and use it in GitHub Desktop.
Save baryluk/ca21490d94cd4286ce92849bbb693032 to your computer and use it in GitHub Desktop.
Divide a full circle into equal angles.
#!/usr/bin/env python3
# Divides a full circle into equal angles.
import math
for N in range(2, 27):
print(f"{N} divider:")
for i in range(N):
alpha = 360.0 * i / N
deg = math.trunc(alpha)
remaining_deg = alpha - float(deg)
assert remaining_deg < 1.0
minutes = math.trunc(remaining_deg * 60.0)
remaining_minutes = remaining_deg * 60.0 - minutes
assert remaining_minutes < 1.0
seconds = remaining_minutes * 60.0
print("{:2} {:3}°{:02}′{:05.2f}″ # {:12.9f}".format(i, deg, minutes, seconds, alpha))
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment