From 6b1e26dc3e40a4fde18dd63f330b0c9e7d9e883c Mon Sep 17 00:00:00 2001 From: fdai7764 Date: Sun, 28 Jan 2024 13:52:16 +0100 Subject: [PATCH] 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 --- src/main/py/trigonometry.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/py/trigonometry.py b/src/main/py/trigonometry.py index ae1aeb8..282137b 100644 --- a/src/main/py/trigonometry.py +++ b/src/main/py/trigonometry.py @@ -15,6 +15,12 @@ def rad2deg(radNumber): return (radNumber * 180) / math.pi 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 \ No newline at end of file + 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)) \ No newline at end of file