2 """ If an angle (in degrees) is not within 360, then this cuts it down to within 0-360 """
9 """ If an angle (in radians) is not within 2Pi, then this cuts it down to within 0-2Pi """
10 angle = angle % (pi*2)
15def dist(ax, ay, bx, by):
16 return sqrt(((bx - ax)**2) + ((by - ay)**2))
28def constrainToUpperQuadrants(ang, deg=False):
35 """ Raise num to exp, but if num starts off as negative, make the result negative """
37 return (num**exp) * (-1
if neg
else 1)
39def round2(num, digits=3, tostr=True, scinot:int=
False):
41 from sympy.core.evalf
import N
as evalf
47 ans = round(num, digits)
49 return '{:1f}'.format(num)
if tostr
else num
52 ensureImported(
'scinot', _as=
"scinotation")
54 raise TypeError(
"Can't round using scientific notation and not return a string")
55 return scinotation.format(ans, scinot)
57 return '{:1f}'.format(ans)
if tostr
else ans
59def largest_square(n, sideLen=1):
60 """ Take the square root of the input number
61 and round down to the nearest integer
63 side = int(n ** (sideLen/2))