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


Python math.atan方法代码示例

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


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

示例1: opposing_angle

# 需要导入模块: import math [as 别名]
# 或者: from math import atan [as 别名]
def opposing_angle(pos1, pos2):
    '''
    Returns the angle of the other_agent relative to the agent
    '''
    x_dif = pos2[0] - pos1[0]
    y_dif = pos2[1] - pos1[1]
    if (x_dif != 0 and y_dif != 0):
        if (x_dif > 0):
            new_angle = 180 + degrees(atan(y_dif / x_dif))
        else:
            new_angle = degrees(atan(y_dif / x_dif))
    elif (y_dif != 0):
        if(y_dif > 0):
            new_angle = 270
        else:
            new_angle = 90
    else:
        if(x_dif > 0):
            new_angle = 180
        else:
            new_angle = 0
    return new_angle 
开发者ID:gcallah,项目名称:indras_net,代码行数:24,代码来源:epidemic.py

示例2: getRayFromTo

# 需要导入模块: import math [as 别名]
# 或者: from math import atan [as 别名]
def getRayFromTo(mouseX,mouseY):
        width, height, viewMat, projMat, cameraUp, camForward, horizon,vertical, _,_,dist, camTarget = p.getDebugVisualizerCamera()
        camPos = [camTarget[0] - dist*camForward[0],camTarget[1] - dist*camForward[1],camTarget[2] - dist*camForward[2]]
        farPlane = 10000
        rayForward = [(camTarget[0]-camPos[0]),(camTarget[1]-camPos[1]),(camTarget[2]-camPos[2])]
        lenFwd = math.sqrt(rayForward[0]*rayForward[0]+rayForward[1]*rayForward[1]+rayForward[2]*rayForward[2])
        invLen = farPlane*1./lenFwd
        rayForward = [invLen*rayForward[0],invLen*rayForward[1],invLen*rayForward[2]]
        rayFrom = camPos
        oneOverWidth = float(1)/float(width)
        oneOverHeight = float(1)/float(height)

        dHor = [horizon[0] * oneOverWidth,horizon[1] * oneOverWidth,horizon[2] * oneOverWidth]
        dVer = [vertical[0] * oneOverHeight,vertical[1] * oneOverHeight,vertical[2] * oneOverHeight]
        rayToCenter=[rayFrom[0]+rayForward[0],rayFrom[1]+rayForward[1],rayFrom[2]+rayForward[2]]
        ortho=[- 0.5 * horizon[0] + 0.5 * vertical[0]+float(mouseX)*dHor[0]-float(mouseY)*dVer[0],
             - 0.5 * horizon[1] + 0.5 * vertical[1]+float(mouseX)*dHor[1]-float(mouseY)*dVer[1],
             - 0.5 * horizon[2] + 0.5 * vertical[2]+float(mouseX)*dHor[2]-float(mouseY)*dVer[2]]

        rayTo = [rayFrom[0]+rayForward[0]  +ortho[0],
                                        rayFrom[1]+rayForward[1]  +ortho[1],
                                        rayFrom[2]+rayForward[2]  +ortho[2]]
        lenOrtho = math.sqrt(ortho[0]*ortho[0]+ortho[1]*ortho[1]+ortho[2]*ortho[2])
        alpha = math.atan(lenOrtho/farPlane)
        return rayFrom,rayTo, alpha 
开发者ID:utra-robosoccer,项目名称:soccer-matlab,代码行数:27,代码来源:pointCloudFromCameraImage.py

示例3: c2s

# 需要导入模块: import math [as 别名]
# 或者: from math import atan [as 别名]
def c2s(self):
        R = self.dist(point(0, 0, 0))
        lg = math.atan(self.y / self.x)
        lat = acos(self.z / R)
        return (lg, lat, R)

    # ~ def transform(self,p1,p2):
    # ~ if isinstance(p2,point):
    # ~ v=vec(p1,p2)
    # ~ rot=v.angle()
    # ~ return self.transform(p1,rot)
    # ~ else:
    # ~ temp=self-p1
    # ~ rot=p2
    # ~ px=math.cos(rot)*temp.x+math.sin(rot)*temp.y
    # ~ py=-math.sin(rot)*temp.x+math.cos(rot)*temp.y
    # ~ return point(px,py) 
开发者ID:kamalshadi,项目名称:Localization,代码行数:19,代码来源:geometry.py

示例4: _view_update_camera

# 需要导入模块: import math [as 别名]
# 或者: from math import atan [as 别名]
def _view_update_camera(aspect, v3d, rv3d, camera):
    zoom = rv3d.view_camera_zoom
    z = ((_SQRT2 + zoom / 50) ** 2) / 4

    cdata = v3d.camera.data
    fit = cdata.sensor_fit
    if fit == 'VERTICAL':
        sensor = cdata.sensor_height
        _sensor = (16 * sensor / 9) / z  # sensor / (18 / 32)
        z *= 9 / 16  # 18 / 32
    else:
        sensor = cdata.sensor_width
        _sensor = sensor / z
    lens = cdata.lens
    camera['fov'] = ('FLOAT', math.degrees(2 * math.atan(_sensor / (2 * lens))))

    offset_x, offset_y = rv3d.view_camera_offset
    shift_x = cdata.shift_x
    shift_y = cdata.shift_y
    shx = 2 * z * (2 * offset_x + shift_x)
    shy = 2 * z * (2 * offset_y + shift_y * aspect)
    camera['screen_window_min'] = ('VECTOR2', (-1, -1))
    camera['screen_window_max'] = ('VECTOR2', (1, 1))

    return (zoom, fit, sensor, lens, offset_x, offset_y, shift_x, shift_y) 
开发者ID:griffin-copperfield,项目名称:Arnold-For-Blender,代码行数:27,代码来源:__init__.py

示例5: pixel_to_lonlat

# 需要导入模块: import math [as 别名]
# 或者: from math import atan [as 别名]
def pixel_to_lonlat(self, px, zoom):
        "Converts a pixel to a longitude, latitude pair at the given zoom level."
        if len(px) != 2:
            raise TypeError('Pixel should be a sequence of two elements.')

        # Getting the number of pixels for the given zoom level.
        npix = self._npix[zoom]

        # Calculating the longitude value, using the degrees per pixel.
        lon = (px[0] - npix) / self._degpp[zoom]

        # Calculating the latitude value.
        lat = RTOD * (2 * atan(exp((px[1] - npix) / (-1.0 * self._radpp[zoom]))) - 0.5 * pi)

        # Returning the longitude, latitude coordinate pair.
        return (lon, lat) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:18,代码来源:zoom.py

示例6: _thick_line

# 需要导入模块: import math [as 别名]
# 或者: from math import atan [as 别名]
def _thick_line(self, start_point, end_point, fill, thickness):
        """Draws a line using polygons to give it a thickness"""

        if thickness == 1:
            self.line((start_point, end_point), fill=fill)
        else:
            # Angle of the line
            if end_point[0] == start_point[0]:
                # Catch a division by zero error
                a = math.pi / 2
            else:
                a = math.atan((end_point[1] - start_point[1]) / (end_point[0] - start_point[0]))

            sin = math.sin(a)
            cos = math.cos(a)
            xdelta = sin * thickness / 2.0
            ydelta = cos * thickness / 2.0

            points = ((start_point[0] - xdelta, start_point[1] + ydelta),
                      (start_point[0] + xdelta, start_point[1] - ydelta),
                      (end_point[0] + xdelta, end_point[1] - ydelta),
                      (end_point[0] - xdelta, end_point[1] + ydelta))

            self.polygon(points, fill=fill) 
开发者ID:songyanho,项目名称:Reinforcement-Learning-for-Self-Driving-Cars,代码行数:26,代码来源:gauge.py

示例7: _location_to_gps

# 需要导入模块: import math [as 别名]
# 或者: from math import atan [as 别名]
def _location_to_gps(lat_ref, lon_ref, location):
    """
    Convert from world coordinates to GPS coordinates
    :param lat_ref: latitude reference for the current map
    :param lon_ref: longitude reference for the current map
    :param location: location to translate
    :return: dictionary with lat, lon and height
    """

    EARTH_RADIUS_EQUA = 6378137.0   # pylint: disable=invalid-name
    scale = math.cos(lat_ref * math.pi / 180.0)
    mx = scale * lon_ref * math.pi * EARTH_RADIUS_EQUA / 180.0
    my = scale * EARTH_RADIUS_EQUA * math.log(math.tan((90.0 + lat_ref) * math.pi / 360.0))
    mx += location.x
    my -= location.y

    lon = mx * 180.0 / (math.pi * EARTH_RADIUS_EQUA * scale)
    lat = 360.0 * math.atan(math.exp(my / (EARTH_RADIUS_EQUA * scale))) / math.pi - 90.0
    z = location.z

    return {'lat': lat, 'lon': lon, 'z': z} 
开发者ID:carla-simulator,项目名称:scenario_runner,代码行数:23,代码来源:route_manipulation.py

示例8: trig

# 需要导入模块: import math [as 别名]
# 或者: from math import atan [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

示例9: turn_xyz_into_llh

# 需要导入模块: import math [as 别名]
# 或者: from math import atan [as 别名]
def turn_xyz_into_llh(x,y,z,system):
	"""Convert 3D Cartesian x,y,z into Lat, Long and Height
       See http://www.ordnancesurvey.co.uk/gps/docs/convertingcoordinates3D.pdf"""

	a = abe_values[system][0]
	b = abe_values[system][1]
	e2 = abe_values[system][2]

	p = math.sqrt(x*x + y*y)

	long = math.atan(y/x)
	lat_init = math.atan( z / (p * (1.0 - e2)) )
	v = a / math.sqrt( 1.0 - e2 * (math.sin(lat_init) * math.sin(lat_init)) )
	lat = math.atan( (z + e2*v*math.sin(lat_init)) / p )

	height = (p / math.cos(lat)) - v # Ignore if a bit out

	# Turn from radians back into degrees
	long = long / 2 / math.pi * 360
	lat = lat / 2 / math.pi * 360

	return [lat,long,height] 
开发者ID:daq-tools,项目名称:kotori,代码行数:24,代码来源:geo.py

示例10: ecef_to_llh

# 需要导入模块: import math [as 别名]
# 或者: from math import atan [as 别名]
def ecef_to_llh(ecef_km):
    # WGS-84 ellipsoid parameters */
    a = 6378.1370
    b = 6356.752314

    p = sqrt(ecef_km[0] ** 2 + ecef_km[1] ** 2)
    thet = atan(ecef_km[2] * a / (p * b))
    esq = 1.0 - (b / a) ** 2
    epsq = (a / b) ** 2 - 1.0

    lat = atan((ecef_km[2] + epsq * b * sin(thet) ** 3) / (p - esq * a * cos(thet) ** 3))
    lon = atan2(ecef_km[1], ecef_km[0])
    n = a * a / sqrt(a * a * cos(lat) ** 2 + b ** 2 * sin(lat) ** 2)
    h = p / cos(lat) - n

    lat = degrees(lat)
    lon = degrees(lon)
    return lat, lon, h 
开发者ID:satellogic,项目名称:orbit-predictor,代码行数:20,代码来源:coordinate_systems.py

示例11: ta_to_E

# 需要导入模块: import math [as 别名]
# 或者: from math import atan [as 别名]
def ta_to_E(ta, ecc):
    """Eccentric anomaly from true anomaly.

    Parameters
    ----------
    ta : float
        True anomaly (rad).
    ecc : float
        Eccentricity.

    Returns
    -------
    E : float
        Eccentric anomaly.

    """
    E = 2 * atan(sqrt((1 - ecc) / (1 + ecc)) * tan(ta / 2))
    return E 
开发者ID:satellogic,项目名称:orbit-predictor,代码行数:20,代码来源:angles.py

示例12: E_to_ta

# 需要导入模块: import math [as 别名]
# 或者: from math import atan [as 别名]
def E_to_ta(E, ecc):
    """True anomaly from eccentric anomaly.

    Parameters
    ----------
    E : float
        Eccentric anomaly (rad).
    ecc : float
        Eccentricity.

    Returns
    -------
    ta : float
        True anomaly (rad).

    """
    ta = 2 * atan(sqrt((1 + ecc) / (1 - ecc)) * tan(E / 2))
    return ta 
开发者ID:satellogic,项目名称:orbit-predictor,代码行数:20,代码来源:angles.py

示例13: angleBetweenChars

# 需要导入模块: import math [as 别名]
# 或者: from math import atan [as 别名]
def angleBetweenChars(firstChar, secondChar):
    fltAdj = float(abs(firstChar.intCenterX - secondChar.intCenterX))
    fltOpp = float(abs(firstChar.intCenterY - secondChar.intCenterY))

    if fltAdj != 0.0:                           # check to make sure we do not divide by zero if the center X positions are equal, float division by zero will cause a crash in Python
        fltAngleInRad = math.atan(fltOpp / fltAdj)      # if adjacent is not zero, calculate angle
    else:
        fltAngleInRad = 1.5708                          # if adjacent is zero, use this as the angle, this is to be consistent with the C++ version of this program
    # end if

    fltAngleInDeg = fltAngleInRad * (180.0 / math.pi)       # calculate angle in degrees

    return fltAngleInDeg
# end function

###################################################################################################
# if we have two chars overlapping or to close to each other to possibly be separate chars, remove the inner (smaller) char,
# this is to prevent including the same char twice if two contours are found for the same char,
# for example for the letter 'O' both the inner ring and the outer ring may be found as contours, but we should only include the char once 
开发者ID:muchlisinadi,项目名称:ALPR-Indonesia,代码行数:21,代码来源:DetectChars.py

示例14: angle

# 需要导入模块: import math [as 别名]
# 或者: from math import atan [as 别名]
def angle(center, point):
    """Return the angle (radian) of point from center of the radian circle.
     ------p
     |   /
     |  /
    c|a/
    """
    dx = point.x - center.x
    dy = point.y - center.y
    if dx == 0:
        if dy < 0:
            return pi * 3 / 2
        return pi / 2
    if dy == 0:
        if dx < 0:
            return pi
        return 0
    if dx < 0:
        return pi + atan(dy / dx)
    if dy < 0:
        return 2 * pi + atan(dy / dx)
    return atan(dy / dx) 
开发者ID:TaipanRex,项目名称:pyvisgraph,代码行数:24,代码来源:visible_vertices.py

示例15: tunnel

# 需要导入模块: import math [as 别名]
# 或者: from math import atan [as 别名]
def tunnel(x, y, step):
    speed = step / 100.0
    x -= (u_width / 2)
    y -= (u_height / 2)
    xo = math.sin(step / 27.0) * 2
    yo = math.cos(step / 18.0) * 2
    x += xo
    y += yo
    if y == 0:
        if x < 0:
            angle = -(math.pi / 2)
        else:
            angle = (math.pi / 2)
    else:
        angle = math.atan(x / y)
    if y > 0:
        angle += math.pi
    angle /= 2 * math.pi  # convert angle to 0...1 range
    hyp = math.sqrt(math.pow(x, 2) + math.pow(y, 2))
    shade = hyp / 2.1
    shade = 1 if shade > 1 else shade
    angle += speed
    depth = speed + (hyp / 10)
    col1 = hue_to_rgb[step % 255]
    col1 = (col1[0] * 0.8, col1[1] * 0.8, col1[2] * 0.8)
    col2 = hue_to_rgb[step % 255]
    col2 = (col2[0] * 0.3, col2[1] * 0.3, col2[2] * 0.3)
    col = col1 if int(abs(angle * 6.0)) % 2 == 0 else col2
    td = .3 if int(abs(depth * 3.0)) % 2 == 0 else 0
    col = (col[0] + td, col[1] + td, col[2] + td)
    col = (col[0] * shade, col[1] * shade, col[2] * shade)
    return (col[0] * 255, col[1] * 255, col[2] * 255) 
开发者ID:pimoroni,项目名称:unicorn-hat-hd,代码行数:34,代码来源:demo.py


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