c c _____________________________ c c subroutine disquat(qq,index1,index2,qresult,index1a,index2a) real qq(4),qqn(4),qresult(4),quint(4),quintn(4),qmax integer index1,index2,index1a,index2a,index3,iq4neg,i,j,k,ip,jp c c PI=3.14159265 c c algorithm for finding disorientation corresponding to c input quaternion, QQ (from COMQUAT): resultant quat. is in QRESULT c indices for symmetry operators are in INDEX1, INDEX2 c index1=0 index2=0 index1a=0 index2a=0 qmax=0. ip=1 jp=1 c do 200, i=1,24 call presymm(qq,i,quint) c do 190, j=1,24 c loop over the two sides of the grain call postsymm(quint,j,quintn) c do 185, kjl=1,2 switch=1.0 if(kjl.eq.2) then switch=-1.0 endif do 180, k=1,4 qqn(k)=quintn(k)*switch 180 continue c can take negative of Q because identity = +/-(0,0,0,1) c do 210, ijk=1,2 qresult(1)=qqn(1) qresult(2)=qqn(2) qresult(3)=qqn(3) qresult(4)=qqn(4) iq4neg=ijk if(ijk.eq.2) qresult(4)=-1.*qqn(4) c take the inverse rotation, i.e. apply the switching symmetry c if(qresult(1).ge.0.0) then c if((qresult(1)-qresult(2)).lt.1e-5) then c if((qresult(2)-qresult(3)).lt.1e-5) then c if((qresult(3)-qresult(4)).lt.1e-5) then if(qresult(1).le.qresult(2)) then if(qresult(2).le.qresult(3)) then if(qresult(3).le.qresult(4)) then c these IFs ensure that 0<=q1