Example #1
0
    def setup_quat_center(self, atomList=None):
        """
        Setup the plane's quat using a list of atoms.

        If no atom list is supplied, the plane is centered in the glpane
        and parallel to the screen.

        @param atomList: A list of atoms.
        @type  atomList: list

        """
        if atomList:
            self.atomPos = []
            for a in atomList:
                self.atomPos += [a.posn()]
            planeNorm = self._getPlaneOrientation(self.atomPos)
            if dot(planeNorm, self.glpane.lineOfSight) < 0:
                planeNorm = -planeNorm
            self.center = add.reduce(self.atomPos) / len(self.atomPos)
            self.quat = Q(V(0.0, 0.0, 1.0), planeNorm)
        else:
            self.center = V(0.0, 0.0, 0.0)
            # Following makes sure that Plane edges are parallel to
            # the 3D workspace borders. Fixes bug 2448
            x, y, z = self.glpane.right, self.glpane.up, self.glpane.out
            self.quat = Q(x, y, z)
            self.quat += Q(self.glpane.right, pi)
Example #2
0
def inertia_eigenvectors(basepos, already_centered = False):
    """
    Given basepos (an array of positions),
    compute and return (as a 2-tuple) the lists of eigenvalues and
    eigenvectors of the inertia tensor (computed as if all points had the same
    mass). These lists are always length 3, even for len(basepos) of 0,1, or 2,
    overlapping or colinear points, etc, though some evals will be 0 in these cases.
       Optional small speedup: if caller knows basepos is centered at the origin, it can say so.
    """
    #bruce 060119 split this out of shakedown_poly_evals_evecs_axis() in chunk.py
    basepos = A(basepos) # make sure it's a Numeric array
    if not already_centered and len(basepos):
        center = add.reduce(basepos)/len(basepos)
        basepos = basepos - center
    # compute inertia tensor
    tensor = zeros((3,3),Float)
    for p in basepos:
        rsq = dot(p, p)
        m= - multiply.outer(p, p)
        m[0,0] += rsq
        m[1,1] += rsq
        m[2,2] += rsq
        tensor += m
    evals, evecs = eigenvectors(tensor)
    assert len(evals) == len(evecs) == 3
    return evals, evecs
Example #3
0
    def setup_quat_center(self, atomList = None):
        """
        Setup the plane's quat using a list of atoms.

        If no atom list is supplied, the plane is centered in the glpane
        and parallel to the screen.

        @param atomList: A list of atoms.
        @type  atomList: list

        """
        if atomList:    
            self.atomPos = []
            for a in atomList:
                self.atomPos += [a.posn()]    
            planeNorm = self._getPlaneOrientation(self.atomPos)
            if dot(planeNorm, self.glpane.lineOfSight) < 0:
                planeNorm = -planeNorm                
            self.center = add.reduce(self.atomPos) / len(self.atomPos)
            self.quat   = Q(V(0.0, 0.0, 1.0), planeNorm) 
        else:       
            self.center = V(0.0, 0.0, 0.0)
            # Following makes sure that Plane edges are parallel to
            # the 3D workspace borders. Fixes bug 2448
            x, y ,z = self.glpane.right, self.glpane.up, self.glpane.out
            self.quat  = Q(x, y, z) 
            self.quat += Q(self.glpane.right, pi)
Example #4
0
def inertia_eigenvectors(basepos, already_centered=False):
    """
    Given basepos (an array of positions),
    compute and return (as a 2-tuple) the lists of eigenvalues and
    eigenvectors of the inertia tensor (computed as if all points had the same
    mass). These lists are always length 3, even for len(basepos) of 0,1, or 2,
    overlapping or colinear points, etc, though some evals will be 0 in these cases.
       Optional small speedup: if caller knows basepos is centered at the origin, it can say so.
    """
    #bruce 060119 split this out of shakedown_poly_evals_evecs_axis() in chunk.py
    basepos = A(basepos)  # make sure it's a Numeric array
    if not already_centered and len(basepos):
        center = add.reduce(basepos) / len(basepos)
        basepos = basepos - center
    # compute inertia tensor
    tensor = zeros((3, 3), Float)
    for p in basepos:
        rsq = dot(p, p)
        m = -multiply.outer(p, p)
        m[0, 0] += rsq
        m[1, 1] += rsq
        m[2, 2] += rsq
        tensor += m
    evals, evecs = eigenvectors(tensor)
    assert len(evals) == len(evecs) == 3
    return evals, evecs
Example #5
0
    def __init_quat_center(self, list):

        for a in list:  #[:3]:
            self.atomPos += [a.posn()]

        planeNorm = self._getPlaneOrientation(self.atomPos)
        self.quat = Q(V(0.0, 0.0, 1.0), planeNorm)
        self.center = add.reduce(self.atomPos) / len(self.atomPos)
Example #6
0
 def __init_quat_center(self, list):
     
     for a in list:#[:3]:
         self.atomPos += [a.posn()]
 
     planeNorm = self._getPlaneOrientation(self.atomPos)
     self.quat = Q(V(0.0, 0.0, 1.0), planeNorm)
     self.center = add.reduce(self.atomPos)/len(self.atomPos)
Example #7
0
 def center(self):
     if self.data:
         return add.reduce(self.data) / 2.0
     else:
         return V(0, 0, 0)
Example #8
0
 def draw(self):
     if self.data:
         drawwirebox(black,
                     add.reduce(self.data) / 2,
                     subtract.reduce(self.data) / 2)
Example #9
0
 def center(self):
     if self.data:
         return add.reduce(self.data)/2.0
     else:
         return V(0, 0, 0)
Example #10
0
 def draw(self):
     if self.data:
         drawwirebox(black,
                     add.reduce(self.data) / 2,
                     subtract.reduce(self.data) / 2 )