This works. Rotates the object about its center.
            
            Angle is specified in radians
506101
def rotate(self, angle):
        

        self.angle = (self.angle + angle) % (math.pi * 2.0)

        # precalculate these parameters
        c = math.cos(angle)
        s = math.sin(angle)
        px, py = self.center

        def _rotate_point(xy):

            x, y = xy

            x = x - px
            y = y - py

            return (x * c - y * s) + px, (x * s + y * c) + py

        # calculate rotation for each point
        self.pts = [p for p in map(lambda x: _rotate_point(x), self.pts)]
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
946995
def y_rotate(rotationAmt):
        """"""
        ma4 = Matrix4((math.cos(rotationAmt), 0, math.sin(rotationAmt), 0),
                      (0, 1, 0, 0),
                      (-math.sin(rotationAmt), 0, math.cos(rotationAmt), 0),
                      (0, 0, 0, 1))
        return ma4
720765
def axis_rotation(points, angle, inplace=False, deg=True, axis='z'):
    
    axis = axis.lower()

    # Copy original array to if not inplace
    if not inplace:
        points = points.copy()

    # Convert angle to radians
    if deg:
        angle *= np.pi / 180

    if axis == 'x':
        y = points[:, 1] * np.cos(angle) - points[:, 2] * np.sin(angle)
        z = points[:, 1] * np.sin(angle) + points[:, 2] * np.cos(angle)
        points[:, 1] = y
        points[:, 2] = z
    elif axis == 'y':
        x = points[:, 0] * np.cos(angle) + points[:, 2] * np.sin(angle)
        z = - points[:, 0] * np.sin(angle) + points[:, 2] * np.cos(angle)
        points[:, 0] = x
        points[:, 2] = z
    elif axis == 'z':
        x = points[:, 0] * np.cos(angle) - points[:, 1] * np.sin(angle)
        y = points[:, 0] * np.sin(angle) + points[:, 1] * np.cos(angle)
        points[:, 0] = x
        points[:, 1] = y
    else:
        raise Exception('invalid axis.  Must be either "x", "y", or "z"')

    if not inplace:
        return points
639313
function rotateX(out, a, b, c){
    var by = b[1]
    var bz = b[2]

    // Translate point to the origin
    var py = a[1] - by
    var pz = a[2] - bz

    var sc = Math.sin(c)
    var cc = Math.cos(c)

    // perform rotation and translate to correct position
    out[0] = a[0]
    out[1] = by + py * cc - pz * sc
    out[2] = bz + py * sc + pz * cc

    return out
}
828083
def rotate_x(self, angle):
        
        axis_rotation(self.points, angle, inplace=True, axis='x')
359535
def rotate_board(self, angle, unit='radian'):
        ''''''
        if unit == 'angle':
            angle = angle*math.pi/180

        angle %= 2*math.pi
        if angle not in [0, math.pi/2, math.pi, math.pi*3/2]:
            raise ValueError('Angle must be integral multiple of pi/2(90 degree)')

        new_pos = [[0 for _ in self.pos_range] for _ in self.pos_range]
        cos_ang = math.cos(angle)
        sin_ang = math.sin(angle)
        center = (self.board_size - 1)/2
        for x, y in comb(self.pos_range, 2):
            xt = int((x - center)*cos_ang - (y - center)*sin_ang + center)
            yt = int((x - center)*sin_ang + (y - center)*cos_ang + center)
            new_pos[xt][yt] = self.pos[x][y]
        return new_pos
996553
function() {
            this.x = this.body.p.x;
            this.y = this.body.p.y;
            this.rotation = this.body.a * RAD2DEG;
        }
1169036
def rotate(r, pos)
      return (0..2).map do |i|
        (0..2).inject(0) { |sum, j| sum + r[i][j] * pos[j] }
      end
    rescue => e
      raise
    end
1219742
def centerOn(self, point):
        
        rect = self.rect()
        x = point.x() - rect.width() / 2.0
        y = point.y() - rect.height() / 2.0
        
        self.setPos(x, y)
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)
1251474
function Rotate($angle, $x = -1, $y = -1)
	{
		if ($x == -1) {
			$x = $this->x;
		}
		if ($y == -1) {
			$y = $this->y;
		}
		if ($this->angle != 0) {
			$this->writer->write('Q');
		}
		$this->angle = $angle;
		if ($angle != 0) {
			$angle*=M_PI / 180;
			$c = cos($angle);
			$s = sin($angle);
			$cx = $x * Mpdf::SCALE;
			$cy = ($this->h - $y) * Mpdf::SCALE;
			$this->writer->write(sprintf('q %.5F %.5F %.5F %.5F %.3F %.3F cm 1 0 0 1 %.3F %.3F cm', $c, $s, -$s, $c, $cx, $cy, -$cx, -$cy));
		}
	}
65414
function pathRotate(contour, angle, centerX, centerY) {
            angle = angle === undefined ? 0 : angle;
            var x = centerX || 0;
            var y = centerY || 0;
            var cos = Math.cos(angle);
            var sin = Math.sin(angle);
            var px;
            var py;
            var p;

            // x1=cos(angle)*x-sin(angle)*y;
            // y1=cos(angle)*y+sin(angle)*x;
            for (var i = 0, l = contour.length; i < l; i++) {
                p = contour[i];
                px = cos * (p.x - x) - sin * (p.y - y);
                py = cos * (p.y - y) + sin * (p.x - x);
                p.x = px + x;
                p.y = py + y;
            }

            return contour;
        }
193873
def rotate_y(self, angle):
        
        axis_rotation(self.points, angle, inplace=True, axis='y')
546235
function (source, target, startAngle) {
                    // Given a point we need to find the next point clockwise from the start angle
                    var i,
                        point = target[target.length - 1],
                        thisAngle,
                        bestAngleSoFar = 9999,
                        returnPoint = point;
                    for (i = 0; i < source.length; i += 1) {
                        if (source[i].x !== point.x || source[i].y !== point.y) {
                            // get the angle in degrees since start angle
                            thisAngle = 180 - (Math.atan2(source[i].x - point.x, source[i].y - point.y) * (180 / Math.PI));
                            if (thisAngle > startAngle && thisAngle < bestAngleSoFar) {
                                returnPoint = source[i];
                                bestAngleSoFar = thisAngle;
                            }
                        }
                    }
                    target.push(returnPoint);
                    return bestAngleSoFar;
                }
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]
572304
def rotate(self, theta_deg, xoff=0, yoff=0):
        
        self.rotate_deg([theta_deg], (xoff, yoff))