# Path: geosolver/matfunc.py
# class Vec(Table):
#     def dot( self, otherVec ):  return reduce(operator.add, map(operator.mul, self, otherVec), 0.0)
#     def norm( self ):  return math.sqrt(abs( self.dot(self.conjugate()) ))
#     def normSquared( self ):  return abs( self.dot(self.conjugate()) )
#     def normalize( self ):  return self / self.norm()
#     def outer( self, otherVec ):  return Mat([otherVec*x for x in self])
#     def cross( self, otherVec ):
#         'Compute a Vector or Cross Product with another vector'
#         assert len(self) == len(otherVec) == 3, 'Cross product only defined for 3-D vectors'
#         u, v = self, otherVec
#         return Vec([ u[1]*v[2]-u[2]*v[1], u[2]*v[0]-u[0]*v[2], u[0]*v[1]-u[1]*v[0] ])
#     def house( self, index ):
#         'Compute a Householder vector which zeroes all but the index element after a reflection'
#         v = Vec( Table([0]*index).concat(self[index:]) ).normalize()
#         t = v[index]
#         sigma = 1.0 - t**2
#         if sigma != 0.0:
#             t = v[index] = t<=0 and t-1.0 or -sigma / (t + 1.0)
#             v /= t
#         return v, 2.0 * t**2 / (sigma + t**2)
#     def polyval( self, x ):
#         'Vec([6,3,4]).polyval(5) evaluates to 6*x**2 + 3*x + 4 at x=5'
#         return reduce( lambda cum,c: cum*x+c, self, 0.0 )
#     def ratval( self, x ):
#         'Vec([10,20,30,40,50]).ratfit(5) evaluates to (10*x**2 + 20*x + 30) / (40*x**2 + 50*x + 1) at x=5.'
#         degree = len(self) / 2
#         num, den = self[:degree+1], self[degree+1:] + [1]
#         return num.polyval(x) / den.polyval(x)


from includes import *
from geosolver.matfunc import Vec
import numpy.numarray as Numeric

        matrix[0][3] = 0.0
        matrix[1][3] = 0.0
        matrix[2][3] = 0.0
        matrix[3][0] = 0.0
        matrix[3][1] = 0.0
        matrix[3][2] = 0.0
        matrix[3][3] = 1.0

    # Not used - Rick
    #def getMatrixSingle(self, matrix):
    #    mat = Numeric.zeros([4,4])
    #    self.getMatrix(mat)
    #    count = 0
    #    for i in range(4):
    #        for j in range(4):
    #            matrix[count] = mat[i][j]
    #            count += 1
    #    #print "between:"
    #    #print matrix
    
    def getRotationMatrix(self, matrix):
        mat = Numeric.identity(4)
        self.getMatrix(mat)
        
        for i in range(4):
            for j in range(4):
                matrix[i][j] = mat[j][i]

    def axis(self):

# Path: geosolver/matfunc.py
# class Vec(Table):
#     def dot( self, otherVec ):  return reduce(operator.add, map(operator.mul, self, otherVec), 0.0)
#     def norm( self ):  return math.sqrt(abs( self.dot(self.conjugate()) ))
#     def normSquared( self ):  return abs( self.dot(self.conjugate()) )
#     def normalize( self ):  return self / self.norm()
#     def outer( self, otherVec ):  return Mat([otherVec*x for x in self])
#     def cross( self, otherVec ):
#         'Compute a Vector or Cross Product with another vector'
#         assert len(self) == len(otherVec) == 3, 'Cross product only defined for 3-D vectors'
#         u, v = self, otherVec
#         return Vec([ u[1]*v[2]-u[2]*v[1], u[2]*v[0]-u[0]*v[2], u[0]*v[1]-u[1]*v[0] ])
#     def house( self, index ):
#         'Compute a Householder vector which zeroes all but the index element after a reflection'
#         v = Vec( Table([0]*index).concat(self[index:]) ).normalize()
#         t = v[index]
#         sigma = 1.0 - t**2
#         if sigma != 0.0:
#             t = v[index] = t<=0 and t-1.0 or -sigma / (t + 1.0)
#             v /= t
#         return v, 2.0 * t**2 / (sigma + t**2)
#     def polyval( self, x ):
#         'Vec([6,3,4]).polyval(5) evaluates to 6*x**2 + 3*x + 4 at x=5'
#         return reduce( lambda cum,c: cum*x+c, self, 0.0 )
#     def ratval( self, x ):
#         'Vec([10,20,30,40,50]).ratfit(5) evaluates to (10*x**2 + 20*x + 30) / (40*x**2 + 50*x + 1) at x=5.'
#         degree = len(self) / 2
#         num, den = self[:degree+1], self[degree+1:] + [1]
#         return num.polyval(x) / den.polyval(x)


# Path: workbench/quaternion.py
from includes import *
from geosolver.matfunc import Vec
import numpy.numarray as Numeric


        matrix[0][3] = 0.0
        matrix[1][3] = 0.0
        matrix[2][3] = 0.0
        matrix[3][0] = 0.0
        matrix[3][1] = 0.0
        matrix[3][2] = 0.0
        matrix[3][3] = 1.0

    # Not used - Rick
    #def getMatrixSingle(self, matrix):
    #    mat = Numeric.zeros([4,4])
    #    self.getMatrix(mat)
    #    count = 0
    #    for i in range(4):
    #        for j in range(4):
    #            matrix[count] = mat[i][j]
    #            count += 1
    #    #print "between:"
    #    #print matrix
    
    def getRotationMatrix(self, matrix):
        mat = Numeric.identity(4)
        self.getMatrix(mat)
        
        for i in range(4):
            for j in range(4):
                matrix[i][j] = mat[j][i]

    def axis(self):

        result = Vec([self.quaternion[0], self.quaternion[1], self.quaternion[2]])