add lesson6

This commit is contained in:
Motiejus Jakštys
2019-11-28 17:51:15 +02:00
parent 7d1de6304d
commit 5574e67ff4
4 changed files with 47 additions and 3 deletions

28
Karto/lesson6/cnt.py Executable file
View File

@@ -0,0 +1,28 @@
#!/usr/bin/env python3
from math import cos, tan, asin, sqrt
from deg import deg
L12 = 396.942
B12 = deg('40-19-21.0')
D12 = L12 * cos(B12)
L23 = 421.159
H23 = 25.771
B23 = asin(H23 / L23)
D23 = sqrt(L23**2 - H23**2)
L34 = 294.911
B34 = deg('31-56-51.2')
D34 = L34 * cos(B34)
H41 = 77.226
B41 = deg('38-45-7.8')
D41 = H41 / tan(B41)
print("""
D12 = %4.3f""" % D12 + """
D23 = %4.3f""" % D23 + """
D34 = %4.3f""" % D34 + """
D41 = %4.3f""" % D41 + """
Sum = %4.3f""" % (D12 + D23 + D34 + D41) + """
""")

12
Karto/lesson6/deg.py Normal file
View File

@@ -0,0 +1,12 @@
from math import pi
def deg(inp):
"""return angle in radians"""
if isinstance(inp, str) and '-' in inp:
deg, mm, ss = inp.split('-')
ddeg, dmm, dss = float(deg), float(mm), float(ss)
deg = ddeg + dmm/60 + dss/3600
else:
deg = float(instr)
return deg * pi / 180