-
-
Save NicolaM94/6e0e0ffa41a3da006cd011e6f783163d to your computer and use it in GitHub Desktop.
Clock position and hands angles degree
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
class ClockPosition (): | |
def __init__(self,hh,mm): | |
self.hh = hh | |
self.mm = mm | |
self.mmdegree = self.mm * 6 | |
self.hhdegree = (self.hh % 12) * 30 + self.mm * 0.5 | |
def calculateInternalAngle (self): | |
# Calculates the absolute value of the angle | |
angleOne = self.mmdegree - self.hhdegree | |
if angleOne < 0: | |
angleOne = angleOne * (-1) | |
# Calculates the other face of the angle | |
angleTwo = 360 - angleOne | |
# Returns the smallest one | |
if angleOne < angleTwo: | |
return angleOne | |
return angleTwo | |
with open("clockpositions.txt","w") as file: | |
for hh in range(0,24): | |
for mm in range(0,60): | |
ck = ClockPosition(hh,mm).calculateInternalAngle() | |
file.write(f"HH: {hh}\tMM: {mm}\tAngle: {ck}\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment