Convert a rotation matrix to angular velocity
        
        w - angular velocity in inertial frame
        Omega - angular velocity in body frame
423067
def dcmdottoang_vel(R,Rdot):
    
    w = vee_map(Rdot.dot(R.T))
    Omega = vee_map(R.T.dot(Rdot))

    return (w, Omega)
879454
def Cosine(x, a, omega, phi, y0):
    
    return a * np.cos(x * omega + phi) + y0
812493
def z_rotate(rotationAmt):
        """"""
        ma4 = Matrix4((math.cos(rotationAmt), -math.sin(rotationAmt), 0, 0),
                      (math.sin(rotationAmt), math.cos(rotationAmt), 0, 0),
                      (0, 0, 1, 0),
                      (0, 0, 0, 1))

        return ma4
1212738
def dv(self, orb):
        

        orb = orb.copy(form="cartesian")

        if self.frame == "QSW":
            mat = to_qsw(orb).T
        elif self.frame == "TNW":
            mat = to_tnw(orb).T
        else:
            mat = np.identity(3)

        # velocity increment in the same reference frame as the orbit
        return mat @ self._dv
717062
def axis_angle(self):
        
        qw, qx, qy, qz = self.quaternion
        theta = 2 * np.arccos(qw)
        omega = np.array([1,0,0])
        if theta > 0:
            rx = qx / np.sqrt(1.0 - qw**2)
            ry = qy / np.sqrt(1.0 - qw**2)
            rz = qz / np.sqrt(1.0 - qw**2)
            omega = np.array([rx, ry, rz])
        return theta * omega
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)
1126418
def euler(self):
        """"""
        e_xyz = transformations.euler_from_matrix(self.rotation, 'sxyz')
        return np.array([180.0 / np.pi * a for a in e_xyz])
830954
function() {
            var absoluteMatrix = this.getAbsoluteTransform().getMatrix(),
                absoluteTransform = new Kinetic.Transform(),
                offset = this.offset();

            // clone the matrix array
            absoluteTransform.m = absoluteMatrix.slice();
            absoluteTransform.translate(offset.x, offset.y);

            return absoluteTransform.getTranslation();
        }
823644
def rotation(ATTITUDE):
    ''''''
    r = Matrix3()
    r.from_euler(ATTITUDE.roll, ATTITUDE.pitch, ATTITUDE.yaw)
    return r
326048
def convertToRateMatrix(self, Q):
        
        rowSums             = Q.sum(axis=1).getA1()
        idxRange            = np.arange(Q.shape[0])
        Qdiag               = coo_matrix((rowSums,(idxRange,idxRange)),shape=Q.shape).tocsr()
        return Q-Qdiag
817142
def _tilt(omega, b, psi):
    
    return np.cosh(psi/2.0)**b * np.exp(-psi**2/2.0 * omega)
445508
def rotation_matrix_3D(u, th):
    
    # normalize the axis:
    u = normalize(u)
    # We use the Euler-Rodrigues formula;
    # see https://en.wikipedia.org/wiki/Euler-Rodrigues_formula
    a = math.cos(0.5 * th)
    s = math.sin(0.5 * th)
    (b, c, d) = -s * u
    (a2, b2, c2, d2) = (a*a, b*b, c*c, d*d)
    (bc, ad, ac, ab, bd, cd) = (b*c, a*d, a*c, a*b, b*d, c*d)
    return np.array([[a2 + b2 - c2 - d2, 2*(bc + ad),         2*(bd - ac)],
                     [2*(bc - ad),       a2 + c2 - b2 - d2,   2*(cd + ab)],
                     [2*(bd + ac),       2*(cd - ab),         a2 + d2 - b2 - c2]])
1370179
def rot(self, t=0., transposed=False):
        
        rotmat = np.array(
            [[np.cos(self._pa+self._omegab*t),np.sin(self._pa+self._omegab*t)],
             [-np.sin(self._pa+self._omegab*t),np.cos(self._pa+self._omegab*t)]])
        if transposed:
            return rotmat.T
        else:
            return rotmat
179044
def transform_error_coorb_to_inertial(vec_coorb, vec_err_coorb, orbPhase,
        quat_copr):
    

    # for reproducibility
    np.random.seed(0)

    # Get distribution in coorbital frame
    dist_coorb = np.array([np.random.normal(m, s, 1000)
        for m,s in zip(vec_coorb, vec_err_coorb)]).T

    # Transform distribution to coprecessing frame
    dist_copr = rotate_in_plane(dist_coorb, -orbPhase)

    # Transform distribution to inertial frame
    dist_inertial = transformTimeDependentVector(
        np.array([quat_copr for _ in dist_copr]).T, dist_copr.T).T

    # Get 1sigma width in inertial frame
    vec_err_inertial = np.std(dist_inertial, axis=0)

    return vec_err_inertial
1231183
def rot3(theta):
    
    return np.array([
        [np.cos(theta), np.sin(theta), 0],
        [-np.sin(theta), np.cos(theta), 0],
        [0, 0, 1]
    ])
1089880
def axis_rotation_matrix(axis, theta):
    """"""
    [x, y, z] = axis
    c = np.cos(theta)
    s = np.sin(theta)
    return np.array([
        [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]
    ])
911154
def rotation_df(ATT):
    ''''''
    r = Matrix3()
    r.from_euler(radians(ATT.Roll), radians(ATT.Pitch), radians(ATT.Yaw))
    return r