- Inlägg: 1877
- Tack mottaget: 470
Fluxio
Elbranschens mötesplats
Be Logga in eller Skapa ett konto ansluta till konversationen.
Python 3.2 (r32:88445, Feb 20 2011, 21:29:02)[MSC v.1500 32 bit (Intel)] on win32
>>> from math import *
>>> from cmath import rect, phase, polar
>>> rad = radians
>>> deg = degrees
>>>
>>> I1 = 10; I2 = 8; I3 = 5
>>> c1 = I1 * complex(cos(rad(0)),sin(rad(0)))
>>> c2 = I2 * complex(cos(rad(-120)),sin(rad(-120)))
>>> c3 = I3 * complex(cos(rad(120)),sin(rad(120)))
>>> s = c1+c2+c3
>>> print(c1,c2,c3,s)
(10+0j) (-4-7j) (-2.5+4.3j) (3.5-2.6j)
>>> polar(s)
(4.4, -0.64)
>>> deg(-0.64)
-37
>>> polar(rect(I1, 0) + rect(I2, rad(-120)) + rect(I3, rad(120)))
(4.4, -0.64)def dpolar(val):
"Like cmath.polar but returns the angle in degrees instead of radians."
rpolar = polar(val)
return (rpolar[0], degrees(rpolar[1]))
def drect(val, deg):
"Like cmath.rect but angle is given in degrees instead of radians."
return rect(val, radians(deg))
>>> dpolar(drect(I1, 0) + drect(I2, -120) + drect(I3, 120))
(4.4, -37)Be Logga in eller Skapa ett konto ansluta till konversationen.
Be Logga in eller Skapa ett konto ansluta till konversationen.
Be Logga in eller Skapa ett konto ansluta till konversationen.
Be Logga in eller Skapa ett konto ansluta till konversationen.
Be Logga in eller Skapa ett konto ansluta till konversationen.
Be Logga in eller Skapa ett konto ansluta till konversationen.