# Path: attitude/geom/util.py
# def dot(*matrices):
#     return reduce(N.dot, matrices)
# 
# Path: attitude/error/ellipse.py
# def ellipse(center,covariance_matrix,level=1, n=1000):
#     """Returns error ellipse in slope-azimuth space"""
#     # singular value decomposition
#     U, s, rotation_matrix = N.linalg.svd(covariance_matrix)
#     # semi-axes (largest first)
# 
#     saxes = N.sqrt(s)*level ## If the _area_ of a 2s ellipse is twice that of a 1s ellipse
#     # If the _axes_ are supposed to be twice as long, then it should be N.sqrt(s)*width
# 
#     u = N.linspace(0, 2*N.pi, n)
#     data = N.column_stack((saxes[0]*N.cos(u), saxes[1]*N.sin(u)))
#     # rotate data
#     return N.dot(data, rotation_matrix)+ center


import numpy as N
from ..geom.util import dot
from ..error.ellipse import ellipse
from hashlib import sha1
from __future__ import division, print_function

def hash_array(a):
    return sha1(a.data.tobytes()).hexdigest()[:8]

def rotation(angle):
    """Rotation about the Z axis (in the XY plane)"""
    return N.array([[N.cos(angle),-N.sin(angle),0],
        [N.sin(angle), N.cos(angle),0],
        [0           , 0           ,1]])


# Path: attitude/geom/util.py
# def dot(*matrices):
#     return reduce(N.dot, matrices)
# 
# Path: attitude/error/ellipse.py
# def ellipse(center,covariance_matrix,level=1, n=1000):
#     """Returns error ellipse in slope-azimuth space"""
#     # singular value decomposition
#     U, s, rotation_matrix = N.linalg.svd(covariance_matrix)
#     # semi-axes (largest first)
# 
#     saxes = N.sqrt(s)*level ## If the _area_ of a 2s ellipse is twice that of a 1s ellipse
#     # If the _axes_ are supposed to be twice as long, then it should be N.sqrt(s)*width
# 
#     u = N.linspace(0, 2*N.pi, n)
#     data = N.column_stack((saxes[0]*N.cos(u), saxes[1]*N.sin(u)))
#     # rotate data
#     return N.dot(data, rotation_matrix)+ center


# Path: attitude/orientation/base.py
import numpy as N
from ..geom.util import dot
from ..error.ellipse import ellipse
from hashlib import sha1

from __future__ import division, print_function

def hash_array(a):
    return sha1(a.data.tobytes()).hexdigest()[:8]

def rotation(angle):
    """Rotation about the Z axis (in the XY plane)"""
    return N.array([[N.cos(angle),-N.sin(angle),0],
        [N.sin(angle), N.cos(angle),0],
        [0           , 0           ,1]])


def ellipse(center,covariance_matrix,level=1, n=1000):