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


Python numpy.tan函数代码示例

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


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

示例1: latlon2xy

def latlon2xy(lat, lon, origin=(37.0, -118.0), az=0, km2deg=111.3195):
    """Project cartesian x,y coordinates to geographical lat,lon.

    Parameters
    -----------
    lat and lon : 2darrays in decimal degrees.

    origin : tuple or list, optional, default: lat=37.0 lon=-118.0
            lat,lon coordinates of the south-west corner of the x,y grid

    az : float or int, optional, default: 0 degrees
            rotation of the grid aroud the vertical (z-axis),
            see the SW4 User Guide for more information.

    km2deg : float, optional, default: 111.3195 km
            how many km to a degree.

    Returns
    --------
    x and y 2darrays."""

    az = np.radians(az)
    x = km2deg * (
        ((lat - origin[0]) +
         (lon - origin[1]) * np.cos(np.radians(lat)) * np.tan(az)) /
        (np.cos(az) * (1 + np.tan(az)**2)))
    y = (km2deg * ((lon - origin[1]) * np.cos(np.radians(lat))) /
         np.cos(az)) - x * np.tan(az)

    return x, y
开发者ID:jaabell,项目名称:pySW4,代码行数:30,代码来源:utils.py

示例2: calculate_fracture_step_sizes

def calculate_fracture_step_sizes(start_yx, ang):
    """
    Calculate the sizes of steps dx and dy to be used when "drawing" the
    fracture onto the grid.

    Parameters
    ----------
    start_yx : tuple of int
        Starting grid coordinates
    ang : float
        Fracture angle relative to horizontal (radians)

    Returns
    -------
    (dy, dx) : tuple of float
        Step sizes in y and x directions. One will always be unity, and the
        other will always be <1.
    """
    starty, startx = start_yx
    if startx==0:  # frac starts on left side
        dx = 1
        dy = tan(ang)
    else:  # frac starts on bottom side
        dy = 1
        dx = -tan(ang-pi/2)

    return (dy, dx)
开发者ID:kwentz10,项目名称:Cellular_Automata,代码行数:27,代码来源:fracture_grid.py

示例3: Reached

    def Reached(self, qdr, dist, flyby):
        # Calculate distance before waypoint where to start the turn
        # Turn radius:      R = V2 tan phi / g
        # Distance to turn: wpturn = R * tan (1/2 delhdg) but max 4 times radius
        # using default bank angle per flight phase
        turnrad = bs.traf.tas * bs.traf.tas /     \
                      (np.maximum(bs.traf.eps, np.tan(bs.traf.bank)) * g0)  \
                       # Turn radius in meters!

        next_qdr = np.where(self.next_qdr < -900., qdr, self.next_qdr)

        # Avoid circling by checking for flying away
        away     = np.abs(degto180(bs.traf.trk%360. - qdr%360.)) > 90. # difference large than 90

        # Ratio between distance close enough to switch to next wp when flying away
        # When within pro1 nm and flying away: switch also
        proxfact = 1.01 # Turnradius scales this contant , factor => [turnrad]
        incircle = dist<turnrad*proxfact
        circling = away*incircle # [True/False] passed wp,used for flyover as well


        # distance to turn initialisation point [m]
        self.turndist = flyby*np.abs(turnrad *
            np.tan(np.radians(0.5 * np.abs(degto180(qdr%360. - next_qdr%360.)))))


        # Check whether shift based dist is required, set closer than WP turn distance
        swreached = np.where(bs.traf.swlnav * ((dist < self.turndist)+circling))[0]

        # Return True/1.0 for a/c where we have reached waypoint
        return swreached
开发者ID:isabelmetz,项目名称:bluesky,代码行数:31,代码来源:activewpdata.py

示例4: project

	def project(self, p, radius, width, height) :
		#print p
		#print width
		#print height
		#print "radius"
		#print radius

		xFOV = 63.38
		yFOV = 48.25
		cx = width /2
		cy = height /2
		fx = cx / np.tan((xFOV/2) * np.pi / 180)
		fy = cy / np.tan((yFOV/2) * np.pi / 180)
		
		toball = np.zeros(3)
		toball[0] = (p[0] - cx) / fx
		toball[1] = -(p[1] - cy) / fy
		toball[2] = 1
		toball = toball / np.linalg.norm(toball) #normalize so we can then multiply by distance
		distance = self.pixel_radius / radius
		toball = toball * distance

		pose = Pose()
		pose.position = Point(toball[0], toball[1], toball[2])
		pose.orientation = Quaternion(0,0,0,1)
		#print "FOUND ORANGE BALL!!!!"
		#print toball
		return pose
开发者ID:iaq3,项目名称:gatlin,代码行数:28,代码来源:single_color_vision.py

示例5: __init__

    def __init__(self, ra_0, dec_0, dec_1, dec_2):
        """Lambert Conformal conic projection.

        LCC is a conic projection with an origin along the lines connecting
        the poles. It preserves angles, but is not equal-area,
        perspective or equistant.

        Its preferred use of for areas with predominant east-west extent
        at higher latitudes.

        As a conic projection, it depends on two standard parallels, i.e.
        intersections of the cone with the sphere. To minimize scale variations,
        these standard parallels should be chosen as small as possible while
        spanning the range in declinations of the data.

        For details, see Snyder (1987, section 15).

        Args:
            ra_0: RA that maps onto x = 0
            dec_0: Dec that maps onto y = 0
            dec_1: lower standard parallel
            dec_2: upper standard parallel (must not be -dec_1)
        """
        ConicProjection.__init__(self, ra_0, dec_0, dec_1, dec_2)
        # Snyder 1987, eq. 14-1, 14-2 and 15-1 to 15-3.
        self.dec_max = 89.99

        dec_1 *= self.deg2rad
        dec_2 *= self.deg2rad
        self.n = np.log(np.cos(dec_1)/np.cos(dec_2)) / \
        (np.log(np.tan(np.pi/4 + dec_2/2)/np.tan(np.pi/4 + dec_1/2)))
        self.F = np.cos(dec_1)*(np.tan(np.pi/4 + dec_1/2)**self.n)/self.n
        self.rho_0 = self._rho(dec_0)
开发者ID:rainwoodman,项目名称:skymapper,代码行数:33,代码来源:skymapper.py

示例6: execute

 def execute(self, fp):
     fp.rack.m = fp.module.Value
     fp.rack.z = fp.teeth
     fp.rack.pressure_angle = fp.pressure_angle.Value * np.pi / 180.
     fp.rack.thickness = fp.thickness.Value
     fp.rack.beta = fp.beta.Value * np.pi / 180.
     fp.rack.head = fp.head
     fp.rack._update()
     pts = fp.rack.points()
     pol = Wire(makePolygon(list(map(fcvec, pts))))
     if fp.beta.Value == 0:
         face = Face(Wire(pol))
         fp.Shape = face.extrude(fcvec([0., 0., fp.height.Value]))
     elif fp.double_helix:
         beta = fp.beta.Value * np.pi / 180.
         pol2 = Part.Wire(pol)
         pol2.translate(fcvec([0., np.tan(beta) * fp.height.Value / 2, fp.height.Value / 2]))
         pol3 = Part.Wire(pol)
         pol3.translate(fcvec([0., 0., fp.height.Value]))
         fp.Shape = makeLoft([pol, pol2, pol3], True, True)
     else:
         beta = fp.beta.Value * np.pi / 180.
         pol2 = Part.Wire(pol)
         pol2.translate(fcvec([0., np.tan(beta) * fp.height.Value, fp.height.Value]))
         fp.Shape = makeLoft([pol, pol2], True)
开发者ID:looooo,项目名称:FCGear,代码行数:25,代码来源:features.py

示例7: build_planar_surface

def build_planar_surface(geometry):
    """
    Builds the planar rupture surface from the openquake.nrmllib.models
    instance
    """
    # Read geometry from wkt
    geom = wkt.loads(geometry.wkt)
    top_left = Point(geom.xy[0][0],
                     geom.xy[1][0],
                     geometry.upper_seismo_depth)
    top_right = Point(geom.xy[0][1],
                      geom.xy[1][1],
                      geometry.upper_seismo_depth)
    strike = top_left.azimuth(top_right)
    dip_dir = (strike + 90.) % 360.
    depth_diff = geometry.lower_seismo_depth - geometry.upper_seismo_depth
    bottom_right = top_right.point_at(
        depth_diff / np.tan(geometry.dip * (np.pi / 180.)),
        depth_diff,
        dip_dir)
    bottom_left = top_left.point_at(
        depth_diff / np.tan(geometry.dip * (np.pi / 180.)),
        depth_diff,
        dip_dir)
    return PlanarSurface(1.0,
                         strike,
                         geometry.dip,
                         top_left,
                         top_right,
                         bottom_right,
                         bottom_left)
开发者ID:g-weatherill,项目名称:gmpe-smtk,代码行数:31,代码来源:conditional_simulation.py

示例8: fundamental_geometry_plot_data

def fundamental_geometry_plot_data(par):
    '''Returns the coordinates for line end points of the bicycle fundamental
    geometry.

    Parameters
    ----------
    par : dictionary
        Benchmark bicycle parameters.

    Returns
    -------
    x : ndarray
    z : ndarray

    '''
    d1 = np.cos(par['lam']) * (par['c'] + par['w'] -
                par['rR'] * np.tan(par['lam']))
    d3 = -np.cos(par['lam']) * (par['c'] - par['rF'] *
                np.tan(par['lam']))
    x = np.zeros(4, dtype=object)
    z = np.zeros(4, dtype=object)
    x[0] = 0.
    x[1] = d1 * np.cos(par['lam'])
    x[2] = par['w'] - d3 * np.cos(par['lam'])
    x[3] = par['w']
    z[0] = -par['rR']
    z[1] = -par['rR'] - d1 * np.sin(par['lam'])
    z[2] = -par['rF'] + d3 * np.sin(par['lam'])
    z[3] = -par['rF']

    return x, z
开发者ID:StefenYin,项目名称:BicycleParameters,代码行数:31,代码来源:geometry.py

示例9: get_corner_coordinates

    def get_corner_coordinates(self):
        inc = self.inclination

        llLat, llLon = self.get_ll_anchor()
        urLat, urLon = self.get_ur_anchor()

        if self.orbital_node == 'Ascending':

            ulLat, ulLon = od.ne_to_latlon(
                self.lat_center, self.lon_center,
                self.track_length/2,
                -num.tan(inc*d2r) * self.width/2)
            lrLat, lrLon = od.ne_to_latlon(
                self.lat_center, self.lon_center,
                -self.track_length/2,
                num.tan(inc*d2r) * self.width/2)

        elif self.orbital_node == 'Descending':
            urLat, urLon = od.ne_to_latlon(
                self.lat_center, self.lon_center,
                self.track_length/2,
                num.tan(inc*d2r) * self.width/2)
            llLat, llLon = od.ne_to_latlon(
                self.lat_center, self.lon_center,
                -self.track_length/2,
                -num.tan(inc*d2r) * self.width/2)

        return ((llLat, llLon), (ulLat, ulLon),
                (urLat, urLon), (lrLat, lrLon))
开发者ID:emolch,项目名称:pyrocko,代码行数:29,代码来源:insar.py

示例10: compute_voroni_area_of_triangle

def compute_voroni_area_of_triangle(w1,w2,l1,l2):
    """
    computes the part of the triangle for the Voroni area
    descriped in [1]

            x_i
          +
          |\
          | \
          |  \
        l1|   \l2
          |    \
          |     \
          |w1  w2\
          +-------+
        x_j  l3  x_{j+1}

    """
    # Check if triangle is obtuse in x_i
    if w1+w2 < pi/2.0:
        # Then get Area(T)/2
        return norm(cross(l1,l2))/4.0
    
    if w1 > pi/2.0 or w2 > pi/2:
        # Then get Area(T)/4
        return norm(cross(l1,l2))/8.0
            

    #Else use formula on page 9 in [1]
    return ((1/tan(w1))*inner(l2,l2) + (1/tan(w2))*inner(l1,l1))/8.0
开发者ID:maldun,项目名称:MyMesh,代码行数:30,代码来源:Tools.py

示例11: draw

    def draw(self, output="plot.png", label=None):
        """ draw the wave structure """

        print(self.left_pos, self.contact_pos, self.right_pos)

        # each wave has a point on the origin.  The maximum height we
        # want to draw to is self.dx -- we'll do the center and right
        x1 = self.x0 + self.dx * np.tan(np.radians(self.left_pos))
        xc = self.x0 + self.dx * np.tan(np.radians(self.contact_pos))
        x3 = self.x0 + self.dx * np.tan(np.radians(self.right_pos))

        # draw the waves
        if self.left_type == "shock":
            plt.plot([self.x0, x1], [0, self.dx], color="C0", lw=3)
        else:
            for n in range(5):
                x1 = self.x0 + self.dx * np.tan(np.radians(self.left_pos - 2*n))
                plt.plot([self.x0, x1], [0, self.dx], color="C0", lw=1)

        plt.plot([self.x0, xc], [0, self.dx], color="C1")

        if self.right_type == "shock":
            plt.plot([self.x0, x3], [0, self.dx], color="C0", lw=3)
        else:
            for n in range(5):
                x3 = self.x0 + self.dx * np.tan(np.radians(self.right_pos + 2*n))
                plt.plot([self.x0, x3], [0, self.dx], color="C0", lw=1)
开发者ID:Open-Astrophysics-Bookshelf,项目名称:numerical_exercises,代码行数:27,代码来源:multiple_interfaces.py

示例12: publish

 def publish(self, event):
     if self.imgmsg is None:
         return
     now = rospy.Time.now()
     # setup ros message and publish
     with self.lock:
         self.imgmsg.header.stamp = now
         self.imgmsg.header.frame_id = self.frame_id
     self.pub.publish(self.imgmsg)
     if self.publish_info:
         info = CameraInfo()
         info.header.stamp = now
         info.header.frame_id = self.frame_id
         info.width = self.imgmsg.width
         info.height = self.imgmsg.height
         if self.fovx is not None and self.fovy is not None:
             fx = self.imgmsg.width / 2.0 / \
                 np.tan(np.deg2rad(self.fovx / 2.0))
             fy = self.imgmsg.height / 2.0 / \
                 np.tan(np.deg2rad(self.fovy / 2.0))
             cx = self.imgmsg.width / 2.0
             cy = self.imgmsg.height / 2.0
             info.K = np.array([fx, 0, cx,
                                0, fy, cy,
                                0, 0, 1.0])
             info.P = np.array([fx, 0, cx, 0,
                                0, fy, cy, 0,
                                0, 0, 1, 0])
             info.R = [1, 0, 0, 0, 1, 0, 0, 0, 1]
         self.pub_info.publish(info)
开发者ID:jsk-ros-pkg,项目名称:jsk_recognition,代码行数:30,代码来源:image_publisher.py

示例13: cone_to_plane

def cone_to_plane(theta, a_max):
    '''
    convert the cone to plane
    '''
    h = 1./np.tan(a_max)
    sl = h*np.tan(theta)
    return sl
开发者ID:danustc,项目名称:Optics,代码行数:7,代码来源:geometry_elements.py

示例14: get_distance_matrix

def get_distance_matrix(pan, fov, height, rows):
    """
        画像と同じ行数で一列の配列を返す。
        それぞれの行にはcameraからcenterまでの距離が入ってる。

        src: pan       -> カメラの傾き   [radian]
             fov       -> カメラの視野角 [radian]
             height    -> 地面からカメラまでの高さ [m]
             rows      -> 画像の縦方向のピクセル数 [pixel]

        dst: dis       -> 距離の真値
             dis_ratio -> dis[row] / dis[len(rows)]の値(画像中心からの距離の比)
    """

    # Convert radian -> degree
    pan = 1.0 * pan * np.pi / 180
    fov = 1.0 * fov * np.pi / 180
    dis = []
    dis_ratio = []

    for row in range(rows - 1, -1, -1):
        # dis.append( height * np.tan(1.*row*fov/rows + pan - 1.*fov/2))
        dis_ratio.append(np.tan(1.0 * row * fov / rows + pan - 1.0 * fov / 2) / np.tan(pan))

    return dis_ratio
开发者ID:DriesDries,项目名称:shangri-la,代码行数:25,代码来源:feature_extraction.py

示例15: nominal_q

def nominal_q(sx, sy, az_in, el_in, az_out, el_out, dz):
    nx, ny = sx + dz * tan(az_in), sy + dz * tan(el_in)
    nd = sqrt( (nx-sx)**2 + (ny-sy)**2 + dz**2 )
    #plt.subplot(131); plot(nx/5,ny/5,'G: direct flight beam center')

    px, py = sx + dz * tan(az_out), sy + dz * tan(el_out)
    pd = sqrt( (px-sx)**2 + (py-sy)**2 + dz**2 )
    #plt.subplot(122); plot(px/5,py/5,'G: direct flight scattered beam')

    if 0:
        # Correction to move px,py into the q normal plane.  This is
        # insignificant for small angle scattering.
        nx_hat, ny_hat, nz_hat = (nx-sx)/nd, (ny-sy)/nd, dz/nd
        px_hat, py_hat, pz_hat = (px-sx)/pd, (py-sy)/pd, dz/pd
        d = nd / (px_hat*nx_hat + py_hat*ny_hat + pz_hat*nz_hat)
        px, py = sx + px_hat*d, sy + py_hat*d
    #plt.subplot(122); plot((px)/5,(py)/5,'G: scattered beam on q normal plane')

    # Note: px,py is the location of the scattered neutron relative to the
    # beam center without gravity in detector coordinates, not the qx,qy vector
    # in inverse coordinates.  This allows us to compute the scattered angle at 
    # the sample, returning theta and phi.
    qd = sqrt((px-nx)**2 + (py-ny)**2)
    theta, phi = arctan2(qd, nd)/2, arctan2(py-ny, px-nx)

    return theta, phi
开发者ID:pkienzle,项目名称:sansresolution,代码行数:26,代码来源:res.py


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