Difficult-Rocket/libs/P_C.py

77 lines
1.6 KiB
Python
Raw Normal View History

2020-12-21 21:43:01 +08:00
"""
writen by shenjackyuanjie
mail: 3695888@qq.com
"""
import libs
import math
2020-12-21 21:48:52 +08:00
def P_C_M(A, B): # stand for Physics Calculation multiple
2020-12-21 21:43:01 +08:00
"""
formats:
A & B list format:docs.basic_config.json:basic_number
"""
C = [0.0, 1, [], []]
2020-12-21 22:53:34 +08:00
Float = float(A[0] * B[0])
Int = int(A[1] + B[1])
2020-12-21 22:11:49 +08:00
if Float >= 10:
Float /= 10
Int += 1
elif Float <= 0.01:
Float *= 10
Int -= 1
else:
2020-12-21 22:53:34 +08:00
pass
2020-12-22 06:36:02 +08:00
Unit1, Unit2 = A[2] + B[2], []
2020-12-21 21:59:36 +08:00
for unit in B[3]:
2020-12-22 06:36:02 +08:00
if unit in Unit1:
2020-12-22 06:12:38 +08:00
Unit1.remove(unit)
2020-12-21 21:59:36 +08:00
else:
Unit2.append(unit)
2020-12-21 22:48:43 +08:00
if Unit1 == None:
Unit1 = []
2020-12-22 06:12:38 +08:00
for unit in Unit2:
if unit in Unit1:
Unit1.remove(unit)
Unit2.remove(unit)
else:
pass
2020-12-21 21:59:36 +08:00
C = [Float, Int, Unit1, Unit2]
2020-12-21 21:48:52 +08:00
return C
def P_C_D(A, B): # stand for Physics Calculation divide
"""
formats:
A & B list format:docs.basic_config.json:basic_number
"""
2020-12-22 06:36:02 +08:00
B[2], B[3] = B[3], B[2]
2020-12-21 21:48:52 +08:00
C = [0.0, 1, [], []]
2020-12-21 22:53:34 +08:00
Float = float(A[0] / B[0])
Int = int(A[1] - B[1])
2020-12-21 22:48:43 +08:00
if Float >= 10:
Float /= 10
Int += 1
elif Float <= 0.01:
Float *= 10
Int -= 1
else:
2020-12-21 22:53:34 +08:00
pass
2020-12-22 06:36:02 +08:00
Unit1, Unit2 = A[2] + B[2], []
for unit in B[3]:
if unit in Unit1:
2020-12-22 06:12:38 +08:00
Unit1.remove(unit)
2020-12-21 22:48:43 +08:00
else:
Unit2.append(unit)
if Unit1 == None:
Unit1 = []
2020-12-22 06:12:38 +08:00
for unit in Unit2:
if unit in Unit1:
Unit1.remove(unit)
Unit2.remove(unit)
else:
pass
2020-12-21 22:48:43 +08:00
C = [Float, Int, Unit1, Unit2]
2020-12-21 21:48:52 +08:00
return C