Browse Source

refactoring: used a comment to explain the shifting of the curve as I see no way to make that clear with variable names. Furthermore, used the already implemented basic calculating operations to reduce duplication of code

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

6
src/main/py/trigonometry.py

@ -16,9 +16,9 @@ def rad2deg(radNumber):
def sin_approx_bhaskara(radNumber):
shallFlipTheResult = 0
shallFlipTheResult = 0 #the bhaskara function can only be used between zero and pi. For the rest of the sin period I simply mirrored the first arch of the curve to match the actual sine wave
if math.pi < radNumber < 2 * math.pi:
radNumber -= math.pi
radNumber = subract(math.pi, radNumber)
shallFlipTheResult = 1
@ -33,5 +33,5 @@ def sin_approx_bhaskara(radNumber):
sinResult = divide(num, subract(denomFrag2, denomFrag1))
if(shallFlipTheResult == 1):
return sinResult * -1
return multiply(sinResult, -1)
return sinResult
Loading…
Cancel
Save