• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python math.rad函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __init__

    def __init__(self, lift, duration, firing_order, advance=0):

        """
        Initialize a Camshaft instance

        :param lift: camshaft lift measured in mm
        :param duration: crank degrees between valve opening and closing
        :param firing_order: list of cylinder numbers in order of firing pattern
        :param  advance[optional]: camshaft (not crankshaft) degrees of advance
            - Positive means valve opens sooner than when piston is at TDC
            - Negative means valve opens later than when piston is at TDC
        """

        super(Camshaft, self).__init__()
        self.lift = lift
        self.duration = rad(duration)
        self.number_cylinders = len(firing_order)
        self.firing_order = firing_order
        self.advance = rad(advance)
        self.amplitude = None
        self.start_lift = tuple(rad(720 / self.number_cylinders * (cyl - 1))
                           for cyl in self.firing_order)

        # run methods to solve for parameters
        self.solve_amplitude()
开发者ID:cbmurphy,项目名称:EngineModel,代码行数:25,代码来源:camshaft.py


示例2: earthquake

def earthquake():
    url = 'http://www.seismi.org/api/eqs/2013?min_magnitude=7'
    resp = requests.get(url)
    data = json.loads(resp.text)
    city_list = ['Juneau, AK', 'Vancouver, BC', 'Seattle', 'Portland, OR', 'San Francisco, CA', 'Los Angeles, CA']
    city_dict = {}
    for city in city_list:
        lat_c = get_city_loc(city)[0]
        lng_c = get_city_loc(city)[1]
        intensity_list = []
        eq_dict = {}
        for i in range(len(data['earthquakes'])):
            stri = str(i + 1)
            timedate = data['earthquakes'][i]['timedate']
            lat_e = float(data['earthquakes'][i]['lat'])
            lng_e = float(data['earthquakes'][i]['lon'])
            mag = float(data['earthquakes'][i]['magnitude'])
            depth = float(data['earthquakes'][i]['depth'])
            #  Haversine calculation for distance using coordinates.
            R = 6371
            dLat = rad(lat_c - lat_e)
            dLon = rad(lng_c - lng_e)
            lat_er = rad(lat_e)
            lat_cr = rad(lat_c)
            a = sin(dLat/2) * sin(dLat/2) + sin(dLon/2) * sin(dLon/2) * cos(lat_er) * cos(lat_cr)
            c = 2 * atan2(sqrt(a), sqrt(1-a))
            epi_d = R * c
            depth_d = sqrt(depth**2 + epi_d**2)
            intensity = 10000 * mag / depth_d
            intensity_list.append(intensity)
            eq_dict[stri] = [timedate, str(epi_d), str(depth_d), str(mag), str(intensity)]
        intensity_avg = sum(intensity_list) / len(intensity_list)
        city_dict[city] = (str(intensity_avg), eq_dict)
    return city_dict
开发者ID:jwhite007,项目名称:Mashup,代码行数:34,代码来源:equake_mashup.py


示例3: project

    def project(self, lon, lat):
        from math import radians as rad, pow, asin, cos, sin

        lon, lat = self.ll(lon, lat)
        phi = rad(lat)
        lam = rad(lon)

        cos_c = sin(self.phi0) * sin(phi) + cos(self.phi0) * cos(phi) * cos(lam - self.lam0)
        k = (self.dist - 1) / (self.dist - cos_c)
        k = (self.dist - 1) / (self.dist - cos_c)

        k *= self.scale

        xo = self.r * k * cos(phi) * sin(lam - self.lam0)
        yo = -self.r * k * (cos(self.phi0) * sin(phi) - sin(self.phi0) * cos(phi) * cos(lam - self.lam0))

        # rotate
        tilt = self.tilt_

        cos_up = cos(self.up_)
        sin_up = sin(self.up_)
        cos_tilt = cos(tilt)
        sin_tilt = sin(tilt)

        H = self.r * (self.dist - 1)
        A = ((yo * cos_up + xo * sin_up) * sin(tilt / H)) + cos_tilt
        xt = (xo * cos_up - yo * sin_up) * cos(tilt / A)
        yt = (yo * cos_up + xo * sin_up) / A

        x = self.r + xt
        y = self.r + yt

        return (x, y)
开发者ID:netconstructor,项目名称:kartograph.py,代码行数:33,代码来源:azimuthal.py


示例4: __init__

 def __init__(self, lat0=0.0, lon0=0.0, lat1=0.0, flip=0):
     self.lat0 = lat0
     self.lat1 = lat1
     self.phi0 = rad(lat0 * -1)
     self.phi1 = rad(lat1 * -1)
     self.lam0 = rad(lon0)
     Cylindrical.__init__(self, lon0=lon0, flip=flip)
开发者ID:PythonCharmers,项目名称:kartograph.py,代码行数:7,代码来源:cylindrical.py


示例5: project

 def project(self, lon, lat):
     lon, lat = self.ll(lon, lat)
     lam = rad(lon)
     phi = rad(lat * -1)
     x = lam * 1000
     y = math.log((1 + math.sin(phi)) / math.cos(phi)) * 1000
     return (x, y)
开发者ID:PythonCharmers,项目名称:kartograph.py,代码行数:7,代码来源:cylindrical.py


示例6: area

def area(pts, earthrad=6371):
	from math import radians as rad, sin, cos, asin, sqrt, pi, tan, atan
	pihalf = pi * .5

	n = len(pts)
	sum = 0
	for j in range(0,n):
		k = (j+1)%n
		if j == 0:
			lam1 = rad(pts[j][0])
			beta1 = rad(pts[j][1])
			cosB1 = cos(beta1)
		else:
			lam1 = lam2
			beta1 = beta2
			cosB1 = cosB2
		lam2 = rad(pts[k][0])
		beta2 = rad(pts[k][1])
		cosB2 = cos(beta2)
		
		if lam1 != lam2:
			hav = haversine( beta2 - beta1 ) + cosB1 * cosB2 * haversine(lam2 - lam1)
			a = 2 * asin(sqrt(hav))
			b = pihalf - beta2
			c = pihalf - beta1
			s = 0.5 * (a+b+c)
			t = tan(s*0.5) * tan((s-a)*0.5) * tan((s-b)*0.5) * tan((s-c)*0.5)
			excess = abs(4*atan(sqrt(abs(t))))
			if lam2 < lam1:
				excess = -excess
			sum += excess
	return abs(sum)*earthrad*earthrad
开发者ID:kartograph,项目名称:kartograph.py-old,代码行数:32,代码来源:gisutils.py


示例7: get_transformed_model

	def get_transformed_model(self, transforms):
		t = transforms

		scaling_matrix = np.matrix([
			[t['sx']/100, 0, 0, 1],
			[0, t['sy']/100, 0, 1],
			[0, 0, t['sz']/100, 1],
			[0, 0, 0, 1]
		])

		translation_matrix = np.matrix([
			[1, 0, 0, t['tx']],
			[0, 1, 0, t['ty']],
			[0, 0, 1, t['tz']],
			[0, 0, 0, 1   ]
		])

		rotation_matrix = np.matrix(euler_matrix(
			rad(t['rx']),
			rad(t['ry']),
			rad(t['rz'])
		))

		matrix = scaling_matrix * translation_matrix * rotation_matrix

		leds_ = leds.copy()
		leds_ = np.pad(leds_, (0,1), 'constant', constant_values=1)[:-1]
		leds_ = np.rot90(leds_, 3)
		leds_ = np.dot(matrix, leds_)
		leds_ = np.rot90(leds_)
		leds_ = np.array(leds_)

		return leds_
开发者ID:buzz,项目名称:sniegabuda-raspi,代码行数:33,代码来源:gui.py


示例8: project

 def project(self, lon, lat):
     lon, lat = self.ll(lon, lat)
     lam = rad(lon)
     phi = rad(lat * -1)
     x = 1032 * lam * math.cos(phi)
     y = 1032 * phi
     return (x, y)
开发者ID:PythonCharmers,项目名称:kartograph.py,代码行数:7,代码来源:pseudocylindrical.py


示例9: rotate_ox

def rotate_ox(m, b, a):
    cosa, sina = cos(rad(a)), sin(rad(a))
    rotm = translate(mat(1), [-b[0], -b[1], -b[2]])
    rotm = rotm * mat([[1,     0,    0, 0],
                       [0,  cosa, sina, 0],
                       [0, -sina, cosa, 0],
                       [0,     0,    0, 1]])
    rotm = rotm * translate(mat(1), b)
    return m * rotm
开发者ID:geerk,项目名称:something,代码行数:9,代码来源:transform.py


示例10: __init__

 def __init__(self, lat0=0, lon0=0, lat1=0, lat2=0):
     self.lat0 = lat0
     self.phi0 = rad(lat0)
     self.lon0 = lon0
     self.lam0 = rad(lon0)
     self.lat1 = lat1
     self.phi1 = rad(lat1)
     self.lat2 = lat2
     self.phi2 = rad(lat2)
开发者ID:Eugene-msc,项目名称:kartograph.py,代码行数:9,代码来源:conic.py


示例11: __init__

 def __init__(me, lon0=0, flip=0):
     me.EPS = 1e-10
     PseudoCylindrical.__init__(me, lon0=lon0, flip=flip)
     me.r = me.HALFPI * 100
     sea = []
     r = me.r
     for phi in range(0, 361):
         sea.append((math.cos(rad(phi)) * r, math.sin(rad(phi)) * r))
     me.sea = sea
开发者ID:PythonCharmers,项目名称:kartograph.py,代码行数:9,代码来源:pseudocylindrical.py


示例12: __init__

	def __init__(self, lat0=0, lon0=0, lat1=0, lat2=0):
		from math import radians as rad
		self.lat0 = lat0
		self.phi0 = rad(lat0)
		self.lon0 = lon0
		self.lam0 = rad(lon0)
		self.lat1 = lat1
		self.phi1 = rad(lat1)
		self.lat2 = lat2
		self.phi2 = rad(lat2)
开发者ID:kartograph,项目名称:kartograph.py-old,代码行数:10,代码来源:conic.py


示例13: __init__

    def __init__(self, latlong_dd):
        self.observer = ephem.Observer()
        self.observer.name = 'Somewhere'
        self.observer.lat = rad(latlong_dd[0])  # lat/long in decimal degrees
        self.observer.long = rad(latlong_dd[1])
        self.observer.elevation = 0

        self.observer.date = date.today()

        self.observer.pressure = 1000
        self.gmt = pytz.timezone("GMT")
开发者ID:widget,项目名称:iot-display,代码行数:11,代码来源:ephem_tools.py


示例14: markerDistance

def markerDistance(marker):
    """Finds the relative forwards and sideways distance to a marker
    Input: marker
    Output: sideDist, forwardDist, totalDist"""
    forwardDist = 0
    sideDist = 0
    totalDist = 0
    p = marker.centre
    forwardDist = math.sin(math.rad(p.polar.rot_x))*p.polar.length
    sideDist = math.cos(math.rad(p.polar.rot_x))*p.polar.length
    totalDist = sideDist+forwardDist
    return sideDist, forwardDist, totalDist
开发者ID:MountainNinja,项目名称:-LifterBot2013,代码行数:12,代码来源:robot.py


示例15: __init__

    def __init__(self, lat0=0, lon0=0, lat1=0, lat2=0):
        self.lat0 = lat0
        self.phi0 = rad(lat0)
        self.lon0 = lon0
        self.lam0 = rad(lon0)
        self.lat1 = lat1
        self.phi1 = rad(lat1)
        self.lat2 = lat2
        self.phi2 = rad(lat2)

        if lon0 != 0.0:
            self.bounds = self.bounding_geometry()
开发者ID:PythonCharmers,项目名称:kartograph.py,代码行数:12,代码来源:conic.py


示例16: __init__

    def __init__(self, lat0=0, lon0=0, lat1=0, lat2=0):
        self.lat0 = lat0
        self.phi0 = rad(lat0)
        self.lon0 = lon0
        self.lam0 = rad(lon0)
        self.lat1 = lat1
        self.phi1 = rad(lat1)
        self.lat2 = lat2
        self.phi2 = rad(lat2)
        self.sea = self.sea_coords()

        if lon0 != 0.0:
            from Polygon import MultiPolygon as Poly
            self.inside_p = Poly(self.sea)
开发者ID:cemetek,项目名称:kartograph.py,代码行数:14,代码来源:conic.py


示例17: __init__

 def __init__(self, xcenter, ycenter, style):
     self.a, self.b, self.c, self.d = [xcenter-.5, ycenter+.5],[xcenter+.5, ycenter+.5],  [xcenter-.5, ycenter-.5], [xcenter+.5, ycenter-.5]
     if style == 1:  #upper right and lower left arcs
         #first upper right
         x = [self.b[0] + cos(rad(i))/2. for i in range(180, 271)]
         y = [self.b[1] + sin(rad(i))/2. for i in range(180, 271)]
         x[44] = xcenter
         y[44] = ycenter
         self.p1 = [x,y]
         #now lower left
         x = [self.c[0] + cos(rad(i))/2. for i in range(0, 91)]
         y = [self.c[1] + sin(rad(i))/2. for i in range(0, 91)]
         x[44] = xcenter
         y[44] = ycenter
         self.p2 = [x,y]
     if style == 2:  #upper left and lower right arcs
         #first upper left
         x = [self.a[0] + cos(rad(i))/2. for i in range(270, 361)]
         y = [self.a[1] + sin(rad(i))/2. for i in range(270, 361)]
         x[44] = xcenter
         y[44] = ycenter
         self.p1 = [x,y]
         #now lower right
         x = [self.d[0] + cos(rad(i))/2. for i in range(90, 181)]
         y = [self.d[1] + sin(rad(i))/2. for i in range(90, 181)]
         x[44] = xcenter
         y[44] = ycenter
         self.p2 = [x,y]
开发者ID:flag0010,项目名称:truchet,代码行数:28,代码来源:truchet.py


示例18: setAlpha

 def setAlpha(self, alpha):
     alpha = alpha % 360
     self.alpha = alpha
     if alpha < 45.0: # 1
         self.pos1 = self.h - 1 + self.w * tan(rad(alpha))
         self.pos2 = self.h - 1
         self.step = -1
         self.endPoints = self.endPointsH
         self.span = self.h
         return
     if 45.0 <= alpha < 90.0: # 2
         self.pos1 = self.w - 1 + self.h / tan(rad(alpha))
         self.pos2 = self.w - 1
         self.step = -1
         self.endPoints = self.endPointsV
         self.span = self.w
         return
     if 90.0 <= alpha < 135.0: # 3
         self.pos1 = self.w - 1
         self.pos2 = self.w - 1 - self.h / tan(rad(alpha))
         self.step = -1
         self.endPoints = self.endPointsV
         self.span = self.w
         return
     if 135.0 <= alpha < 180.0: # 4
         self.pos1 = self.w * tan(rad(alpha)) # this is correct since tan(pi - x) = -tan x
         self.pos2 = 0
         self.step = 1
         self.endPoints = self.endPointsH
         self.span = self.h
         return
     if 180.0 <= alpha < 225.0: # 5
         self.pos1 = 0
         self.pos2 = -self.w * tan(rad(alpha))
         self.step = 1
         self.endPoints = self.endPointsH
         self.span = self.h
         return
     if 225.0 <= alpha < 270.0: # 6
         self.pos1 = 0
         self.pos2 = -self.h / tan(rad(alpha))
         self.step = 1
         self.endPoints = self.endPointsV
         self.span = self.w
         return
     if 270.0 <= alpha < 315.0: # 7
         self.pos1 = self.h / tan(rad(alpha)) # this is correct since tan(x - 3/2 * pi) = -cot x
         self.pos2 = 0
         self.step = 1
         self.endPoints = self.endPointsV
         self.span = self.w
         return
     if 315.0 <= alpha: # 8
         self.pos1 = self.h - 1
         self.pos2 = self.h - 1 - self.w * tan(rad(alpha))
         self.step = -1
         self.endPoints = self.endPointsH
         self.span = self.h
         return
     raise ValueError("Weird Python behavior at angle: " + str(alpha))
开发者ID:Pastafarianist,项目名称:captchure,代码行数:60,代码来源:preprocess.py


示例19: project

	def project(self, lon, lat):
		lon,lat = self.ll(lon, lat)
		phi = rad(lat)
		lam = rad(lon)
		n = self.n		
		if abs(abs(phi) - self.HALFPI) < 1e-10:
			rho = 0.0
		else:
			rho = self.c * math.pow(math.tan(self.QUARTERPI + 0.5 * phi), -n)
		lam_ = (lam - self.lam0) * n
		x = 1000 * rho * math.sin(lam_)
		y = 1000 * (self.rho0 - rho * math.cos(lam_))
		
		return (x,y*-1)
开发者ID:kartograph,项目名称:kartograph.py-old,代码行数:14,代码来源:conic.py


示例20: draw

	def draw(self, cr):
		flen = len(self.fillColorA) if self.fillColorA else 0
		if flen in(3, 4):
			cr.push_group()
			cr.set_line_cap(cairo.LINE_CAP_ROUND)
			getattr(cr, 'set_source_rgb'+('', 'a')[flen==4])(*self.fillColorA)
			cr.set_line_width(self.width)
			cr.move_to(*self.start)
			cr.line_to(*self.end)
			cr.stroke()
			cr.pop_group_to_source()
			cr.paint()
		if self.frameColorA and(self.frameWidth):
			cr.push_group()
			cr.translate(*self.center)
			cr.rotate(-rad(self.orientation/10.))
			cr.translate(-self.center[0], -self.center[1])
			cr.set_line_cap(cairo.LINE_CAP_ROUND)
			cr.set_fill_rule(cairo.FILL_RULE_EVEN_ODD)
			cr.set_source_rgba(*self.frameColorA)
			cr.set_line_width(self.frameWidth)
			r = self.width/2.
			xsize = max(0, wdh - hgt)
			ysize = max(0, hgt - wdh)
			cr.move_to(ox - wdh/2., oy + ysize/2.)
			cr.arc(ox - xsize/2., oy - ysize/2., r, pi, 3 * pi/2.)
			cr.arc(ox + xsize/2., oy - ysize/2., r, 3 * pi/2., 2 * pi)
			cr.arc(ox + xsize/2., oy + ysize/2., r, 0, pi/2.)
			cr.arc(ox - xsize/2., oy + ysize/2., r, pi/2., pi)
			cr.pop_group_to_source()
			cr.paint()
开发者ID:LordBlick,项目名称:svgImportKiCAD,代码行数:31,代码来源:clDrawSVG.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python math.radians函数代码示例发布时间:2022-05-27
下一篇:
Python math.pow函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap