From 7e5d74ffa609b19c3acfbf970e6581e8058fba7c Mon Sep 17 00:00:00 2001 From: fdai7764 Date: Sun, 28 Jan 2024 14:22:27 +0100 Subject: [PATCH] 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 --- src/main/py/trigonometry.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/py/trigonometry.py b/src/main/py/trigonometry.py index 1043118..12107e2 100644 --- a/src/main/py/trigonometry.py +++ b/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 \ No newline at end of file