Пример #1
0
def rot(rad = math.pi/2, unitv = vector3d.Vector3D(0,0,1)):
    unitv.normalizethis()
    crosspmat = multidim.Matrix(3,3,[unitv.x*unitv.x,unitv.x*unitv.y,unitv.x*unitv.z,
                                     unitv.x*unitv.y,unitv.y*unitv.y,unitv.y*unitv.z,
                                     unitv.x*unitv.z,unitv.y*unitv.z,unitv.z*unitv.z])
    tensorprod = multidim.Matrix(3,3,[0,-unitv.z,unitv.y,
                                      unitv.z,0,-unitv.x,
                                      -unitv.y,unitv.x,0])
    sr = math.sin(rad)
    cr = math.cos(rad)
    return Rotation3D(cr*multidim.identity(3) + sr*tensorprod + (1-cr)*crosspmat)
Пример #2
0
 def getangax2(self):
     #Axis:
     #Get the eigenvector for the eigenvalue == 1:
     nullspace, matrref, minv, ones, zeros = multidim.nullspace(self.matrix - multidim.identity(3), tolerance=0.00000000001)
     axis = matrix2vector3D(nullspace)
     axis.normalizethis()
     if (axis - vector3d.xbasev()).norm() > 0.1:
         v = vector3d.xbasev()
     elif (axis - vector3d.ybasev()).norm() > 0.1:
         v = vector3d.ybasev()
     elif (axis - vector3d.zbasev()).norm() > 0.1:
         v = vector3d.zbasev()
     else:
         raise RuntimeError('Rotation3D.getangax: Bad internal matrix!!')
     v = vector3d.orthonormal(axis,v)            # Make v orthonormal against axis
     vrot = self.rotvec(v)
     angle = vector3d.anglebetween(v, vrot)
     axis1 = vector3d.crossproduct(v, vrot)
     if vector3d.dotproduct(axis, axis1) < 0:
         axis = -axis
     return angle, axis
Пример #3
0
 def __init__(self, m = multidim.identity(3)):
     # NOTE: Do not remove "copy" - default arguments are only defined upon function definiton!!:
     self.matrix = m.copy()