Rotate in place to `angle_target_degrees` at `speed`
345681
def turn_to_angle(self, speed, angle_target_degrees, brake=True, block=True):
        
        assert self.odometry_thread_id, "odometry_start() must be called to track robot coordinates"

        # Make both target and current angles positive numbers between 0 and 360
        if angle_target_degrees < 0:
            angle_target_degrees += 360

        angle_current_degrees = math.degrees(self.theta)

        if angle_current_degrees < 0:
            angle_current_degrees += 360

        # Is it shorter to rotate to the right or left
        # to reach angle_target_degrees?
        if angle_current_degrees > angle_target_degrees:
            turn_right = True
            angle_delta = angle_current_degrees - angle_target_degrees
        else:
            turn_right = False
            angle_delta = angle_target_degrees - angle_current_degrees

        if angle_delta > 180:
            angle_delta = 360 - angle_delta
            turn_right = not turn_right

        log.debug("%s: turn_to_angle %s, current angle %s, delta %s, turn_right %s" %
            (self, angle_target_degrees, angle_current_degrees, angle_delta, turn_right))
        self.odometry_coordinates_log()

        if turn_right:
            self.turn_right(speed, angle_delta, brake, block)
        else:
            self.turn_left(speed, angle_delta, brake, block)

        self.odometry_coordinates_log()
1223864
def rotate_dom_by_yaw(self, dom_id, heading, centre_point=None):
        """"""
        pmts = self.pmts[self.pmts.dom_id == dom_id]
        if centre_point is None:
            centre_point = self.dom_positions[dom_id]

        for pmt in pmts:
            pmt_pos = np.array([pmt.pos_x, pmt.pos_y, pmt.pos_z])
            pmt_dir = np.array([pmt.dir_x, pmt.dir_y, pmt.dir_z])
            pmt_radius = np.linalg.norm(centre_point - pmt_pos)
            index = self._pmt_index_by_pmt_id[pmt.pmt_id]
            pmt_ref = self.pmts[index]

            dir_rot = qrot_yaw([pmt.dir_x, pmt.dir_y, pmt.dir_z], heading)
            pos_rot = pmt_pos - pmt_dir * pmt_radius + dir_rot * pmt_radius

            pmt_ref.dir_x = dir_rot[0]
            pmt_ref.dir_y = dir_rot[1]
            pmt_ref.dir_z = dir_rot[2]
            pmt_ref.pos_x = pos_rot[0]
            pmt_ref.pos_y = pos_rot[1]
            pmt_ref.pos_z = pos_rot[2]
        self.reset_caches()
825676
def rotate_pt(x_arr, y_arr, theta_deg, xoff=0, yoff=0):
    
    # TODO: use opencv acceleration if available
    a_arr = x_arr - xoff
    b_arr = y_arr - yoff
    cos_t = np.cos(np.radians(theta_deg))
    sin_t = np.sin(np.radians(theta_deg))
    ap = (a_arr * cos_t) - (b_arr * sin_t)
    bp = (a_arr * sin_t) + (b_arr * cos_t)
    return np.asarray((ap + xoff, bp + yoff))
1080511
def solve(self, angles0, target):
        """"""
        return self.optimizer.optimize(np.array(angles0), target)
1239711
def rotate(self, azimuth, axis=None):
        
        target = self._target

        y_axis = self._n_pose[:3, 1].flatten()
        if axis is not None:
            y_axis = axis
        x_rot_mat = transformations.rotation_matrix(azimuth, y_axis, target)
        self._n_pose = x_rot_mat.dot(self._n_pose)

        y_axis = self._pose[:3, 1].flatten()
        if axis is not None:
            y_axis = axis
        x_rot_mat = transformations.rotation_matrix(azimuth, y_axis, target)
        self._pose = x_rot_mat.dot(self._pose)
193873
def rotate_y(self, angle):
        
        axis_rotation(self.points, angle, inplace=True, axis='y')
1290170
def rotateZ(self, angle, axis_point=(0, 0, 0), rad=False):
        """"""
        if rad:
            angle *= 57.29578
        self.RotateZ(angle)
        if self.trail:
            self.updateTrail()
        return self
21784
def _update_textrotation(self, angle):
        """"""

        states = {0: 0, -90: 1, 180: 2, 90: 3}

        try:
            self.rotation_tb.state = states[round(angle)]
        except KeyError:
            self.rotation_tb.state = 0

        self.rotation_tb.toggle(None)
        self.rotation_tb.Refresh()
911154
def rotation_df(ATT):
    ''''''
    r = Matrix3()
    r.from_euler(radians(ATT.Roll), radians(ATT.Pitch), radians(ATT.Yaw))
    return r
1262109
def rotate_right(self, seconds=None):
        """"""
        self._move(speed=0, steering=-STEER_MAX, seconds=seconds)
1361863
def rotate(self, shift):
        '''
        
        '''
        self.child_corners.values[:] = np.roll(self.child_corners
                                                 .values, shift, axis=0)
        self.update_transform()
84555
function rotate(a, ang){
    return {
      x: a.x * Math.cos(ang) - a.y * Math.sin(ang),
      y: a.x * Math.sin(ang) + a.y * Math.cos(ang)};
  }
1037561
def z_angle_rotate(xy, theta):
    
    xy = np.array(xy).T
    theta = np.array(theta).T

    out = np.zeros_like(xy)
    out[...,0] = np.cos(theta)*xy[...,0] - np.sin(theta)*xy[...,1]
    out[...,1] = np.sin(theta)*xy[...,0] + np.cos(theta)*xy[...,1]

    return out.T
78681
def pts_rotate(pts=[], angle=[0.0], center=(0.0, 0.0)):
    '''
    '''
    assert isinstance(pts, list) and len(pts) > 0
    l_pt_prev = None
    for pt in pts:
        assert isinstance(pt, tuple)
        l_pt = len(pt)
        assert l_pt > 1
        for i in pt:
            assert isinstance(i, float)
        if l_pt_prev is not None:
            assert l_pt == l_pt_prev
        l_pt_prev = l_pt
    assert isinstance(angle, list)
    l_angle = len(angle)
    assert l_angle == l_pt-1
    for i in angle:
        assert isinstance(i, float)
        assert abs(i) <= 2*pi
    assert isinstance(center, tuple)
    assert len(center) == l_pt
    for i in center:
        assert isinstance(i, float)

    return [pt_rotate(pt, angle, center) for pt in pts]
999681
def pt_rotate(pt=(0.0, 0.0), angle=[0.0], center=(0.0, 0.0)):
    '''
    '''
    assert isinstance(pt, tuple)
    l_pt = len(pt)
    assert l_pt > 1
    for i in pt:
        assert isinstance(i, float)
    assert isinstance(angle, list)
    l_angle = len(angle)
    assert l_angle == l_pt-1
    for i in angle:
        assert isinstance(i, float)
        assert abs(i) <= 2*pi
    assert isinstance(center, tuple)
    assert len(center) == l_pt
    for i in center:
        assert isinstance(i, float)

    # Get vector from center to point and use to get relative polar coordinate.
    v_cart = [pt[i] - center[i] for i in range(l_pt)]

    # Length of vector needs to stay constant for new point.
    v_pol_l = [sqrt(v_cart[i]**2 + v_cart[i+1]**2) for i in range(l_angle)]
    v_pol_a = [(atan(v_cart[i+1] / v_cart[i]) if v_cart[i] != 0.0 else pi/2) + pi*int(pt[i] < center[i]) \
               for i in range(l_angle)]

    # Add rotation angle then convert back to cartesian vector.
    n_pol_a = [v_pol_a[i] + angle[i] for i in range(l_angle)]
    n_cart = [v_pol_l[0] * cos(n_pol_a[0])] + [v_pol_l[i] * sin(n_pol_a[i])\
                                               for i in range(l_angle)]

    # Add in the centre offset to get original offset from c.
    r = [n_cart[i] + center[i] for i in range(l_pt)]
    return tuple(r)
902817
def rotateX(self, angle):
        
        rad = angle * math.pi / 180
        cosa = math.cos(rad)
        sina = math.sin(rad)
        y = self.y * cosa - self.z * sina
        z = self.y * sina + self.z * cosa
        return Point3D(self.x, y, z)
4932
def on_for_degrees(self, speed, degrees, brake=True, block=True):
        
        speed_sp = self._speed_native_units(speed)
        self._set_rel_position_degrees_and_speed_sp(degrees, speed_sp)
        self._set_brake(brake)
        self.run_to_rel_pos()

        if block:
            self.wait_until('running', timeout=WAIT_RUNNING_TIMEOUT)
            self.wait_until_not_moving()