python类rad2deg()的实例源码

number_recognition.py 文件源码 项目:Robo-Plot 作者: JackBuck 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _estimate_current_anticlockwise_degrees_using_minarearect(self, spot_xy) -> float:
        # Find the minimum area rectangle around the number
        nearby_contour_groups = contour_tools.extract_contour_groups_close_to(
            self.contour_groups, target_point_xy=spot_xy, delta=self._min_pixels_between_contour_groups)
        nearby_contours = [c for grp in nearby_contour_groups for c in grp]
        box = cv2.minAreaRect(np.row_stack(nearby_contours))
        corners_xy = cv2.boxPoints(box).astype(np.int32)
        self._log_contours_on_current_image([corners_xy], name="Minimum area rectangle")

        # Construct a vector which, once correctly rotated, goes from the bottom right corner up & left at 135 degrees
        sorted_corners = sorted(corners_xy, key=lambda pt: np.linalg.norm(spot_xy - pt))
        bottom_right_corner = sorted_corners[0]  # The closest corner to the spot
        adjacent_corners = sorted_corners[1:3]  # The next two closest corners

        unit_vectors_along_box_edge = misc.normalised(adjacent_corners - bottom_right_corner)
        up_left_diagonal = unit_vectors_along_box_edge.sum(axis=0)

        degrees_of_up_left_diagonal = np.rad2deg(np.arctan2(-up_left_diagonal[1], up_left_diagonal[0]))
        return degrees_of_up_left_diagonal - 135
image_analysis.py 文件源码 项目:Robo-Plot 作者: JackBuck 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def create_rotated_sub_image(image, centre, search_width, angle_rad):
    # Rotation transform requires x then y.
    M = cv2.getRotationMatrix2D((centre[1], centre[0]), np.rad2deg(angle_rad), 1.0)

    w = image.shape[1]
    h = centre[0] + int((image.shape[0] - centre[0]) * abs(math.sin(angle_rad)))
    rotated = cv2.warpAffine(image, M, (w, h))

    # Centre the last white centroid into the centre of the image.
    half_sub_image_width = int(min(min(search_width, centre[1]),
                                   min(rotated.shape[1] - centre[1], search_width)))

    sub_image = rotated[centre[0]:,
                centre[1] - half_sub_image_width: centre[1] + half_sub_image_width]

    return sub_image
helix.py 文件源码 项目:isambard 作者: woolfson-group 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def rotate_monomers(self, angle, radians=False):
        """ Rotates each Residue in the Polypeptide.

        Notes
        -----
        Each monomer is rotated about the axis formed between its
        corresponding primitive `PseudoAtom` and that of the 
        subsequent `Monomer`.

        Parameters
        ----------
        angle : float
            Angle by which to rotate each monomer.
        radians : bool
            Indicates whether angle is in radians or degrees.
        """
        if radians:
            angle = numpy.rad2deg(angle)
        for i in range(len(self.primitive) - 1):
            axis = self.primitive[i + 1]['CA'] - self.primitive[i]['CA']
            point = self.primitive[i]['CA']._vector
            self[i].rotate(angle=angle, axis=axis, point=point)
        return
vrep_env.py 文件源码 项目:vrep-env 作者: ycps 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def obj_get_joint_angle(self, handle):
        angle = self.RAPI_rc(vrep.simxGetJointPosition( self.cID,handle,
                vrep.simx_opmode_blocking
            )
        )
        return -np.rad2deg(angle[0])
make_photon_list.py 文件源码 项目:atoolbox 作者: liweitianux 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def cart2pol(x, y):
        rho = np.sqrt(x**2 + y**2)
        phi = 180 + np.rad2deg(np.arctan2(y, x))  # 0-360 [deg]
        return (rho, phi)
fixation_detector.py 文件源码 项目:esys-pbi 作者: fsxfreak 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def max_distance_deg(self):
        return np.rad2deg(self.max_distance)
kalman_tests.py 文件源码 项目:tea 作者: antorsae 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def process_lidar_csv_file(filename):
    with open(filename) as csvfile:
        reader = csv.DictReader(csvfile)

        csv_rows = [row for row in reader]
        print "%s lidar records" % len(csv_rows)

        n_limit_rows = 1000000

        lidar_obss = []
        bbox_obss = [[],[],[]]

        for i, row in enumerate(csv_rows):
            if i > n_limit_rows - 1:
                break

            time_ns = int(row['time'])
            x, y, z, yaw = float(row['x']), float(row['y']), float(row['z']), float(row['yaw'])
            l, w, h = float(row['l']), float(row['w']), float(row['h'])

            obs = LidarObservation(time_ns * 1e-9, x, y, z, yaw)
            lidar_obss.append(obs)

            bbox_obss[0].append(l)
            bbox_obss[1].append(w)
            bbox_obss[2].append(h)

        yaw = [np.rad2deg(o.yaw) for o in lidar_obss]
        print np.std(yaw)
        #plt.figure(figsize=(16,8))
        #plt.plot(yaw)
        #plt.grid(True)

        return lidar_obss, bbox_obss
View.py 文件源码 项目:em_examples 作者: geoscixyz 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def phase(z):
    val = np.angle(z)
    # val = np.rad2deg(np.unwrap(np.angle((z))))
    return val
Reflection.py 文件源码 项目:em_examples 作者: geoscixyz 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def getReflectionandTransmission(sig1, sig2, f, theta_i, eps1=epsilon_0, eps2=epsilon_0, mu1=mu_0, mu2=mu_0,dtype="TE"):
    """
    Compute reflection and refraction coefficient of plane waves
    """
    theta_i = np.deg2rad(theta_i)
    omega = 2*np.pi*f

    k1 = np.sqrt(omega**2*mu1*eps1-1j*omega*mu1*sig1)
    k2 = np.sqrt(omega**2*mu2*eps2-1j*omega*mu2*sig2)

    if dtype == "TE":
        bunmo = mu2*k1*np.cos(theta_i) + mu1*(k2**2-k1**2*np.sin(theta_i)**2)**0.5
        bunja_r = mu2*k1*np.cos(theta_i) - mu1*(k2**2-k1**2*np.sin(theta_i)**2)**0.5
        bunja_t = 2*mu2*k1*np.cos(theta_i)
    elif dtype == "TM":
        bunmo = mu2*k1*(k2**2-k1**2*np.sin(theta_i)**2)**0.5 + mu1*k2**2 * np.cos(theta_i)
        bunja_r = mu2*k1*(k2**2-k1**2*np.sin(theta_i)**2)**0.5 - mu1*k2**2 * np.cos(theta_i)
        bunja_t = 2*mu1*k2**2*np.cos(theta_i)
    else:
        raise Exception("XXX")

    r = bunja_r / bunmo
    t = bunja_t / bunmo

    theta_t = np.rad2deg(abs(np.arcsin(k1/k2 * np.sin(theta_i))))
    return r, t, theta_t
hyperellipsoid.py 文件源码 项目:wiicop 作者: barnabuskev 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def rotXYZ(R, unit='deg'):
    """ Compute Euler angles from matrix R using XYZ sequence."""

    angles = np.zeros(3)
    angles[0] = np.arctan2(R[2, 1], R[2, 2])
    angles[1] = np.arctan2(-R[2, 0], np.sqrt(R[0, 0]**2 + R[1, 0]**2))
    angles[2] = np.arctan2(R[1, 0], R[0, 0])

    if unit[:3].lower() == 'deg':  # convert from rad to degree
        angles = np.rad2deg(angles)

    return angles
py_sfm_depth_v1-1_py3.py 文件源码 项目:py_sfm_depth 作者: geojames 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def visibility(cam, footprints, targets):
    """    
    This function tests is the target points (x,y only) are "visable" (i.e.
    within the photo footprints) and calculates the "r" angle for the refraction 
    correction\n
    Vars:\n
    \t cam = Pandas dataframe (n x ~6, fields: x,y,z,yaw,pitch,roll)\n
    \t footprints = Pandas dataframe (n x 1) of Matplotlib Path objects\n
    \t targets = Pandas dataframe (n x ~3, fields: x,y,sfm_z...)\n

    RETURNS: r_filt = numpy array (n_points x n_cams) of filtered "r" angles.\n
    Points that are not visable to a camera will have a NaN "r" angle. 
    """

    # Setup boolean array for visability
    vis = np.zeros((targets.shape[0],cam.shape[0])) 

    # for each path objec in footprints, check is the points in targets are
    #   within the path polygon. path.contains_points returns boolean.
    #   the results are accumulated in the vis array.
    for idx in range(footprints.shape[0]):
        path = footprints.fov[idx]
        vis[:,idx] = path.contains_points(np.array([targets.x.values, targets.y.values]).T)

    # calculate the coord. deltas between the cameras and the target
    dx = np.atleast_2d(cam.x.values) - np.atleast_2d(targets.x.values).T
    dy = np.atleast_2d(cam.y.values) - np.atleast_2d(targets.y.values).T
    dz = np.atleast_2d(cam.z.values) - np.atleast_2d(targets.sfm_z).T

    # calc xy distance (d)
    d = np.sqrt((dx)**2+(dy)**2)

    # calc inclination angle (r) from targets to cams
    r = np.rad2deg(np.arctan(d/dz))

    r_filt = r * vis
    r_filt[r_filt == 0] = np.nan

    return r_filt
py_sfm_depth_v1-0.py 文件源码 项目:py_sfm_depth 作者: geojames 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def visibility(cam, footprints, targets):
    """    
    This function tests is the target points (x,y only) are "visable" (i.e.
    within the photo footprints) and calculates the "r" angle for the refraction 
    correction\n
    Vars:\n
    \t cam = Pandas dataframe (n x ~6, fields: x,y,z,yaw,pitch,roll)\n
    \t footprints = Pandas dataframe (n x 1) of Matplotlib Path objects\n
    \t targets = Pandas dataframe (n x ~3, fields: x,y,sfm_z...)\n

    RETURNS: r_filt = numpy array (n_points x n_cams) of filtered "r" angles.\n
    Points that are not visable to a camera will have a NaN "r" angle. 
    """

    # Setup boolean array for visability
    vis = np.zeros((targets.shape[0],cam.shape[0])) 

    # for each path objec in footprints, check is the points in targets are
    #   within the path polygon. path.contains_points returns boolean.
    #   the results are accumulated in the vis array.
    for idx in range(footprints.shape[0]):
        path = footprints.fov[idx]
        vis[:,idx] = path.contains_points(np.array([targets.x.values, targets.y.values]).T)

    # calculate the coord. deltas between the cameras and the target
    dx = np.atleast_2d(cam.x.values) - np.atleast_2d(targets.x.values).T
    dy = np.atleast_2d(cam.y.values) - np.atleast_2d(targets.y.values).T
    dz = np.atleast_2d(cam.z.values) - np.atleast_2d(targets.sfm_z).T

    # calc xy distance (d)
    d = np.sqrt((dx)**2+(dy)**2)

    # calc inclination angle (r) from targets to cams
    r = np.rad2deg(np.arctan(d/dz))

    r_filt = r * vis
    r_filt[r_filt == 0] = np.nan

    return r_filt
Launch_Manager.py 文件源码 项目:KRPC 作者: BevoLJ 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def insertion_pitch(self):
        _circ_dv = self.circ_dv()
        _t_ap_dv = self.target_apoapsis_speed_dv()
        _m = np.rad2deg(self.mean_anomaly())
        _burn_time = self.maneuver_burn_time(self.circ_dv())

        @jit(nopython=True)
        def pitch_calcs_low():
                return (_t_ap_dv * (_circ_dv / 1000)) + (_m - (180 - (_burn_time / 6)))

        @jit(nopython=True)
        def pitch_calcs_high():
                return (_t_ap_dv * (_circ_dv / 1000)) + (_m - 180)

        # if self.parking_orbit_alt <= 250000: return pitch_calcs_low()
        # else: return pitch_calcs_high()
        return pitch_calcs_high()
Lagadha.py 文件源码 项目:KRPC 作者: BevoLJ 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test(self):
        # -#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
        #             T E S T I N G              #
        # -#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#

        while True:
            print(np.rad2deg(self.moon_mean_anomaly()))
            time.sleep(1)
Lunar_Vanny_Launch_Program.py 文件源码 项目:KRPC 作者: BevoLJ 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def transfer(self):
        # -#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
        #               L U N A R                #
        #            T R A N S F E R             #
        # -#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#

        self.control.rcs = False
        self.control.throttle = 0
        time.sleep(1)
        self.ap.reference_frame = self.vessel.orbital_reference_frame
        self.ap.target_direction = (0, 1, 0)
        self.ap.engage()
        print(self.mode)

        while self.mode != "Xfered":
            self.injection_ETA = self.xfer_ETA(self.ut() + self.seconds_finder(5, 16, 00),
                                               self.moon_LAN(), self.moon_argument_of_periapsis())

            if self.mode == "Testing":
                print(np.rad2deg(self.moon_mean_anomaly()))
                self.mode = "Xfered"

            if self.mode == "LEO Cruise":
                self.KSC.warp_to(self.ut() + self.injection_ETA - 140)
                if self.injection_ETA < 130: self.mode = "AoA"; print(self.mode); time.sleep(2)

            if self.mode == "AoA":
                print(self.injection_ETA)
                if self.injection_ETA > 170: self.mode = "LEO Cruise"
                if self.injection_ETA > 25: self.fix_aoa(self.injection_ETA)
                elif self.injection_ETA <= 25: self.xfer()

            if self.mode == "Injection":
                self.flameout("Transfer")
                if self.vessel.mass < 20: self.mode = "Xfered"; print(self.mode)

            time.sleep(.1)

        print("Done")
quadplotter.py 文件源码 项目:evolvingcopter 作者: antocuni 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def update(self, quad):
        """
        Set the new position and rotation of the quadcopter: ``pos`` is a tuple
        (x, y, z), and rpy is a tuple (roll, pitch, yaw) expressed in
        *radians*
        """
        x, y, z = quad.position
        roll, pitch, yaw = np.rad2deg(quad.rpy)
        self.quadplot.resetTransform()
        self.quadplot.translate(x, y, z)
        self.quadplot.rotate(roll, 1, 0, 0, local=True)
        self.quadplot.rotate(pitch, 0, 1, 0, local=True)
        self.quadplot.rotate(yaw, 0, 0, 1, local=True)
        #
        self.label_t.setText('t = %5.2f' % quad.t)
windeval.py 文件源码 项目:POWER 作者: pennelise 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def convert_to_degspd(u,v):
    """Convert arrays of u,v vectors to arrays of direction (in met.deg) and speed

    Arguments:
    u - np array of the u (east) part of the vector
    v - np array of the v (north) part of the vector
    """
    dir_spd = [] 
    wind_direction = (np.rad2deg(np.arctan2(-u,-v))) % 360.0
    wind_speed = np.sqrt(u ** 2 + v ** 2)
    dir_spd.append(wind_direction)
    dir_spd.append(wind_speed)
    return np.array(dir_spd) #[[list of wind dirs], [list of wind spds]]
imutils.py 文件源码 项目:VLTPF 作者: avigan 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _rotate_interp_builtin(array, alpha, center, mode='constant', cval=0):
    '''
    Rotation with the built-in rotation function.

    The center of rotation is exactly ((dimx-1) / 2, (dimy-1) / 2),
    whatever the odd/even-ity of the image dimensions

    '''
    alpha_rad = -np.deg2rad(alpha)

    # center of rotation: ((dims[1]-1) / 2, (dims[0]-1) / 2)
    rotated = ndimage.interpolation.rotate(array, np.rad2deg(-alpha_rad), reshape=False, order=3, mode=mode, cval=cval)

    return rotated
visualization.py 文件源码 项目:pymoskito 作者: cklb 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def update_scene(self, x):
        x0 = x[0]
        phi1 = np.rad2deg(x[2])
        phi2 = np.rad2deg(x[4])

        # cart and shaft
        self.cart.set_x(-st.cart_length/2 + x0)
        self.pendulum_shaft.center = [x0, 0]

        t_phi1 = (mpl.transforms.Affine2D().rotate_deg_around(x0, 0, phi1)
                  + self.axes.transData)
        t_phi2 = (mpl.transforms.Affine2D().rotate_deg_around(x0, 0, phi2)
                  + self.axes.transData)

        # long pendulum
        self.long_pendulum.set_xy([-st.long_pendulum_radius + x0, 0])
        self.long_pendulum.set_transform(t_phi1)
        self.long_pendulum_weight.set_xy([-st.pendulum_weight_radius
                                          + x0, st.long_pendulum_height])
        self.long_pendulum_weight.set_transform(t_phi1)

        # short pendulum
        self.short_pendulum.set_xy(np.array([-st.short_pendulum_radius, 0])
                                   + np.array([x0, 0]))
        self.short_pendulum.set_transform(t_phi2)
        self.short_pendulum_weight.set_xy([-st.pendulum_weight_radius + x0,
                                           st.short_pendulum_height])

        self.short_pendulum_weight.set_transform(t_phi2)
        self.canvas.draw()
Display.py 文件源码 项目:freddie 作者: kunkkakada 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def transform(self, ppos, pdir, point):
        xr = point[0]-ppos[0]
        yr = point[1]-ppos[1]
        ang = angle_between360(pdir,northvector)
        #print np.rad2deg(ang)
        w = rotate([xr,yr],ang)
        return w+self.midpoint


问题


面经


文章

微信
公众号

扫码关注公众号