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


Python math.atan函数代码示例

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


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

示例1: fromwgs84

def fromwgs84(lat, lng, pkm=False):
    """
    Convert coordintes from WGS84 to TWD97

    pkm true for Penghu, Kinmen and Matsu area
    The latitude and longitude can be in the following formats:
        [+/-]DDD°MMM'SSS.SSSS" (unicode)
        [+/-]DDD°MMM.MMMM' (unicode)
        [+/-]DDD.DDDDD (string, unicode or float)
    The returned coordinates are in meters
    """

    _lng0 = lng0pkm if pkm else lng0

    lat = radians(todegdec(lat))
    lng = radians(todegdec(lng))

    t = sinh((atanh(sin(lat)) - 2*pow(n,0.5)/(1+n)*atanh(2*pow(n,0.5)/(1+n)*sin(lat))))
    epsilonp = atan(t/cos(lng-_lng0))
    etap = atan(sin(lng-_lng0) / pow(1+t*t, 0.5))

    E = E0 + k0*A*(etap + alpha1*cos(2*1*epsilonp)*sinh(2*1*etap) + 
                          alpha2*cos(2*2*epsilonp)*sinh(2*2*etap) +
                          alpha3*cos(2*3*epsilonp)*sinh(2*3*etap))
    N = N0 + k0*A*(epsilonp + alpha1*sin(2*1*epsilonp)*cosh(2*1*etap) +
                              alpha2*sin(2*2*epsilonp)*cosh(2*2*etap) +
                              alpha3*sin(2*3*epsilonp)*cosh(2*3*etap))

    return E*1000, N*1000
开发者ID:shupingT,项目名称:twd97,代码行数:29,代码来源:converter.py

示例2: wmplugin_exec

   def wmplugin_exec(self, m):
	
	axes = [None, None, None, None]


	self.acc = [self.NEW_AMOUNT*(new-zero)/(one-zero) + self.OLD_AMOUNT*old
	       for old,new,zero,one in zip(self.acc,m,self.acc_zero,self.acc_one)]
	a = math.sqrt(sum(map(lambda x: x**2, self.acc)))

	roll = math.atan(self.acc[cwiid.X]/self.acc[cwiid.Z])
	if self.acc[cwiid.Z] <= 0:
		if self.acc[cwiid.X] > 0: roll += math.pi
		else: roll -= math.pi

	pitch = math.atan(self.acc[cwiid.Y]/self.acc[cwiid.Z]*math.cos(roll))

	axes[0] = int(roll  * 1000 * self.Roll_Scale)
	axes[1] = int(pitch * 1000 * self.Pitch_Scale)

	if (a > 0.85) and (a < 1.15):
		if (math.fabs(roll)*(180/math.pi) > 10) and \
		   (math.fabs(pitch)*(180/math.pi) < 80):
			axes[2] = int(roll * 5 * self.X_Scale)

		if (math.fabs(pitch)*(180/math.pi) > 10):
			axes[3] = int(pitch * 10 * self.Y_Scale)

	return math.degrees(pitch), math.degrees(roll)
开发者ID:evilmachina,项目名称:leetZeppelin,代码行数:28,代码来源:acc.py

示例3: execute

	def execute(self, context):
		lightOffset = 20
		lightHeight = 20
		scene = context.scene
		# delete active object if it is a mesh
		active = context.object
		if active and active.type=="MESH":
			bpy.ops.object.delete()
		# getting width and height of the footprint
		w, h = [float(i) for i in self.size.split("x")]
		# add lights
		rx = math.atan((h+lightOffset)/lightHeight)
		rz = math.atan((w+lightOffset)/(h+lightOffset))
		def lamp_add(x, y, rx, rz):
			bpy.ops.object.light_add(
				type="SUN",
				location=((x,y,lightHeight)),
				rotation=(rx, 0, rz)
			)
			context.active_object.data.energy = 0.5
		lamp_add(w+lightOffset, h+lightOffset, -rx, -rz)
		lamp_add(-w-lightOffset, h+lightOffset, -rx, rz)
		lamp_add(-w-lightOffset, -h-lightOffset, rx, -rz)
		lamp_add(w+lightOffset, -h-lightOffset, rx, rz)
		
		create_rectangle(context, w, h)
		align_view(context.object)
		
		return {"FINISHED"}
开发者ID:vvoovv,项目名称:bcga,代码行数:29,代码来源:__init__.py

示例4: lift_drag

    def lift_drag(self, state_vector, t, vec = [-1, 0, 1]):
        """
        vec = [-1, 0, 1]
        Drag versor in capsule coordinate system
        """
        x, y, vx, vy = state_vector

        # kąt promienia wodzącego
        tau_r = atan(-x/y)

        # Flight Patch Angle
        FPA = atan(vy/vx)

        # convert time to positive numbers
        t = t + self.SUFR_duration_total

        # Bank change time (from charts, approx)
        roll_time = 10          # s

        #~ if t <= roll_time:
            #~ AoA = self.AoA_at_SUFR_start*(1-t*(1./roll_time))
        #~ elif t > roll_time:
            #~ AoA = 0.
        AoA = self.AoA_function(t)*cos(self.bank_function(t))
        # tau_r > 0; FPA < 0, AoA > 0
        # everything should be < 0
        Ex, Ey, __ = np.matrix(vec).dot(self.obrot_o_kat(-tau_r +FPA -AoA)).tolist()[0]
        return Ex, Ey
开发者ID:arkhebuz,项目名称:ebmd,代码行数:28,代码来源:MSL_EV.py

示例5: gazePix

 def gazePix(self,anglex,angley):
     """Converts gaze angle to monitor pixel"""
     alphax = math.degrees(math.atan(self.ledx/self.monitordistance))
     pixx = self.deg2pix(anglex-alphax)
     alphay = math.degrees(math.atan(self.ledy/self.monitordistance))
     pixy = self.deg2pix(angley-alphay)
     return pixx,pixy
开发者ID:neuromind81,项目名称:aibs,代码行数:7,代码来源:Eyetracker.py

示例6: trouverInfoRobot

    def trouverInfoRobot(self, contourGauche, contourDroit):
        centreGauche = self.trouverCentre(contourGauche)
        centreDroit = self.trouverCentre(contourDroit)
        centreRobot = (int(round((centreDroit[0]+centreGauche[0])/2)), int(round((centreDroit[1]+centreGauche[1])/2)))
        deltaX = centreDroit[0]-centreGauche[0]
        deltaY = -1*(centreDroit[1]-centreGauche[1])
        if not deltaX == 0:
            pente = deltaY/deltaX

        if deltaY == 0 and deltaX < 0:
            angle = 180
        elif deltaY == 0 and deltaX > 0:
            angle = 0
        elif deltaX == 0 and deltaY > 0:
            angle = 90
        elif deltaX == 0 and deltaY < 0:
            angle = 270
        elif deltaX > 0 and deltaY > 0:
            angle = int(round(math.degrees(math.atan(pente))))
        elif deltaX > 0 and deltaY < 0:
            angle = 360 + int(round(math.degrees(math.atan(pente))))
        elif deltaX < 0:
            angle = 180 + int(round(math.degrees(math.atan(pente))))

        angle += 90
        if angle >= 360:
            angle -= 360

        return centreRobot, angle
开发者ID:jmprovencher,项目名称:Treasure-Picker-Robot,代码行数:29,代码来源:DetectionRobot.py

示例7: transform

def transform(x,y,z):
    initial_angle=math.acos(L/(4*l))#
    bed_angle=math.asin((z-square_z)/l)#
    leg_offset=l*math.cos(bed_angle)
    yprime=y+y_offset-leg_offset
    xprime=x+L/2
    topz=((d/2-y)/d)*front_z+(1-(d/2-y)/d)*back_z
    bed_tilt=math.atan2(-back_z+front_z,d)
    yprime-=z*math.sin(bed_tilt)
    zprime=topz-z*math.cos(bed_tilt)
    left_leg=math.sqrt(xprime*xprime+yprime*yprime)
    right_leg=math.sqrt((L-xprime)*(L-xprime)+yprime*yprime)
    left_elbow=math.acos((left_leg*left_leg-2*l*l)/(-2*l*l))
    right_elbow=math.acos((right_leg*right_leg-2*l*l)/(-2*l*l))
    left_small_angle=(math.pi-left_elbow)/2
    right_small_angle=(math.pi-right_elbow)/2
    left_virtual=math.atan(-yprime/xprime)
    right_virtual=math.atan(-yprime/(L-xprime))
    left_drive=left_small_angle+left_virtual-initial_angle
    right_drive=right_small_angle+right_virtual-initial_angle
    left_stepper=-left_drive+(math.pi-left_elbow)*mechanical_advantage
    right_stepper=-right_drive+(math.pi-right_elbow)*mechanical_advantage
    #print "left_angle: "+str(left_drive)+" left_elbow: "+str(math.pi-left_elbow)
    #print "right_angle: "+str(left_drive)+" right_elbow: "+str(math.pi-right_elbow)
    return left_stepper*200/math.pi,right_stepper*200/math.pi,zprime
开发者ID:PDDixon,项目名称:ConceptFORGE,代码行数:25,代码来源:wally+segmentize.py

示例8: mu_2_1

def mu_2_1(ay, by):
    return (1.0 / (2.0 * by)) * \
            (2.0 * ay * \
                    (atan((1.0 - ay) / by) + atan((1.0 + ay) / by)) + \
              by * \
                    (log((-1.0 + ay) ** 2 + by ** 2) - \
                     log((1.0 + ay) ** 2 + by ** 2)))
开发者ID:tbenthompson,项目名称:quadracheer,代码行数:7,代码来源:rl135.py

示例9: GoToPoint

 def GoToPoint(self):
     self.brain.output.printf("go to point")
     PointY = self.B_Y + self.B_Y * (self.B_X - self.X_M)/(self.B_X - self.F_X)
     deltaX = self.R_X - self.X_M
     deltaY = abs(PointY - self.R_Y)
     deltaTheta = R_Theta - (pi - atan(deltaY/deltaX)) 
     dist = sqrt(deltaY * deltaY + deltaX * deltaX)
     forward = 0
     left = 0
     turnCCW = 0
     if dist > self.Radius:
         if R_Theta < pi - atan((deltaY + self.Radius)/deltaX):
             turnCCW = deltaTheta * sin(deltaTheta)#turnCCW=CLIP(deltaTheta,DEG_TO_RAD(-20),DEG_TO_RAD(20))
             self.brain.output.printf2('GoToPoint------turnCCW:::::::',turnCCW)
             self.brain.setWalk(1,0,0,turnCCW)
         elif R_Theta > pi - atan((deltaY - self.Radius)/deltaX):
             turnCCW = -deltaTheta * sin(deltaTheta)#rurnCCW=CLIP(-deltaTheta,DEG_TO_RAD(-20),DEG_TO_RAD(20))
             self.brain.output.printf2('GoToPoint------turnCCW:::::::',turnCCW)
             self.brain.setWalk(1,0,0,turnCCW)
         else:
             self.brain.setWalk(1,0,0,0)
         forward = dist * sin(dist)#or forward = 0.02 can be adopt
         left = dist * sin(dist)#or left = 0.02 can be adopt
         turnCCW = 0
         self.brain.setWalk(1,forward,left,turnCCW)
开发者ID:spyfree,项目名称:tjNaoBackup,代码行数:25,代码来源:rDefender.py

示例10: Meter2px

def Meter2px(h,vd,vd1,hd,nrows,ncols):
    ### real scale (unit : meter)
    #h  : building size
    #vd : distance between buliding to the bottom of the image
    #vd1: distance between bottom to up of the image
    #hd : horizontal distancd
    
    ### pixels based
    # nrows
    # ncols


    theta = math.atan(1.*vd/h) #radius 
    z=(h**2+vd**2)**0.5
    alpha = pi/2-theta
    beta = math.atan((vd+vd1)*1./h)-theta

    ydp = beta/ncols
    xdp = beta/nrows

    ylen = np.zeros(ncols)
    xlen = np.ones(nrows)*hd/nrows

    distance = vd
    for i in range(ncols):
        
        gamma = (theta+ydp*(1+i))
        pylen = h*math.tan(gamma)-distance # pixel length
        ylen[i] = pylen
        distance = distance+pylen

    print ylen[-1]/ylen[0]
    return xlen,ylen[::-1]
开发者ID:dawnknight,项目名称:tracking,代码行数:33,代码来源:meter2px.py

示例11: mu_6_0

def mu_6_0(ay, by):
    return ((-3.0 * (-1.0 + ay)**3.0 * by - 5.0 * (-1.0 + ay) * by**3.0)/\
            ((-1.0 + ay)**2.0 + by**2.0)**2.0 + \
            (3.0 * (1.0 + ay)**3.0 * by + 5.0 * (1.0 + ay) * by ** 3.0)/\
            ((1.0 + ay)**2.0 + by**2.0)**2.0 -
            3.0 * atan((-1.0 + ay)/by) + 3.0 * atan((1.0 + ay)/by))/\
                    (8.0 * by**5.0)
开发者ID:tbenthompson,项目名称:quadracheer,代码行数:7,代码来源:rl135.py

示例12: m2nu

def m2nu(m):
    if m < 1:
        raise ValueError('Mach number should be greater than or equal to 1')
    a = (GAMMA+1) / (GAMMA-1)
    b = m**2 - 1
    c = a**-1 * b
    return sqrt(a) * atan(sqrt(c)) - atan(sqrt(b))
开发者ID:iwarobots,项目名称:TunnelDesign,代码行数:7,代码来源:prandtl_meyer_function.py

示例13: __init__

    def __init__(self, central_longitude=0.0, satellite_height=35785831,
                 false_easting=0, false_northing=0, globe=None):
        proj4_params = [('proj', 'geos'), ('lon_0', central_longitude),
                        ('lat_0', 0), ('h', satellite_height),
                        ('x_0', false_easting), ('y_0', false_northing),
                        ('units', 'm')]
        super(Geostationary, self).__init__(proj4_params, globe=globe)

        # TODO: Factor this out, particularly if there are other places using
        # it (currently: Stereographic & Geostationary). (#340)
        def ellipse(semimajor=2, semiminor=1, easting=0, northing=0, n=200):
            t = np.linspace(0, 2 * np.pi, n)
            coords = np.vstack([semimajor * np.cos(t), semiminor * np.sin(t)])
            coords += ([easting], [northing])
            return coords

        # TODO: Let the globe return the semimajor axis always.
        a = np.float(self.globe.semimajor_axis or 6378137.0)
        b = np.float(self.globe.semiminor_axis or 6378137.0)
        h = np.float(satellite_height)
        max_x = h * math.atan(a / (a + h))
        max_y = h * math.atan(b / (b + h))

        coords = ellipse(max_x, max_y,
                         false_easting, false_northing, 60)
        coords = tuple(tuple(pair) for pair in coords.T)
        self._boundary = sgeom.polygon.LinearRing(coords)
        self._xlim = self._boundary.bounds[::2]
        self._ylim = self._boundary.bounds[1::2]
        self._threshold = np.diff(self._xlim)[0] * 0.02
开发者ID:fandres70,项目名称:cartopy,代码行数:30,代码来源:crs.py

示例14: get_vec_ang

def get_vec_ang(vec):
	'''
	Get the angle of a vector in [0,360).
	Input: a 2D vector
	Output: [0, 360)
	'''
	if (0 == vec[0]): # vx = 0
		if (vec[1] > 0):
			return 90
		elif (vec[1] < 0):
			return 270
		else:
			return 0
	else: # vx != 0
		if(0 == vec[1]): # vy = 0
			if(vec[0] > 0):
				return 0
			else:
				return 180
		else: # vx != 0, vy != 0
			temp = math.fabs(vec[1]/vec[0])
			if ( vec[0]>0 and vec[1]>0 ): # 1st quadrant 
				return math.atan(temp) * 180 / math.pi
			elif ( vec[0]<0 and vec[1]>0 ): # 2
				return (math.pi-math.atan(temp)) * 180 / math.pi
			elif ( vec[0]<0 and vec[1]<0 ): # 3
				return (math.pi+math.atan(temp)) * 180 / math.pi
			else: # 4
				return (2*math.pi-math.atan(temp)) * 180 / math.pi
开发者ID:princeward,项目名称:OmniBot,代码行数:29,代码来源:mcu_comm_node.py

示例15: generate_wind

def generate_wind(nodes, cells, prevailing_wind_bearing=270, average_wind_speed=7.0):
    import noise
    import math
    import numpy as np
    for n in nodes:
        wind_bearing = (int(round(180.0 * noise.pnoise3(n.x, n.y, n.z))) + 360) % 360  # in degrees
        wind_strength = (8 * noise.pnoise3(n.x, n.y, n.z)) + 16.0  # kmph

        # move the generated random wind bearing towards the prevailing wind a little
        wind_vector = np.add(np.array([wind_strength * math.cos(math.radians(90 - wind_bearing)),
                                       wind_strength * math.cos(math.radians(wind_bearing))]),
                             np.array([average_wind_speed * math.cos(math.radians(90 - prevailing_wind_bearing)),
                                       average_wind_speed * math.cos(math.radians(prevailing_wind_bearing))]))

        wind_strength = math.sqrt(math.pow(wind_vector[0], 2) + math.pow(wind_vector[1], 2)) #  sqrt((x2-x1)^2 + (y2-y1)^2) = vector magnitude
        wind_bearing = int(round(math.degrees(math.atan(wind_vector[1]/wind_vector[0])))) # tan-1((y2-y1)/x2-x1)) = vector bearing

        n.set_feature(['wind', 'bearing'], wind_bearing)
        n.set_feature(['wind', 'strength'], wind_strength)
        n.set_feature(['wind', 'vector', 'x'], wind_vector[0])
        n.set_feature(['wind', 'vector', 'y'], wind_vector[1])
        n.wind = Wind(wind_bearing, wind_strength, wind_vector)
    for c in cells:
        wind_vector = np.sum(np.array([n.wind.vector for n in c.nodes]), axis=0)
        wind_strength = math.sqrt(math.pow(wind_vector[0], 2) + math.pow(wind_vector[1], 2))  #  sqrt((x2-x1)^2 + (y2-y1)^2) = vector magnitude
        wind_bearing = int(round(math.degrees(math.atan(wind_vector[1]/wind_vector[0]))))  # tan-1((y2-y1)/x2-x1)) = vector bearing

        c.wind = Wind(wind_bearing, wind_strength, wind_vector)
开发者ID:samcorcoran,项目名称:everett,代码行数:28,代码来源:wind.py


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