Changeset 755


Ignore:
Timestamp:
Sep 8, 2012 10:14:53 AM (11 years ago)
Author:
vondreele
Message:

fix rotation about view direction
eliminate divide by zero error in quaternion stuff

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImath.py

    r753 r755  
    10651065    Q = np.zeros(4)
    10661066    d = np.sqrt(np.sum(np.array(V)**2))
    1067     V /= d
     1067    if d:
     1068        V /= d
     1069    else:
     1070        return [1.,0.,0.,0.]    #identity
    10681071    p = A/2.
    10691072    Q[0] = np.cos(p)
     
    10781081    Q = np.zeros(4)
    10791082    d = np.sqrt(np.sum(np.array(V)**2))
    1080     V /= d
     1083    if d:
     1084        V /= d
     1085    else:
     1086        return [1.,0.,0.,0.]    #identity
    10811087    p = A/2.
    10821088    Q[0] = cosd(p)
  • trunk/GSASIIphsGUI.py

    r754 r755  
    15641564            'vdwScale':0.67,'ellipseProb':50,'sizeH':0.50,'unitCellBox':False,
    15651565            'showABC':True,'selectedAtoms':[],'Atoms':[],'oldxy':[],
    1566             'Quaternion':[0.0,0.0,1.0,0.0],'bondList':{},'viewDir':[0,0,1]}
     1566            'Quaternion':[1.0,0.0,0.0,0.0],'bondList':{},'viewDir':[0,0,1]}
    15671567        try:
    15681568            drawingData = data['Drawing']
     
    15771577            drawingData['viewDir'] = [0,0,1]
    15781578        if 'Quaternion' not in drawingData:
    1579             drawingData['Quaternion'] = [0.0,0.0,1.0,0.0]
     1579            drawingData['Quaternion'] = [1.0,0.0,0.0,0.0]
    15801580        cx,ct,cs,ci = [0,0,0,0]
    15811581        if generalData['Type'] == 'nuclear':
  • trunk/GSASIIplot.py

    r754 r755  
    26722672#first get rotation vector (= view vector) in screen coords. & angle increment       
    26732673        View = glGetIntegerv(GL_VIEWPORT)
     2674        cent = [View[2]/2,View[3]/2]
    26742675        oldxy = drawingData['oldxy']
    26752676        if not len(oldxy): oldxy = list(newxy)
     
    26772678        drawingData['oldxy'] = list(newxy)
    26782679        V = drawingData['viewDir']
    2679         X0 = drawingData['viewPoint'][0]
    2680         A = (dxy[0]+dxy[1])*.25
    2681 # next transform vector back to xtal coordinates via inverse quaternion
    2682 # & make new quaternion
     2680        A = [0,0]
     2681        A[0] = dxy[1]*.25
     2682        A[1] = dxy[0]*.25
     2683        if newxy[0] > cent[0]:
     2684            A[0] *= -1
     2685        if newxy[1] < cent[1]:
     2686            A[1] *= -1       
     2687# next transform vector back to xtal coordinates & make new quaternion
    26832688        Q = drawingData['Quaternion']
    26842689        V = np.inner(Amat,V)
    2685         DQ = G2mth.AVdeg2Q(A,V)
    2686         Q = G2mth.prodQQ(Q,DQ)
     2690        Qx = G2mth.AVdeg2Q(A[0],V)
     2691        Qy = G2mth.AVdeg2Q(A[1],V)
     2692        Q = G2mth.prodQQ(Q,Qx)
     2693        Q = G2mth.prodQQ(Q,Qy)
    26872694        drawingData['Quaternion'] = Q
    26882695
Note: See TracChangeset for help on using the changeset viewer.