Browse Source

refactoring: improved readability of sin approx function by splitting the bhaskara formula into multiple lines as well as using the already implemented functions for basic calculation functions

remotes/origin/feature/feature-trigonometry
fdai7764 11 months ago
parent
commit
6b1e26dc3e
  1. 12
      src/main/py/trigonometry.py

12
src/main/py/trigonometry.py

@ -15,6 +15,12 @@ def rad2deg(radNumber):
return (radNumber * 180) / math.pi return (radNumber * 180) / math.pi
def sin_approx_bhaskara(radNumber): def sin_approx_bhaskara(radNumber):
num = 16 * radNumber * (math.pi - radNumber)
denom = 5 * math.pow(math.pi, 2) - 4 * radNumber * (math.pi - radNumber)
return num/denom
num = multiply(16, radNumber)
num = multiply(num, subract(radNumber, math.pi))
denomFrag1 = multiply(5, math.pow(math.pi, 2))
denomFrag2 = subract(radNumber, math.pi)
denomFrag2 = multiply(denomFrag2, radNumber)
denomFrag2 = multiply(denomFrag2, 4)
return divide(num, subract(denomFrag2, denomFrag1))
Loading…
Cancel
Save