예제 #1
0
 def t_obside(cls, high, base_max, base_min):
     from math import sqrt
     from math import pow as pw
     high = float(high)
     base_max = float(base_max)
     base_min = float(base_min)
     return sqrt(pw(high, 2) + pw((base_max - base_min), 2))
예제 #2
0
def dc(s, e):
    r = float("3.141592653589793238462643383279502884197169399375105820974944"
              "592307816406286208998628034825342117067982148086513282306647"
              "093844609550582231725359408128481117450284102701938521105559"
              "644622948954930381964428810975665933446128475648233786783165"
              "271201909145648566923460348610454326648213393607260249141273"
              "724587006606315588174881520920962829254091715364367892590360"
              "011330530548820466521384146951941511609433057270365759591953"
              "092186117381932611793105118548074462379962749567351885752724"
              "891227938183011949129833673362440656643086021394946395224737"
              "190702179860943702770539217176293176752384674818467669405132"
              "000568127145263560827785771342757789609173637178721468440901"
              "224953430146549585371050792279689258923542019956112129021960"
              "864034418159813629774771309960518707211349999998372978049951"
              "059731732816096318595024459455346908302642522308253344685035"
              "261931188171010003137838752886587533208381420617177669147303"
              "598253490428755468731159562863882353787593751957781857780532"
              "1712268066130019278766111959092164201989") / 180.
    r_start = (s[0] * r, s[1] * r)
    r_end = (e[0] * r, e[1] * r)
    cl1 = co(r_start[0])
    cl2 = co(r_end[0])
    sl1 = si(r_start[0])
    sl2 = si(r_end[0])
    dt = r_end[1] - r_start[1]
    cdt = co(dt)
    sdt = si(dt)
    return int(at(sq(pw(cl2 * sdt, 2) + pw(cl1 * sl2 - sl1 * cl2 * cdt, 2)),
                  sl1 * sl2 + cl1 * cl2 * cdt) * 6372795)
예제 #3
0
def dc(s, e):
    r = float("3.141592653589793238462643383279502884197169399375105820974944"
              "592307816406286208998628034825342117067982148086513282306647"
              "093844609550582231725359408128481117450284102701938521105559"
              "644622948954930381964428810975665933446128475648233786783165"
              "271201909145648566923460348610454326648213393607260249141273"
              "724587006606315588174881520920962829254091715364367892590360"
              "011330530548820466521384146951941511609433057270365759591953"
              "092186117381932611793105118548074462379962749567351885752724"
              "891227938183011949129833673362440656643086021394946395224737"
              "190702179860943702770539217176293176752384674818467669405132"
              "000568127145263560827785771342757789609173637178721468440901"
              "224953430146549585371050792279689258923542019956112129021960"
              "864034418159813629774771309960518707211349999998372978049951"
              "059731732816096318595024459455346908302642522308253344685035"
              "261931188171010003137838752886587533208381420617177669147303"
              "598253490428755468731159562863882353787593751957781857780532"
              "1712268066130019278766111959092164201989") / 180.
    r_start = (s[0] * r, s[1] * r)
    r_end = (e[0] * r, e[1] * r)
    cl1 = co(r_start[0])
    cl2 = co(r_end[0])
    sl1 = si(r_start[0])
    sl2 = si(r_end[0])
    dt = r_end[1] - r_start[1]
    cdt = co(dt)
    sdt = si(dt)
    return int(
        at(sq(pw(cl2 * sdt, 2) + pw(cl1 * sl2 - sl1 * cl2 * cdt, 2)),
           sl1 * sl2 + cl1 * cl2 * cdt) * 6372795)
예제 #4
0
 def pow(cls, num1, num2):
     if isinstance(num1, Float) or isinstance(num1, Int):
         num1 = num1.num
     if isinstance(num2, Float) or isinstance(num2, Int):
         num2 = num2.num
     from math import pow as pw
     num1 = float(num1)
     num2 = float(num2)
     return pw(num1, num2)
예제 #5
0
    def get_number_of_ipv6_addresses(self):
        count = 0

        # For each prefix entry, the number of owned addresses is 2^(128bits - prefix length)
        for prefix in self._ip_prefixes:
            if prefix[2]:
                count += pw(2, 128 - prefix[1])

        return count
예제 #6
0
    def delta(cls, coeffxx, coeffx, term):
        if isinstance(coeffxx, Float) or isinstance(coeffxx, Int):
            coeffxx = coeffxx.num
        if isinstance(coeffx, Float) or isinstance(coeffx, Int):
            coeffx = coeffx.num
        if isinstance(term, Float) or isinstance(term, Int):
            term = term.num

        from math import pow as pw
        DELTA = float(pw(coeffx, 2) - (4 * term * coeffxx))
        return DELTA
예제 #7
0
#example of import

#basic import import [module] 
import math
print("basic import")
print(math.pow(2,3))
 
#can be define custom module name 
import math as mh
print("import as")
print(mh.pow(2,4))

#can be specify function or all function (*) in module
#from [module] import [specify function or *(all function can use)] 
#from math import pow,log,..[some another function in math]
from math import pow
print("import specify type")
print(pow(2,2))

#advance import
#from math import pow as pw,log as lg..[some another function in math]
from math import pow as pw
print("advance type")
print(pw(2,5))

module = __import__('math')
func = getattr(module,'pow')
func()
예제 #8
0
 def c_area(cls, radius):
     radius = float(radius)
     from math import pow as pw
     return cls.PI * pw(radius, 2)
예제 #9
0
 def diagonal(cls, side1, side2):
     side1 = float(side1)
     side2 = float(side2)
     from math import sqrt
     from math import pow as pw
     return sqrt((pw(side1, 2)) + (pw(side2, 2)))
예제 #10
0
 def t_diagonalmin(cls, high, base_min):
     base_min = float(base_min)
     high = float(high)
     from math import sqrt
     from math import pow as pw
     return sqrt(pw(high, 2) + pw(base_min, 2))
예제 #11
0
 def t_diagonalmax(cls, high, base_max):
     base_max = float(base_max)
     high = float(high)
     from math import sqrt
     from math import pow as pw
     return sqrt(pw(high, 2) + pw(base_max, 2))
예제 #12
0
import math
print(math.ceil(2.24))
print(math.floor(2.24))
print(math.pw(2, 10))