def q2mat(q):
    """
        Generate a left rotation matrix from a normalized quaternion

        Parameters
            q:  The normalized quaternion (list)
        Returns
            u:  The rotation matrix (2-dimensional list)
    """
    u = []
    for i in range(3):
        u.append([])
        for j in range(3):
            u[i].append(0.0)

    u[0][0] = q[0] * q[0] + q[1] * q[1] - q[2] * q[2] - q[3] * q[3]
    u[0][1] = 2.0 * (q[1] * q[2] - q[0] * q[3])
    u[0][2] = 2.0 * (q[1] * q[3] + q[0] * q[2])

    u[1][0] = 2.0 * (q[2] * q[1] + q[0] * q[3])
    u[1][1] = q[0] * q[0] - q[1] * q[1] + q[2] * q[2] - q[3] * q[3]
    u[1][2] = 2.0 * (q[2] * q[3] - q[0] * q[1])

    u[2][0] = 2.0 * (q[3] * q[1] - q[0] * q[2])
    u[2][1] = 2.0 * (q[3] * q[2] + q[0] * q[1])
    u[2][2] = q[0] * q[0] - q[1] * q[1] - q[2] * q[2] + q[3] * q[3]

    return u