mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
complex to polar updates
This commit is contained in:
@@ -2,7 +2,6 @@ import random
|
||||
import math
|
||||
import fractions
|
||||
|
||||
|
||||
from ..__init__ import *
|
||||
|
||||
from .addition import *
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
from .__init__ import *
|
||||
|
||||
def complexToPolarFunc(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
|
||||
|
||||
|
||||
complex_to_polar = Generator("Complex To Polar Form", 92, "rexp(itheta) = ", "plr", complexToPolarFunc)
|
||||
18
mathgenerator/funcs/complex_to_polar.py
Normal file
18
mathgenerator/funcs/complex_to_polar.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from .__init__ import *
|
||||
|
||||
|
||||
def complexToPolarFunc(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
|
||||
|
||||
|
||||
complex_to_polar = Generator("Complex To Polar Form", 92,
|
||||
"rexp(itheta) = ", "plr", complexToPolarFunc)
|
||||
Reference in New Issue
Block a user