Returns a rotation matrix around the given axis
558206
def symbolic_axis_rotation_matrix(axis, symbolic_theta):
    """"""
    [x, y, z] = axis
    c = sympy.cos(symbolic_theta)
    s = sympy.sin(symbolic_theta)
    return sympy.Matrix([
        [x**2 + (1 - x**2) * c, x * y * (1 - c) - z * s, x * z * (1 - c) + y * s],
        [x * y * (1 - c) + z * s, y ** 2 + (1 - y**2) * c, y * z * (1 - c) - x * s],
        [x * z * (1 - c) - y * s, y * z * (1 - c) + x * s, z**2 + (1 - z**2) * c]
    ])
102420
def rot2(theta):
    
    return np.array([
        [np.cos(theta), 0, -np.sin(theta)],
        [0, 1, 0],
        [np.sin(theta), 0, np.cos(theta)]
    ])
79048
def quaternion_to_rotation_matrix(quaternion):
    """"""
    c, x, y, z = quaternion
    return np.array([
        [c*c + x*x - y*y - z*z, 2*x*y - 2*c*z,         2*x*z + 2*c*y        ],
        [2*x*y + 2*c*z,         c*c - x*x + y*y - z*z, 2*y*z - 2*c*x        ],
        [2*x*z - 2*c*y,         2*y*z + 2*c*x,         c*c - x*x - y*y + z*z]
    ], float)
117196
def from_axis_angle(axis, angle):
    

    sincomp = math.sin(angle / 2.0)
    return Quaternion(
      axis.x * sincomp, axis.y * sincomp,
      axis.z * sincomp, math.cos(angle / 2.0))
1287670
def _get_shift_matrix(self):
        """"""
        return np.array([[1., 0., self.x_shift, 0.],
                         [0., 1., self.y_shift, 0.],
                         [0., 0.,           1., 0.],
                         [0., 0.,           0., 1.]], dtype=np.float32)
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)};
  }
790791
public Rotation aroundAxis(float x, float y, float z)
	{
		axisX = x;
		axisY = y;
		axisZ = z;
		return this;
	}
1340837
def get_transformation(self, coordinates):
        """"""
        atom1, atom2 = self.hinge_atoms
        center = coordinates[atom1]
        axis = coordinates[atom1] - coordinates[atom2]
        axis /= np.linalg.norm(axis)
        angle = np.random.uniform(-self.max_amplitude, self.max_amplitude)
        return Complete.about_axis(center, angle, axis)
266164
def geom_rotate(g, ax, theta):
    

    # Imports
    import numpy as np

    # Force g to n-vector
    g = make_nd_vec(g, nd=None, t=np.float64, norm=False)

    # Perform rotation and return
    rot_g = np.dot(mtx_rot(ax, theta, reps=(g.shape[0] // 3)), g) \
                .reshape((g.shape[0],1))
    return rot_g
1145612
def rotMatrix2AxisAndAngle(R):
    
    angle = np.arccos((R[0, 0] + R[1, 1] + R[2, 2] - 1)/ 2)
    axis = np.array([
        # x
        (R[2, 1] - R[1, 2])/ np.sqrt((R[2, 1] - R[1, 2])
                                                ** 2 + (R[0, 2] - R[2, 0])**2 + (R[1, 0] - R[0, 1])**2),
        # y
        (R[0, 2] - R[2, 0])/ np.sqrt((R[2, 1] - R[1, 2])
                                                ** 2 + (R[0, 2] - R[2, 0])**2 + (R[1, 0] - R[0, 1])**2),
        # z
        (R[1, 0] - R[0, 1])/ np.sqrt((R[2, 1] - R[1, 2])**2 + 
                                                (R[0, 2] - R[2, 0])**2 + (R[1, 0] - R[0, 1])**2)])
    return axis, angle
513757
def rotated(self, rotation_center, angle):
        
        rot = np.array([[np.cos(angle), np.sin(angle)], [-np.sin(angle), np.cos(angle)]])
        t = np.asfarray(rotation_center)
        new_c = np.dot(rot.T, (self.center - t)) + t
        return RotatedBox(new_c, self.width, self.height, (self.angle+angle) % (np.pi*2))
239907
def Rx_matrix(theta):
    """"""
    return np.array([
        [1, 0, 0],
        [0, np.cos(theta), -np.sin(theta)],
        [0, np.sin(theta), np.cos(theta)]
    ])
1074996
def get_rotations(self):
        """"""
        if self.centrosymmetric:
            return np.vstack((self.rotations, -self.rotations))
        else:
            return self.rotations
653048
def rotate(self, angle, axis=(0, 0, 1)):
        """"""
        if not all(isinstance(a, int) for a in axis):
            raise ValueError
        x, y, z = self.x, self.y, self.z

        # Z axis rotation
        if(axis[2]):
            x = (self.x * math.cos(angle) - self.y * math.sin(angle))
            y = (self.x * math.sin(angle) + self.y * math.cos(angle))

        # Y axis rotation
        if(axis[1]):
            x = self.x * math.cos(angle) + self.z * math.sin(angle)
            z = -self.x * math.sin(angle) + self.z * math.cos(angle)

        # X axis rotation
        if(axis[0]):
            y = self.y * math.cos(angle) - self.z * math.sin(angle)
            z = self.y * math.sin(angle) + self.z * math.cos(angle)

        return Vector(x, y, z)
247133
def get_transformation_matrix(self, theta):
        
        ct = numpy.cos(theta + self.theta)
        st = numpy.sin(theta + self.theta)
        ca = numpy.cos(self.alpha)
        sa = numpy.sin(self.alpha)

        return numpy.matrix(((ct, -st * ca, st * sa, self.a * ct),
                             (st, ct * ca, -ct * sa, self.a * st),
                             (0, sa, ca, self.d),
                             (0, 0, 0, 1)))
1058327
def get_rotated(self, angle):
        """"""
        ca = math.cos(angle)
        sa = math.sin(angle)
        return Point(self.x*ca-self.y*sa, self.x*sa+self.y*ca)
86334
def get_rotated(self, angle):
        
        result = self.copy()
        result.rotate(angle)
        return result