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


Python math.radians方法代码示例

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


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

示例1: distance

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

# 需要导入模块: import math [as 别名]
# 或者: from math import radians [as 别名]
def _startImageCapturingAtGraphNode(self):
        amntY = 0.3
        xdir = [-0.5, 0, 0.5]
        cameraId = 0

        for idx,amntX in enumerate(xdir):
            self._moveHead(amntX, amntY)
            time.sleep(0.1)
            self._checkIfAsthamaInEnvironment(cameraId)
            if self.pumpFound :
                # Setting rotation angle of body towards head
                theta = 0
                if idx == 0: # LEFT
                    theta = math.radians(-45)
                if idx == 2: # RIGHT
                    theta = math.radians(45)
                self.pumpAngleRotation = theta

                return "KILLING GRAPH SEARCH : PUMP FOUND"

        self._moveHead(0, 0) # Bringing to initial view

        return 
开发者ID:maverickjoy,项目名称:pepper-robot-programming,代码行数:25,代码来源:asthama_search.py

示例3: distance

# 需要导入模块: import math [as 别名]
# 或者: from math import radians [as 别名]
def distance(origin, destination):
	"""Determine distance between 2 sets of [lat,lon] in km"""

	lat1, lon1 = origin
	lat2, lon2 = destination
	radius = 6371  # km

	dlat = math.radians(lat2 - lat1)
	dlon = math.radians(lon2 - lon1)
	a = (math.sin(dlat / 2) * math.sin(dlat / 2) +
		 math.cos(math.radians(lat1)) *
		 math.cos(math.radians(lat2)) * math.sin(dlon / 2) *
		 math.sin(dlon / 2))
	c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
	d = radius * c

	return d 
开发者ID:NatanaelAntonioli,项目名称:L.E.S.M.A,代码行数:19,代码来源:L.E.S.M.A. - Fabrica de Noobs Speedtest.py

示例4: rotate_bbox

# 需要导入模块: import math [as 别名]
# 或者: from math import radians [as 别名]
def rotate_bbox(box, a):
  '''Rotate a bounding box 4-tuple by an angle in degrees'''
  corners = ( (box[0], box[1]), (box[0], box[3]), (box[2], box[3]), (box[2], box[1]) )
  a = -math.radians(a)
  sa = math.sin(a)
  ca = math.cos(a)
  
  rot = []
  for p in corners:
    rx = p[0]*ca + p[1]*sa
    ry = -p[0]*sa + p[1]*ca
    rot.append((rx,ry))
  
  # Find the extrema of the rotated points
  rot = list(zip(*rot))
  rx0 = min(rot[0])
  rx1 = max(rot[0])
  ry0 = min(rot[1])
  ry1 = max(rot[1])

  #print('## RBB:', box, rot)
    
  return (rx0, ry0, rx1, ry1) 
开发者ID:kevinpt,项目名称:symbolator,代码行数:25,代码来源:shapes.py

示例5: draw_marker

# 需要导入模块: import math [as 别名]
# 或者: from math import radians [as 别名]
def draw_marker(self, name, mp, tp, weight, c):
    if name in self.markers:
      m_shape, ref, orient, units = self.markers[name]

      c.save()
      c.translate(*mp)
      if orient == 'auto':
        angle = math.atan2(tp[1]-mp[1], tp[0]-mp[0])
        c.rotate(angle)
      elif isinstance(orient, int):
        angle = math.radians(orient)
        c.rotate(angle)

      if units == 'stroke':
        c.scale(weight, weight)
        
      c.translate(-ref[0], -ref[1])
      
      self.draw_shape(m_shape)
      c.restore() 
开发者ID:kevinpt,项目名称:symbolator,代码行数:22,代码来源:cairo_backend.py

示例6: update

# 需要导入模块: import math [as 别名]
# 或者: from math import radians [as 别名]
def update(self):
        radians = math.radians(self.direction)

        self.x += self.speed * math.sin(radians)
        self.y -= self.speed * math.cos(radians)

        # Update ball position
        self.rect.x = self.x
        self.rect.y = self.y

        if self.y <= self.top_edge:
            self.direction = (180-self.direction) % 360
            self.sound.edge_sound.play()
        if self.y > self.bottom_edge - 1*self.height:
            self.direction = (180-self.direction) % 360
            self.sound.edge_sound.play() 
开发者ID:HuangJunye,项目名称:QPong,代码行数:18,代码来源:ball.py

示例7: gcd

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

示例8: to_quaternion

# 需要导入模块: import math [as 别名]
# 或者: from math import radians [as 别名]
def to_quaternion(roll = 0.0, pitch = 0.0, yaw = 0.0):
    """
    Convert degrees to quaternions
    """
    t0 = math.cos(math.radians(yaw * 0.5))
    t1 = math.sin(math.radians(yaw * 0.5))
    t2 = math.cos(math.radians(roll * 0.5))
    t3 = math.sin(math.radians(roll * 0.5))
    t4 = math.cos(math.radians(pitch * 0.5))
    t5 = math.sin(math.radians(pitch * 0.5))

    w = t0 * t2 * t4 + t1 * t3 * t5
    x = t0 * t3 * t4 - t1 * t2 * t5
    y = t0 * t2 * t5 + t1 * t3 * t4
    z = t1 * t2 * t4 - t0 * t3 * t5

    return [w, x, y, z]

# Take off 2.5m in GUIDED_NOGPS mode. 
开发者ID:dronekit,项目名称:dronekit-python,代码行数:21,代码来源:set_attitude_target.py

示例9: contains

# 需要导入模块: import math [as 别名]
# 或者: from math import radians [as 别名]
def contains(self, *args):
        if isinstance(args[0], Point):
            point = args[0]
            return self.contains(LatLon.from_point(point))
        elif isinstance(args[0], LatLon):
            ll = args[0]
            assert ll.is_valid()
            return self.lat().contains(ll.lat().radians) \
                    and self.lon().contains(ll.lon().radians)
        elif isinstance(args[0], self.__class__):
            other = args[0]
            return self.lat().contains(other.lat()) \
                    and self.lon().contains(other.lon())
        elif isinstance(args[0], Cell):
            cell = args[0]
            return self.contains(cell.get_rect_bound())
        else:
            raise NotImplementedError() 
开发者ID:qedus,项目名称:sphere,代码行数:20,代码来源:sphere.py

示例10: _set_lighting

# 需要导入模块: import math [as 别名]
# 或者: from math import radians [as 别名]
def _set_lighting(self):
        # Create new lamp datablock
        light_data = bpy.data.lamps.new(name="New Lamp", type='HEMI')

        # Create new object with our lamp datablock
        light_2 = bpy.data.objects.new(name="New Lamp", object_data=light_data)
        bpy.context.scene.objects.link(light_2)

        # put the light behind the camera. Reduce specular lighting
        self.light.location       = (0, -2, 2)
        self.light.rotation_mode  = 'ZXY'
        self.light.rotation_euler = (radians(45), 0, radians(90))
        self.light.data.energy = 0.7

        light_2.location       = (0, 2, 2)
        light_2.rotation_mode  = 'ZXY'
        light_2.rotation_euler = (-radians(45), 0, radians(90))
        light_2.data.energy = 0.7 
开发者ID:chrischoy,项目名称:3D-R2N2,代码行数:20,代码来源:blender_renderer.py

示例11: __init__

# 需要导入模块: import math [as 别名]
# 或者: from math import radians [as 别名]
def __init__(self, name=None, origin=(0, 0, 0), width=3.0, depth=6.0, height=3.2,
                 rotation_angle=0):
        """Init room."""
        self._width = float(width) or 3.0
        self._depth = float(depth) or 6.0
        self._height = float(height) or 3.2
        self._rotation_angle = float(rotation_angle) or 0.0

        self._z_axis = Vector3(0, 0, 1)
        self._x_axis = Vector3(1, 0, 0).rotate_around(
            self._z_axis, math.radians(rotation_angle))
        self._y_axis = Vector3(0, 1, 0).rotate_around(
            self._z_axis, math.radians(rotation_angle))

        name = name or 'room'
        origin = Point3(*tuple(origin)) if origin else Point3(0, 0, 0)
        # setting up origin will initiate recalculation of room
        HBZone.__init__(self, name, origin) 
开发者ID:ladybug-tools,项目名称:honeybee,代码行数:20,代码来源:room.py

示例12: _get_affine_matrix

# 需要导入模块: import math [as 别名]
# 或者: from math import radians [as 别名]
def _get_affine_matrix(center, angle, translate, scale, shear):
    # Helper method to compute matrix for affine transformation
    # We need compute affine transformation matrix: M = T * C * RSS * C^-1
    # where T is translation matrix: [1, 0, tx | 0, 1, ty | 0, 0, 1]
    #       C is translation matrix to keep center: [1, 0, cx | 0, 1, cy | 0, 0, 1]
    #       RSS is rotation with scale and shear matrix
    #       RSS(a, scale, shear) = [ cos(a)*scale    -sin(a + shear)*scale     0]
    #                              [ sin(a)*scale    cos(a + shear)*scale     0]
    #                              [     0                  0          1]
    
    angle = math.radians(angle)
    shear = math.radians(shear)
    # scale = 1.0 / scale
    
    T = np.array([[1, 0, translate[0]], [0, 1, translate[1]], [0,0,1]])
    C = np.array([[1, 0, center[0]], [0, 1, center[1]], [0,0,1]])
    RSS = np.array([[math.cos(angle)*scale, -math.sin(angle+shear)*scale, 0],
                   [math.sin(angle)*scale, math.cos(angle+shear)*scale, 0],
                   [0,0,1]])
    matrix = T @ C @ RSS @ np.linalg.inv(C)
    
    return matrix[:2,:] 
开发者ID:jbohnslav,项目名称:opencv_transforms,代码行数:24,代码来源:functional.py

示例13: pointOnCircle

# 需要导入模块: import math [as 别名]
# 或者: from math import radians [as 别名]
def pointOnCircle(cx, cy, radius, angle):
    """
    Calculates the coordinates of a point on a circle given the center point,
    radius, and angle.
    """
    angle = math.radians(angle) - (math.pi / 2)
    x = cx + radius * math.cos(angle)
    if x < cx:
        x = math.ceil(x)
    else:
        x = math.floor(x)

    y = cy + radius * math.sin(angle)

    if y < cy:
        y = math.ceil(y)
    else:
        y = math.floor(y)

    return (int(x), int(y)) 
开发者ID:ManiacalLabs,项目名称:BiblioPixel,代码行数:22,代码来源:util.py

示例14: _get_affine_matrix

# 需要导入模块: import math [as 别名]
# 或者: from math import radians [as 别名]
def _get_affine_matrix(center, angle, translate, scale, shear):
    # Helper method to compute matrix for affine transformation
    # We need compute affine transformation matrix: M = T * C * RSS * C^-1
    # where T is translation matrix: [1, 0, tx | 0, 1, ty | 0, 0, 1]
    #       C is translation matrix to keep center: [1, 0, cx | 0, 1, cy | 0, 0, 1]
    #       RSS is rotation with scale and shear matrix
    #       RSS(a, scale, shear) = [ cos(a)*scale    -sin(a + shear)*scale     0]
    #                              [ sin(a)*scale    cos(a + shear)*scale     0]
    #                              [     0                  0          1]

    angle = math.radians(angle)
    shear = math.radians(shear)
    # scale = 1.0 / scale

    T = np.array([[1, 0, translate[0]], [0, 1, translate[1]], [0,0,1]])
    C = np.array([[1, 0, center[0]], [0, 1, center[1]], [0,0,1]])
    RSS = np.array([[math.cos(angle)*scale, -math.sin(angle+shear)*scale, 0],
                   [math.sin(angle)*scale, math.cos(angle+shear)*scale, 0],
                   [0,0,1]])
    matrix = T @ C @ RSS @ np.linalg.inv(C)

    return matrix[:2,:] 
开发者ID:CMU-CREATE-Lab,项目名称:deep-smoke-machine,代码行数:24,代码来源:opencv_functional.py

示例15: set_sailboat_heading

# 需要导入模块: import math [as 别名]
# 或者: from math import radians [as 别名]
def set_sailboat_heading(pub_state):
    global current_state
    global current_sail
    state_aux = ModelState()
    quaternion = (current_state.pose.pose.orientation.x, current_state.pose.pose.orientation.y, current_state.pose.pose.orientation.z, current_state.pose.pose.orientation.w)

    euler = tf.transformations.euler_from_quaternion(quaternion)

    quaternion = tf.transformations.quaternion_from_euler(euler[0], euler[1], math.radians(current_heading))
    state_aux.pose.orientation.x = quaternion[0]
    state_aux.pose.orientation.y = quaternion[1]
    state_aux.pose.orientation.z = quaternion[2]
    state_aux.pose.orientation.w = quaternion[3]
    state_aux.model_name = 'sailboat'
    #state_aux.pose.position.x = current_state.pose.pose.position.x
    #state_aux.pose.position.y = current_state.pose.pose.position.y
    #state_aux.pose.position.z = current_state.pose.pose.position.z
    #print(current_state)

    state_aux.pose.position.x = 240 
    state_aux.pose.position.y = 95
    state_aux.pose.position.z = 1
    pub_state.publish(state_aux) 
开发者ID:disaster-robotics-proalertas,项目名称:usv_sim_lsa,代码行数:25,代码来源:sail_polar_diagram.py


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