From 090afdd4517ed2108a76eb9caea35dc5bec0d2d4 Mon Sep 17 00:00:00 2001 From: adit098 Date: Mon, 19 Oct 2020 22:29:03 +0530 Subject: [PATCH] fix #251 --- mathgenerator/funcs/__init__.py | 3 ++- mathgenerator/funcs/complexToPolarFunc.py | 13 +++++++++++++ mathgenerator/mathgen.py | 3 ++- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 mathgenerator/funcs/complexToPolarFunc.py diff --git a/mathgenerator/funcs/__init__.py b/mathgenerator/funcs/__init__.py index d9e880a..c4aa137 100644 --- a/mathgenerator/funcs/__init__.py +++ b/mathgenerator/funcs/__init__.py @@ -72,4 +72,5 @@ from .geomProgrFunc import * from .geometricMeanFunc import * from .harmonicMeanFunc import * from .DegreeToRadian import * -from .DecimalToOctal import * \ No newline at end of file +from .DecimalToOctal import * +from .complexToPolarFunc import * \ No newline at end of file diff --git a/mathgenerator/funcs/complexToPolarFunc.py b/mathgenerator/funcs/complexToPolarFunc.py new file mode 100644 index 0000000..ddc86ff --- /dev/null +++ b/mathgenerator/funcs/complexToPolarFunc.py @@ -0,0 +1,13 @@ +from .__init__ import * + +def polar(minRealImaginaryNum = -20, maxRealImaginaryNum = 20): + num = complex(random.randint(minRealImaginaryNum, maxRealImaginaryNum), random.randint(minRealImaginaryNum, maxRealImaginaryNum)) + a= num.real + b= num.imag + r = round(math.hypot(a,b), 2) + theta = round(math.atan2(b,a), 2) + plr = str(r) + "exp(i" + str(theta) + ")" + problem = f"rexp(itheta) = " + solution = plr + return problem, solution + \ No newline at end of file diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 2d2697d..5701317 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -160,4 +160,5 @@ decimalToHexadecimal = Generator("Decimal to Hexadecimal", 68, "Hexadecimal of a=", "b", DecimalToHexFunc) degreeToRadian = Generator("Degree To Radian", 69, "Radian of angle=", "radian", DegreeToRadian) decimalToOctal = Generator("Decimal to Octal", 70, - "Octal of a=", "b", DecimalToOctalFunc) \ No newline at end of file + "Octal of a=", "b", DecimalToOctalFunc) +complexToPolar = Generator("Complex To Polar Form", 71, "rexp(itheta) = ", "plr", complexToPolarFunc) \ No newline at end of file