当前位置: 首页>>代码示例>>Python>>正文


Python math.asin方法代码示例

本文整理汇总了Python中math.asin方法的典型用法代码示例。如果您正苦于以下问题:Python math.asin方法的具体用法?Python math.asin怎么用?Python math.asin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在math的用法示例。


在下文中一共展示了math.asin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: distance

# 需要导入模块: import math [as 别名]
# 或者: from math import asin [as 别名]
def distance(pointA, pointB):
	"""
	Calculate the great circle distance between two points 
	on the earth (specified in decimal degrees)

	http://stackoverflow.com/questions/15736995/how-can-i-quickly-estimate-the-distance-between-two-latitude-longitude-points
	"""
	# convert decimal degrees to radians 
	lon1, lat1, lon2, lat2 = map(math.radians, [pointA[1], pointA[0], pointB[1], pointB[0]])

	# haversine formula 
	dlon = lon2 - lon1 
	dlat = lat2 - lat1 
	a = math.sin(dlat/2)**2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlon/2)**2
	c = 2 * math.asin(math.sqrt(a)) 
	r = 3956  # Radius of earth in miles. Use 6371 for kilometers
	return c * r 
开发者ID:kevinabrandon,项目名称:AboveTustin,代码行数:19,代码来源:geomath.py

示例2: gcd

# 需要导入模块: import math [as 别名]
# 或者: from math import asin [as 别名]
def gcd(self, lon1, lat1, lon2, lat2):
        """
        Calculate the great circle distance between two points
        on the earth (specified in decimal degrees)
        """
        # convert decimal degrees to radians
        lon1, lat1, lon2, lat2 = map(math.radians, [lon1, lat1, lon2, lat2])

        # haversine formula
        dlon = lon2 - lon1
        dlat = lat2 - lat1
        a = math.sin(dlat / 2) ** 2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlon / 2) ** 2
        c = 2 * math.asin(math.sqrt(a))

        dis = E.R * c
        return dis 
开发者ID:kamalshadi,项目名称:Localization,代码行数:18,代码来源:geometry.py

示例3: get_euler

# 需要导入模块: import math [as 别名]
# 或者: from math import asin [as 别名]
def get_euler(self):
        t = self.x * self.y + self.z * self.w
        if t > 0.4999:
            heading = 2 * math.atan2(self.x, self.w)
            attitude = math.pi / 2
            bank = 0
        elif t < -0.4999:
            heading = -2 * math.atan2(self.x, self.w)
            attitude = -math.pi / 2
            bank = 0
        else:
            sqx = self.x ** 2
            sqy = self.y ** 2
            sqz = self.z ** 2
            heading = math.atan2(2 * self.y * self.w - 2 * self.x * self.z,
                                 1 - 2 * sqy - 2 * sqz)
            attitude = math.asin(2 * t)
            bank = math.atan2(2 * self.x * self.w - 2 * self.y * self.z,
                              1 - 2 * sqx - 2 * sqz)
        return heading, attitude, bank 
开发者ID:ladybug-tools,项目名称:honeybee,代码行数:22,代码来源:euclid.py

示例4: trig

# 需要导入模块: import math [as 别名]
# 或者: from math import asin [as 别名]
def trig(a, b=' '):
    if is_num(a) and isinstance(b, int):

        funcs = [math.sin, math.cos, math.tan,
                 math.asin, math.acos, math.atan,
                 math.degrees, math.radians,
                 math.sinh, math.cosh, math.tanh,
                 math.asinh, math.acosh, math.atanh]

        return funcs[b](a)

    if is_lst(a):
        width = max(len(row) for row in a)
        padded_matrix = [list(row) + (width - len(row)) * [b] for row in a]
        transpose = list(zip(*padded_matrix))
        if all(isinstance(row, str) for row in a) and isinstance(b, str):
            normalizer = ''.join
        else:
            normalizer = list
        norm_trans = [normalizer(padded_row) for padded_row in transpose]
        return norm_trans
    return unknown_types(trig, ".t", a, b) 
开发者ID:isaacg1,项目名称:pyth,代码行数:24,代码来源:macros.py

示例5: elevation_for

# 需要导入模块: import math [as 别名]
# 或者: from math import asin [as 别名]
def elevation_for(self, position):
        """Returns elevation to given position in radians

        calculation is made inline to have better performance
        """
        observer_pos_ecef = self.position_ecef
        object_coords_ecef = position

        rx = object_coords_ecef[0] - observer_pos_ecef[0]
        ry = object_coords_ecef[1] - observer_pos_ecef[1]
        rz = object_coords_ecef[2] - observer_pos_ecef[2]

        a, b, c = self._cached_elevation_calculation_data

        top_z = (a * rx) + (b * ry) + (c * rz)

        range_sat = sqrt((rx * rx) + (ry * ry) + (rz * rz))

        return asin(top_z / range_sat) 
开发者ID:satellogic,项目名称:orbit-predictor,代码行数:21,代码来源:locations.py

示例6: _haversine

# 需要导入模块: import math [as 别名]
# 或者: from math import asin [as 别名]
def _haversine(lon1, lat1, lon2, lat2):
    """
    Calculate the great circle distance between two points in m
    on the earth (specified in decimal degrees)
    http://stackoverflow.com/questions/15736995/how-can-i-
        quickly-estimate-the-distance-between-two-latitude-longitude-points
    """
    # convert decimal degrees to radians
    lon1, lat1, lon2, lat2 = list(map(radians, [lon1, lat1, lon2, lat2]))
    # haversine formula
    dlon = lon2 - lon1
    dlat = lat2 - lat1
    a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
    c = 2 * asin(sqrt(a))
    km = 6367 * c
    m = 1000. * km
    return m

############################################################################### 
开发者ID:CosmiQ,项目名称:apls,代码行数:21,代码来源:apls_utils.py

示例7: testAsinFunction

# 需要导入模块: import math [as 别名]
# 或者: from math import asin [as 别名]
def testAsinFunction(self):
        ma5 = MovingAverage(5, 'close')
        holder = Asin(ma5)

        sampleClose = np.sin(self.sampleClose)

        for i, close in enumerate(sampleClose):
            data = {'close': close}
            ma5.push(data)
            holder.push(data)

            expected = math.asin(ma5.result())
            calculated = holder.result()
            self.assertAlmostEqual(calculated, expected, 12, "at index {0:d}\n"
                                                             "expected:   {1:f}\n"
                                                             "calculated: {2:f}".format(i, expected, calculated)) 
开发者ID:alpha-miner,项目名称:Finance-Python,代码行数:18,代码来源:testAccumulatorsArithmetic.py

示例8: align_roll

# 需要导入模块: import math [as 别名]
# 或者: from math import asin [as 别名]
def align_roll( vec, vecz, tarz ):

        sine_roll = vec.normalized().dot(vecz.normalized().cross(tarz.normalized()))

        if 1 < abs(sine_roll):
            sine_roll /= abs(sine_roll)
            
        if 0 < vecz.dot( tarz ):
            return math.asin( sine_roll )
        
        elif 0 < sine_roll:
            return -math.asin( sine_roll ) + math.pi
        
        else:
            return -math.asin( sine_roll ) - math.pi

    ####################################################### 
开发者ID:Parik27,项目名称:DragonFF,代码行数:19,代码来源:dff_importer.py

示例9: angular_position

# 需要导入模块: import math [as 别名]
# 或者: from math import asin [as 别名]
def angular_position(texcoord):
    up = texcoord[0]
    v = texcoord[1]
    # correct for hemisphere
    if up>=0.5:
      u = 2.0*(up-0.5)
    else:
      u = 2.0*up

    # ignore points outside of circles
    if ((u-0.5)*(u-0.5) + (v-0.5)*(v-0.5))>0.25:
      return None, None

    # v: 0..1-> vp: -1..1
    phi = math.asin(2.0*(v-0.5))

    # u = math.cos(phi)*math.cos(theta)
    # u: 0..1 -> upp: -1..1
    u = 1.0-u
    theta = math.acos( 2.0*(u-0.5) / math.cos(phi) )

    if up<0.5:
       theta = theta-math.pi

    return (theta,phi) 
开发者ID:bhautikj,项目名称:vrProjector,代码行数:27,代码来源:SideBySideFisheyeProjection.py

示例10: find_angle_graph

# 需要导入模块: import math [as 别名]
# 或者: from math import asin [as 别名]
def find_angle_graph(velocity, vertical_velocity, interp=False):
    angle = []

    for i in range(len(velocity)):
        if velocity[i] == 0:
            angle.append(angle[-1])
        else:
            ratio = max(-1, min(vertical_velocity[i] / velocity[i], 1))
            angle.append(asin(ratio))

    angle = savgol_filter(angle, 5, 1)

    if interp:
        angle = savgol_filter(angle, 11, 1)
        return ss.medfilt(angle, kernel_size=7)

    return angle 
开发者ID:shahar603,项目名称:SpaceXtract,代码行数:19,代码来源:analyse_raw_telemetry.py

示例11: ypr_from_campos

# 需要导入模块: import math [as 别名]
# 或者: from math import asin [as 别名]
def ypr_from_campos(cx, cy, cz):
    camDist = math.sqrt(cx * cx + cy * cy + cz * cz)
    cx = cx / camDist
    cy = cy / camDist
    cz = cz / camDist
    t = math.sqrt(cx * cx + cy * cy)
    tx = cx / t
    ty = cy / t
    yaw = math.acos(tx)
    if ty > 0:
        yaw = 2 * math.pi - yaw

    roll = 0
    pitch = math.asin(cz)

    return yaw, pitch, roll 
开发者ID:eldar,项目名称:differentiable-point-clouds,代码行数:18,代码来源:euler.py

示例12: coord_distance

# 需要导入模块: import math [as 别名]
# 或者: from math import asin [as 别名]
def coord_distance(lat1, lon1, lat2, lon2):
    """
    Finds the distance between two pairs of latitude and longitude.
    :param lat1: Point 1 latitude.
    :param lon1: Point 1 longitude.
    :param lat2: Point two latitude.
    :param lon2: Point two longitude.
    :return: Kilometer distance.
    """
    lon1, lat1, lon2, lat2 = map(math.radians, [lon1, lat1, lon2, lat2])
    dlon = lon2 - lon1
    dlat = lat2 - lat1
    a = math.sin(dlat/2)**2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlon/2)**2
    c = 2 * math.asin(math.sqrt(a))
    km = 6367 * c
    return km 
开发者ID:VikParuchuri,项目名称:apartment-finder,代码行数:18,代码来源:util.py

示例13: new_color_pref

# 需要导入模块: import math [as 别名]
# 或者: from math import asin [as 别名]
def new_color_pref(old_pref, env_color):
    """
    Calculate new color pref with the formula below:
    new_color = sin(avg(asin(old_pref) + asin(env_color)))
    """
    me = math.asin(old_pref)
    env = math.asin(env_color)
    avg = np.average([me, env], weights=weightings)
    new_color = math.sin(avg)
    return new_color 
开发者ID:gcallah,项目名称:indras_net,代码行数:12,代码来源:fashion.py

示例14: latlngup_to_relxyz

# 需要导入模块: import math [as 别名]
# 或者: from math import asin [as 别名]
def latlngup_to_relxyz(c,l):
    # this converts WGS84 (lat,lng,alt) to a rotated ECEF frame
    # where the earth center is still at the origin
    # but (clat,clng,calt) has been rotated to lie on the positive X axis

    clat,clng,calt = c
    llat,llng,lalt = l

    # rotate by -clng around Z to put C on the X/Z plane
    # (this is easy to do while still in WGS84 coordinates)
    llng = llng - clng

    # find angle between XY plane and C
    cx,cy,cz = latlngup_to_ecef((clat,0,calt))
    a = math.atan2(cz,cx)
    
    # convert L to (rotated around Z) ECEF
    lx,ly,lz = latlngup_to_ecef((llat,llng,lalt))

    # rotate by -a around Y to put C on the X axis
    asin = math.sin(-a)
    acos = math.cos(-a)
    rx = lx * acos - lz * asin
    rz = lx * asin + lz * acos

    return (rx, ly, rz)

# calculate range, bearing, elevation from C to L 
开发者ID:mutability,项目名称:dump1090-tools,代码行数:30,代码来源:adsb-polar.py

示例15: range_bearing_elevation

# 需要导入模块: import math [as 别名]
# 或者: from math import asin [as 别名]
def range_bearing_elevation(c,l):
    # rotate C onto X axis
    crx, cry, crz = latlngup_to_relxyz(c,c)
    # rotate L in the same way
    lrx, lry, lrz = latlngup_to_relxyz(c,l)

    # Now we have cartesian coordinates with C on
    # the X axis with ground plane YZ and north along +Z.

    dx, dy, dz = lrx-crx, lry-cry, lrz-crz
    rng = math.sqrt(dx*dx + dy*dy + dz*dz)
    bearing = (360 + 90 - rtod(math.atan2(dz,dy))) % 360
    elev = rtod(math.asin(dx / rng))

    return (rng, bearing, elev) 
开发者ID:mutability,项目名称:dump1090-tools,代码行数:17,代码来源:adsb-polar.py


注:本文中的math.asin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。