python类tan()的实例源码

operators.py 文件源码 项目:Gaia 作者: splcurran 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def tHighDotOperator(stack, z, mode):
    if mode == 1:   # num
        stack.append(utilities.formatNum(math.tan(z)))
    elif mode == 2: # str
        if z == "":
            stack.append("")
        else:
            stack.append(z + z[-2::-1])
    elif mode == 3: # list
        if z == []:
            stack.append([])
        else:
            stack.append(z + z[-2::-1])
    else:
        monadNotImplemented(mode, '')

# ?
ray_caster.py 文件源码 项目:codecad 作者: bluecube 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def get_camera_params(box, size, view_angle):
    box_size = box.size()

    size_diagonal = math.hypot(*size)

    if view_angle is None:
        focal_length = size_diagonal  # Normal lens by default
    else:
        focal_length = size_diagonal / (2 * math.tan(math.radians(view_angle) / 2))

    distance = focal_length * max(_zero_if_inf(box_size.x) / size[0],
                                  _zero_if_inf(box_size.z) / size[1])

    if distance == 0:
        distance = 1

    distance *= 1.2  # 20% margin around the object

    origin = box.midpoint() - util.Vector(0, distance + _zero_if_inf(box_size.y) / 2, 0)
    direction = util.Vector(0, 1, 0)
    up = util.Vector(0, 0, 1)

    return (origin, direction, up, focal_length)
ray_caster.py 文件源码 项目:codecad 作者: bluecube 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def get_camera_params(box, size, view_angle):
    box_size = box.size()

    size_diagonal = math.hypot(*size)

    if view_angle is None:
        focal_length = size_diagonal  # Normal lens by default
    else:
        focal_length = size_diagonal / (2 * math.tan(math.radians(view_angle) / 2))

    distance = focal_length * max(_zero_if_inf(box_size.x) / size[0],
                                  _zero_if_inf(box_size.z) / size[1])

    if distance == 0:
        distance = 1

    distance *= 1.2  # 20% margin around the object

    origin = box.midpoint() - util.Vector(0, distance + _zero_if_inf(box_size.y) / 2, 0)
    direction = util.Vector(0, 1, 0)
    up = util.Vector(0, 0, 1)

    return (origin, direction, up, focal_length)
wmb_importer.py 文件源码 项目:Nier2Blender 作者: C4nf3ng 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def construct_armature(name, bone_data_array):          # bone_data =[boneIndex, boneName, parentIndex, parentName, bone_pos, optional ]
    print('[+] importing armature')
    bpy.ops.object.add(
        type='ARMATURE', 
        enter_editmode=True,
        location=(0,0,0))
    ob = bpy.context.object
    ob.show_x_ray = False
    ob.name = name
    amt = ob.data
    amt.name = name +'Amt'
    for bone_data in bone_data_array:   
        bone = amt.edit_bones.new(bone_data[1])
        bone.head = Vector(bone_data[4]) 
        bone.tail = Vector(bone_data[4]) + Vector((0 , 0.01, 0))
    bones = amt.edit_bones
    for bone_data in bone_data_array:
        if bone_data[2] < 0xffff:                       #this value need to edit in different games
            bone = bones[bone_data[1]]
            bone.parent = bones[bone_data[3]]
            bones[bone_data[3]].tail = bone.head
    bpy.ops.object.mode_set(mode='OBJECT')
    ob.rotation_euler = (math.tan(1),0,0)
    #split_armature(amt.name)                           #current not used
    return ob
wmb_importer.py 文件源码 项目:Nier2Blender 作者: C4nf3ng 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def split_armature(name):
    amt = bpy.data.armatures[name]
    name = name.replace('Amt','')
    bones = amt.bones
    root_bones = [bone for bone in bones if not bone.parent]
    for i in range(len(root_bones)):
        bpy.ops.object.add(
            type='ARMATURE', 
            enter_editmode=True,
            location=(i * 2,0,0))
        ob_new = bpy.context.object
        ob_new.show_x_ray = False
        ob_new.name = "%s_%d" % (name, i)
        amt_new = ob_new.data
        amt_new.name = '%s_%d_Amt' % (name, i)
        copy_bone_tree(root_bones[i] ,amt_new)
        bpy.ops.object.mode_set(mode="OBJECT")
        ob_new.rotation_euler = (math.tan(1),0,0)
    bpy.ops.object.select_all(action="DESELECT")
    obj = bpy.data.objects[name]
    scene = bpy.context.scene
    scene.objects.unlink(obj)
    return False
vefm_271.py 文件源码 项目:bpy_lambda 作者: bcongdon 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def ellipsecomp(self, efactor, theta):
        if theta == self.a90:
            result = self.a90
        elif theta == self.a180:
            result = self.a180
        elif theta == self.a270:
            result = self.a270
        elif theta == self.a360:
            result = 0.0
        else:
            result = atan(tan(theta) / efactor ** 0.5)
            if result < 0.0:
                if theta > self.a180:
                    result = result + self.a180
                elif theta < self.a180:
                    result = result + self.a180

            if result > 0.0:
                if theta > self.a180:
                    result = result + self.a180
                elif theta < self.a180:
                    result = result
        return result
geodesic_classes_271.py 文件源码 项目:bpy_lambda 作者: bcongdon 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def ellipsecomp(self, efactor, theta):
        if theta == self.a90:
            result = self.a90
        elif theta == self.a270:
            result = self.a270
        else:
            result = atan(tan(theta) / efactor**0.5)
            if result >= 0.0:
                x = result
                y = self.a180 + result
                if fabs(x - theta) <= fabs(y - theta):
                    result = x
                else:
                    result = y
            else:
                x = self.a180 + result
                y = result

                if fabs(x - theta) <= fabs(y - theta):
                    result = x
                else:
                    result = y
        return result
portrait_plus.py 文件源码 项目:AutoPortraitMatting 作者: PetroWu 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def rotateNormalizedCord(self, matx, maty, angle):
        h, w = matx.shape
        x_avg = np.mean(matx)
        x_min = np.min(matx)
        y_avg = np.mean(maty)
        y_min = np.min(maty)
        xmat = np.zeros((h, w), dtype=np.float)
        ymat = np.zeros((h, w), dtype=np.float)
        for k in range(h):
            for j in range(w):
                cor_y = k - h / 2
                cor_x = j - w / 2
                if cor_x == 0 and cor_y == 0:
                    xmat[k][j] = x_avg
                    ymat[k][j] = y_avg
                else:
                    x_dis = math.cos(math.pi / 2 - angle) * (-math.tan(math.pi / 2 - angle) * cor_x + cor_y)
                    xmat[k][j] = x_avg - (x_avg - x_min) * x_dis * 2 / w
                    y_dis = math.cos(angle) * (math.tan(angle) * cor_x + cor_y)
                    ymat[k][j] = y_avg + (y_avg - y_min) * y_dis * 2 / h
        return xmat, ymat
util.py 文件源码 项目:Houston 作者: squaresLab 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def BodyRatesToEarthRates(dcm, gyro):
    """Convert the angular velocities from body frame to
    earth frame.

    all inputs and outputs are in radians/s

    returns a earth rate vector.
    """
    from math import sin, cos, tan, fabs

    p      = gyro.x
    q      = gyro.y
    r      = gyro.z

    (phi, theta, psi) = dcm.to_euler()

    phiDot   = p + tan(theta) * (q * sin(phi) + r * cos(phi))
    thetaDot = q * cos(phi) - r * sin(phi)
    if fabs(cos(theta)) < 1.0e-20:
        theta += 1.0e-10
    psiDot   = (q * sin(phi) + r * cos(phi)) / cos(theta)
    return Vector3(phiDot, thetaDot, psiDot)
test_vehicle.py 文件源码 项目:burro 作者: yconst 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_vehicle_pipeline(self):
        throttle = random.uniform(-1.0, 1.0)
        angle = random.uniform(-1.0, 1.0) * config.car.max_steering_angle

        l_a = config.car.L
        w_d = config.car.W
        w_o = config.car.W_offset
        angle_radians = math.radians(angle)
        steer_tan = math.tan(angle_radians)
        r = l_a / steer_tan
        l_out = throttle * (1.0 - (w_d * 0.5 - w_o)/r ) * \
            config.differential_car.left_mult
        r_out = throttle * (1.0 + (w_d * 0.5 + w_o)/r ) * \
            config.differential_car.right_mult
        l_out = min(max(l_out, -1), 1)
        l_out = min(max(l_out, -1), 1)

        self.vehicle.pilot().set_response(angle, throttle)
        self.vehicle.step()

        self.assertAlmostEqual(self.vehicle.mixer.left_driver.output,
                               l_out, places=5)
        self.assertAlmostEqual(self.vehicle.mixer.right_driver.output,
                               r_out, places=5)
transform.py 文件源码 项目:Imagyn 作者: zevisert 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def skew_image(img, angle):
    """
    Skew image using some math
    :param img: PIL image object
    :param angle: Angle in radians (function doesn't do well outside the range -1 -> 1, but still works)
    :return: PIL image object
    """
    width, height = img.size
    # Get the width that is to be added to the image based on the angle of skew
    xshift = tan(abs(angle)) * height
    new_width = width + int(xshift)

    if new_width < 0:
        return img

    # Apply transform
    img = img.transform(
        (new_width, height),
        Image.AFFINE,
        (1, angle, -xshift if angle > 0 else 0, 0, 1, 0),
        Image.BICUBIC
    )

    return img
dxf2gcode_v01_nurbs_calc.py 文件源码 项目:G71 作者: nkp216 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def calc_curve(self,n=0,cpts_nr=20):

        #Anfangswerte fr Step und u
        u=0
        step=float(self.Knots[-1])/(cpts_nr-1)
        Points=[]

        #Wenn die erste Ableitung oder hher errechnet wird die ersten
        #Ableitung in dem tan als Winkel in rad gespeichert
        tang=[]

        while u<=self.Knots[-1]:
            CK=self.bspline_ders_evaluate(n=n,u=u)

            #Den Punkt in einem Punkt List abspeichern            
            Points.append(PointClass(x=CK[0][0],y=CK[0][1]))

            #Fr die erste Ableitung wird den Winkel der tangente errechnet
            if n>=1:
                tang.append(atan2(CK[1][1],CK[1][0]))   
            u+=step

        return Points, tang

    #Modified Version of Algorithm A3.2 from "THE NURBS BOOK" pg.93
dxf2gcode_v01_nurbs_calc.py 文件源码 项目:G71 作者: nkp216 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def calc_curve(self,n=0,cpts_nr=20):

        #Anfangswerte fr Step und u
        u=0
        step=float(self.Knots[-1])/(cpts_nr-1)
        Points=[]

        #Wenn die erste Ableitung oder hher errechnet wird die ersten
        #Ableitung in dem tan als Winkel in rad gespeichert
        tang=[]

        while u<=self.Knots[-1]:
            CK=self.bspline_ders_evaluate(n=n,u=u)

            #Den Punkt in einem Punkt List abspeichern            
            Points.append(PointClass(x=CK[0][0],y=CK[0][1]))

            #Fr die erste Ableitung wird den Winkel der tangente errechnet
            if n>=1:
                tang.append(atan2(CK[1][1],CK[1][0]))   
            u+=step

        return Points, tang

    #Modified Version of Algorithm A3.2 from "THE NURBS BOOK" pg.93
astral.py 文件源码 项目:respeaker_virtualenv 作者: respeaker 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def _eq_of_time(self, juliancentury):
        epsilon = self._obliquity_correction(juliancentury)
        l0 = self._geom_mean_long_sun(juliancentury)
        e = self._eccentrilocation_earth_orbit(juliancentury)
        m = self._geom_mean_anomaly_sun(juliancentury)

        y = tan(radians(epsilon) / 2.0)
        y = y * y

        sin2l0 = sin(2.0 * radians(l0))
        sinm = sin(radians(m))
        cos2l0 = cos(2.0 * radians(l0))
        sin4l0 = sin(4.0 * radians(l0))
        sin2m = sin(2.0 * radians(m))

        Etime = y * sin2l0 - 2.0 * e * sinm + 4.0 * e * y * sinm * cos2l0 - \
            0.5 * y * y * sin4l0 - 1.25 * e * e * sin2m

        return degrees(Etime) * 4.0
plot_heating_correlations.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def getRadius(ra,dec):

    # M31 properties
    PA = 38.1
    inclin = 77.5
    centre = [10.77615,41.353394] # Center of our current FOV.
    #centre = [10.612508,41.208711] # Center from Viaene et al 2014
    dist = 0.785

    #Deproject the pixels to a physical radial distance.
    # convert angles to radians
    PA = ((90.-PA) / 180.0 * math.pi)
    inclin = inclin / 180.0 * math.pi

    radius = np.zeros(len(ra))
    for i in range(0,len(ra)):
        Xsquare = ((ra[i] - centre[0])*math.cos(dec[i] / 180.0 * math.pi)*math.cos(PA) + (dec[i] - centre[1])*math.sin(PA))**2
        Ysquare = (-(ra[i] - centre[0])*math.cos(dec[i] / 180.0 * math.pi)*math.sin(PA) + (dec[i] - centre[1])*math.cos(PA))**2
        radius[i] = math.sqrt(Xsquare + Ysquare / math.cos(inclin)**2.0)
        radius[i] = 2.0 * dist * 1000.0 * math.tan(radius[i]*math.pi/(180.0*2.0))

    return radius
ackerman.py 文件源码 项目:prototype 作者: chutsu 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def ackerman_model(x, u, L, dt):
    """Ackerman model

    Parameters
    ----------
    x :

    u :

    L :

    dt :


    Returns
    -------

    """
    g1 = x[0] + u[0] * cos(x[2]) * dt
    g2 = x[1] + u[0] * sin(x[2]) * dt
    g3 = x[2] + ((u[0] * tan(x[2])) / L) * dt

    return np.array([g1, g2, g3])
common.py 文件源码 项目:prototype 作者: chutsu 项目源码 文件源码 阅读 80 收藏 0 点赞 0 评论 0
def focal_length(image_width, image_height, fov):
    """Calculate focal length in the x and y axis from:
    - image width
    - image height
    - field of view

    Parameters
    ----------
    image_width : int
        Image width
    image_height : int
        Image height
    fov : float
        Field of view

    Returns
    -------
    (fx, fy) : (float, float)
        Focal length in x and y axis

    """
    fx = (image_width / 2.0) / tan(deg2rad(fov) / 2.0)
    fy = (image_height / 2.0) / tan(deg2rad(fov) / 2.0)
    return (fx, fy)
td.py 文件源码 项目:kicad_scripts 作者: NilujePerchut 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __ComputeCurved(vpercent, w, vec, via, pts, segs):
    """Compute the curves part points"""

    radius = via[1]/2.0

    # Compute the bezier middle points
    req_angle = asin(vpercent/100.0)
    oppside = tan(req_angle)*(radius-(w/sin(req_angle)))
    length = sqrt(radius*radius + oppside*oppside)
    d = req_angle - acos(radius/length)
    vecBC = [vec[0]*cos(d)+vec[1]*sin(d), -vec[0]*sin(d)+vec[1]*cos(d)]
    pointBC = via[0] + wxPoint(int(vecBC[0] * length), int(vecBC[1] * length))
    d = -d
    vecAE = [vec[0]*cos(d)+vec[1]*sin(d), -vec[0]*sin(d)+vec[1]*cos(d)]
    pointAE = via[0] + wxPoint(int(vecAE[0] * length), int(vecAE[1] * length))

    curve1 = __Bezier(pts[1], pointBC, pts[2], n=segs)
    curve2 = __Bezier(pts[4], pointAE, pts[0], n=segs)

    return curve1 + [pts[3]] + curve2
JensenOpenMDAOconnect.py 文件源码 项目:Jensen3D 作者: byuflowlab 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def conferenceWakeOverlap(X, Y, R):

    n = np.size(X)

    # theta = np.zeros((n, n), dtype=np.float)        # angle of wake from fulcrum
    f_theta = np.zeros((n, n), dtype=np.float)      # smoothing values for smoothing

    for i in range(0, n):
        for j in range(0, n):
            if X[i] < X[j]:
                z = R/np.tan(0.34906585)
                # print z
                theta = np.arctan((Y[j] - Y[i]) / (X[j] - X[i] + z))
                # print 'theta =', theta
                if -0.34906585 < theta < 0.34906585:
                    f_theta[i][j] = (1 + np.cos(9*theta))/2
                    # print f_theta

    # print z
    # print f_theta
    return f_theta
JensenOpenMDAOconnect.py 文件源码 项目:Jensen3D 作者: byuflowlab 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def conferenceWakeOverlap_tune(X, Y, R, boundAngle):

    n = np.size(X)
    boundAngle = boundAngle*np.pi/180.0
    # theta = np.zeros((n, n), dtype=np.float)      # angle of wake from fulcrum
    f_theta = np.zeros((n, n), dtype=np.float)      # smoothing values for smoothing
    q = np.pi/boundAngle                            # factor inside the cos term of the smooth Jensen (see Jensen1983 eq.(3))
    # print 'boundAngle = %s' %boundAngle, 'q = %s' %q
    for i in range(0, n):
        for j in range(0, n):
            if X[i] < X[j]:
                # z = R/tan(0.34906585)
                z = R/np.tan(boundAngle)               # distance from fulcrum to wake producing turbine
                # print z
                theta = np.arctan((Y[j] - Y[i]) / (X[j] - X[i] + z))
                # print 'theta =', theta

                if -boundAngle < theta < boundAngle:

                    f_theta[i][j] = (1. + np.cos(q*theta))/2.
                    # print f_theta

    # print z
    # print f_theta
    return f_theta
JensenOpenMDAOconnect.py 文件源码 项目:Jensen3D 作者: byuflowlab 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def get_cosine_factor_original(X, Y, R0, bound_angle=20.0):

    n = np.size(X)
    bound_angle = bound_angle*np.pi/180.0
    # theta = np.zeros((n, n), dtype=np.float)      # angle of wake from fulcrum
    f_theta = np.zeros((n, n), dtype=np.float)      # smoothing values for smoothing
    q = np.pi/bound_angle                           # factor inside the cos term of the smooth Jensen (see Jensen1983 eq.(3))

    for i in range(0, n):
        for j in range(0, n):
            if X[i] < X[j]:
                z = R0/np.tan(bound_angle)               # distance from fulcrum to wake producing turbine

                theta = np.arctan((Y[j] - Y[i]) / (X[j] - X[i] + z))

                if -bound_angle < theta < bound_angle:

                    f_theta[i][j] = (1. + np.cos(q*theta))/2.

    return f_theta
JensenOpenMDAOconnect.py 文件源码 项目:Jensen3D 作者: byuflowlab 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def conferenceWakeOverlap_bk(X, Y, R):
    from math import atan, tan, cos
    n = np.size(X)

    # theta = np.zeros((n, n), dtype=np.float)        # angle of wake from fulcrum
    f_theta = np.zeros((n, n), dtype=np.float)      # smoothing values for smoothing

    for i in range(0, n):
        for j in range(0, n):
            if X[i] < X[j]:
                z = R/tan(0.34906585)
                theta = atan(Y[j] - Y[i]) / (X[j] - X[i] + z)
                if -0.34906585 < theta < 0.34906585:
                    f_theta[i][j] = (1 + cos(9*theta))/2
                    # print f_theta

    return f_theta
bm_raytrace.py 文件源码 项目:performance 作者: python 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def render(self, canvas):
        fovRadians = math.pi * (self.fieldOfView / 2.0) / 180.0
        halfWidth = math.tan(fovRadians)
        halfHeight = 0.75 * halfWidth
        width = halfWidth * 2
        height = halfHeight * 2
        pixelWidth = width / (canvas.width - 1)
        pixelHeight = height / (canvas.height - 1)

        eye = Ray(self.position, self.lookingAt - self.position)
        vpRight = eye.vector.cross(Vector.UP).normalized()
        vpUp = vpRight.cross(eye.vector).normalized()

        for y in xrange(canvas.height):
            for x in xrange(canvas.width):
                xcomp = vpRight.scale(x * pixelWidth - halfWidth)
                ycomp = vpUp.scale(y * pixelHeight - halfHeight)
                ray = Ray(eye.point, eye.vector + xcomp + ycomp)
                colour = self.rayColour(ray)
                canvas.plot(x, y, *colour)
math_operation.py 文件源码 项目:vehicle_detection 作者: AuzanMuh 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def centeroidPinHoleMode(height, focal, altitude, theta, yCoordinate):
    # height : jumlah baris (piksel)
    # focal -> |A'O| : focal length (piksel)
    # altitude -> |O'O| : tinggi kamera (m)
    # theta : sudut kemiringan kamera (derajat)
    # yCoordinate : indeks piksel Y object
    height = float(height)
    focal = float(focal)
    theta = float(theta)
    yCoordinate = float(yCoordinate)

    delta = math.degrees(math.atan(math.fabs(yCoordinate - (height / 2)) / focal))

    if yCoordinate >= height / 2:
        lCentroid = altitude * math.tan(math.radians(theta + delta))
    else:
        lCentroid = altitude * math.tan(math.radians(theta - delta))

    lCentroid = round(lCentroid, 4)
    delta = round(delta, 4)

    # print "delta: {0} | lCentroid: {1}".format(delta, lCentroid)
    return lCentroid
math_operation.py 文件源码 项目:vehicle_detection 作者: AuzanMuh 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def getCoordinateFromDistance(height, focal, altitude, theta, distance):
    # height    : jumlah baris (piksel)
    # focal     : panjang focal length kamera (piksel)
    # altitude  : ketinggian kamera
    # theta     : kemiringan kamera
    # distance  : jarak yang ingin diketahui lokasinya

    distance = float(distance)
    altitude = float(altitude)
    focal = float(focal)

    alpha = math.degrees(math.atan(distance / altitude))
    delta = theta - alpha
    yCoordinate = focal * math.tan(math.radians(delta))
    yCoordinate += (height / 2)

    # print "alpha: {0} | delta: {1}".format(alpha, delta)
    return yCoordinate
test_numbers.py 文件源码 项目:pyshgp 作者: erp12 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_float_tan(self):
        i = '_float_tan'
        # 1
        before = {'_float': [0.0]}
        after = {'_float': [0.0]}
        self.assertTrue(t_u.run_test(before, after, i))
        # 2
        before = {'_float': [1.0]}
        after = {'_float': [math.tan(1.0)]}
        self.assertTrue(t_u.run_test(before, after, i))
        # 3
        before = {'_float': [0.5]}
        after = {'_float': [math.tan(0.5)]}
        self.assertTrue(t_u.run_test(before, after, i))
        # 4
        before = {'_float': [-0.5]}
        after = {'_float': [math.tan(-0.5)]}
        self.assertTrue(t_u.run_test(before, after, i))
MiscFunction.py 文件源码 项目:RefractiveIndex-Importer 作者: gr4ph0s 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def IOR(self,n,k):
        theta_deg = 0
        fresnel = []

        while theta_deg <= 90:
            theta = math.radians(theta_deg)
            a = math.sqrt((math.sqrt((n**2-k**2-(math.sin(theta))**2)**2 + ((4 * n**2) * k**2)) + (n**2 - k**2 - (math.sin(theta))**2))/2)
            b = math.sqrt((math.sqrt((n**2-k**2-(math.sin(theta))**2)**2 + ((4 * n**2) * k**2)) - (n**2 - k**2 - (math.sin(theta))**2))/2)

            Fs = (a**2+b**2-(2 * a * math.cos(theta))+(math.cos(theta))**2)/(a**2+b**2+(2 * a * math.cos(theta))+(math.cos(theta))**2)
            Fp = Fs * ((a**2+b**2-(2 * a * math.sin(theta) * math.tan(theta))+(math.sin(theta))**2*(math.tan(theta))**2)/(a**2+b**2+(2 * a * math.sin(theta) * math.tan(theta))+(math.sin(theta))**2*(math.tan(theta))**2))

            R = (Fs + Fp)/2
            fresnel.append(R)
            theta_deg += 1
        return fresnel
n44.py 文件源码 项目:Nordic44-Nordpool 作者: ALSETLab 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def change_prod_con(self, areas, prod, con, pf, tol=4,
                        row=None, column=None):
        """Wrapper function to change load and production
        Args:
            areas: area number
            prod: production
            con: consumption
            pf: power factor
            tol: tolerance for round
            row: which row to write to
            column: which column to write to
        """
        psspy.bsys(sid=0, numarea=1, areas=[areas])
        psspy.scal_2(0, 0, 0,
                     [0, 1, 1, 1, 0],
                     [con, prod,
                      0.0, 0.0, 0.0, 0.0,
                      round(con*math.tan(math.acos(pf)), tol)])
        if self.to_excel:
            self.sheet.cell(row=row, column=column).value = prod
            self.sheet.cell(row=row, column=column+1).value = con
pentaprism.py 文件源码 项目:freecad-pyoptools 作者: cihologramas 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def execute(self,obj):
        import Part,FreeCAD
        l2=obj.S.Value/2.

        q=2*l2*tan(radians(22.5))
        v1 = FreeCAD.Base.Vector(l2,-l2,-l2)
        v2 = FreeCAD.Base.Vector(l2,-l2,l2)
        v3 = FreeCAD.Base.Vector(-l2,-l2,l2+q)
        v4 = FreeCAD.Base.Vector(-l2-q,-l2,l2)
        v5 = FreeCAD.Base.Vector(-l2,-l2,-l2)

        l1= Part.makePolygon([v1,v2,v3,v4,v5,v1])
        F = Part.Face(Part.Wire(l1.Edges))
        d = F.extrude(FreeCAD.Base.Vector(0,2*l2,0))

        obj.Shape = d
rayspoint.py 文件源码 项目:freecad-pyoptools 作者: cihologramas 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def execute(self,obj):
        import Part,FreeCAD

        dist = obj.distribution.lower()


        if dist not in ["polar","cartesian"]:
            obj.distribution="polar"
            print "Ray Distribution not understood, changing it to polar"

        if dist == "polar":
            print obj.angle , type(obj.angle)
            r=5*tan(obj.angle.getValueAs("rad").Value)
            d=Part.makeCone(0,r,5)
            #d.translate(FreeCAD.Base.Vector(0,0,-0.5))
        else: #Cartesian
            #Todo: Change to piramis instead of a cone
            r=5*tan(obj.angle.getValueAs("rad").Value)
            d=Part.makeCone(0,r,5)
        obj.Shape = d


问题


面经


文章

微信
公众号

扫码关注公众号