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


Python math.rad函数代码示例

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


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


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