Created
October 21, 2011 18:55
-
-
Save sash13/1304634 to your computer and use it in GitHub Desktop.
Расчет ТОЭ схем в Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import * | |
def toExpForm(a,s): | |
if a.real != 0: | |
real=sqrt(pow(a.real,2)+pow(a.imag,2)) | |
agle=degrees(atan(a.imag/a.real)) | |
else: | |
real=a.imag | |
agle=90.0 if a.imag>0 else -90.0 | |
print (s+'='+str(round(a.real,3))+'','' if a.imag<0 else '+', str(round(a.imag,3))+'='+str(round(real,3)) + '∠' + str(round(agle,3))) | |
def tz(a,b,c): | |
return (a*c)/(a+b+c) , (b*c)/(a+b+c), (a*b)/(a+b+c) | |
a=4+3j | |
b=3+6j | |
c=7-3j | |
e=tz(a,b,c) | |
toExpForm(e[0],'Zao') | |
toExpForm(e[1],'Zbo') | |
toExpForm(e[2],'Zco') | |
toExpForm(a,'Za') | |
toExpForm(b,'Zb') | |
toExpForm(c,'Zc') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment