# Path: blockplayer/expmap.py
# def axis2rot(axis):
# def euler2rot(euler):
# def rot2axis(matrix):
# 	R = np.array([
# 		[ux*ux+(1-ux*ux)*c,  ux*uy*(1-c)-uz*s,  ux*uz*(1-c)+uy*s],
# 		[ux*uy*(1-c)+uz*s,   uy*uy+(1-uy*uy)*c, uy*uz*(1-c)-ux*s],
# 		[ux*uz*(1-c)-uy*s,   uz*uy*(1-c)+ux*s,  uz*uz+(1-uz*uz)*c]])
#   R = numpy.array(matrix, dtype=numpy.float32)
#   R33 = R[:3, :3]


import numpy as np
from OpenGL.GL import *
from blockplayer import expmap
from wxpy3d import PointWindow
from wxpy3d.opengl_state import opengl_state
global window
if not 'window' in globals():
    window = PointWindow(title='demo_meanshift', size=(640,480))
    window.Move((0,0))

def normalize(X):
    return X / np.sqrt(np.sum(X*X))

def random_basis():
    X = normalize(np.random.rand(3)-0.5)
    Y = normalize(np.random.rand(3)-0.5)
    Z = normalize(np.cross(X, Y))
    X = normalize(np.cross(Y, Z))
    return np.array([X,Y,Z]).astype('f')

def random_points(N=1000, mu=0.1):

# Path: blockplayer/expmap.py
# def axis2rot(axis):
# def euler2rot(euler):
# def rot2axis(matrix):
# 	R = np.array([
# 		[ux*ux+(1-ux*ux)*c,  ux*uy*(1-c)-uz*s,  ux*uz*(1-c)+uy*s],
# 		[ux*uy*(1-c)+uz*s,   uy*uy+(1-uy*uy)*c, uy*uz*(1-c)-ux*s],
# 		[ux*uz*(1-c)-uy*s,   uz*uy*(1-c)+ux*s,  uz*uz+(1-uz*uz)*c]])
#   R = numpy.array(matrix, dtype=numpy.float32)
#   R33 = R[:3, :3]


# Path: demos/demo_meanshift.py
import numpy as np
from OpenGL.GL import *
from blockplayer import expmap
from wxpy3d import PointWindow
from wxpy3d.opengl_state import opengl_state

global window
if not 'window' in globals():
    window = PointWindow(title='demo_meanshift', size=(640,480))
    window.Move((0,0))

def normalize(X):
    return X / np.sqrt(np.sum(X*X))

def random_basis():
    X = normalize(np.random.rand(3)-0.5)
    Y = normalize(np.random.rand(3)-0.5)
    Z = normalize(np.cross(X, Y))
    X = normalize(np.cross(Y, Z))
    return np.array([X,Y,Z]).astype('f')

def random_points(N=1000, mu=0.1):

    basis = random_basis()