Skip to content

Commit

Permalink
Normalize quat
Browse files Browse the repository at this point in the history
  • Loading branch information
marinerhemant committed Oct 26, 2023
1 parent 527469b commit e07a7c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion FF_HEDM/src/Calibrant.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ extern int *mapMask;
size_t mapMaskSize = 0;
int *mapMask;

inline void CalcPeakProfile(int **Indices, int *NrEachIndexBin, int idx,
double *Average,double Rmi,double Rma,double EtaMi,double EtaMa,
double ybc,double zbc,double px,int NrPixelsY, double *ReturnValue);

static inline
pixelvalue**
allocMatrixPX(int nrows, int ncols)
Expand Down Expand Up @@ -1418,7 +1422,7 @@ int main(int argc, char *argv[])
means[10] += StdDiff;
FILE *Out;
char OutFileName[1024];
sprintf(OutFileName,"%s_%06d%s.%s",fn,a,Ext,"corr.csv");
sprintf(OutFileName,"%s_%0*d%s.%s",fn,Padding,a,Ext,"corr.csv");
Out = fopen(OutFileName,"w");
fprintf(Out,"%%Eta Strain RadFit EtaCalc DiffCalc RadCalc Ideal2Theta\n");
for (i=0;i<nIndices;i++){
Expand Down
12 changes: 12 additions & 0 deletions FF_HEDM/src/GetMisorientation.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,20 @@ void BringDownToFundamentalRegion(double QuatIn[4], double QuatOut[4],int SGNr)
QuatOut[3] = qps[maxCosRowNr][3];
}

static inline void normalizeQuat(double quat[4]){
double norm = sqrt(quat[0]*quat[0]+quat[1]*quat[1]+quat[2]*quat[2]+quat[3]*quat[3]);
quat[0] /= norm;
quat[1] /= norm;
quat[2] /= norm;
quat[3] /= norm;
}

inline
double GetMisOrientation(double quat1[4], double quat2[4], double axis[3], double *Angle,int SGNr)
{
double q1FR[4], q2FR[4], q1Inv[4], QP[4], MisV[4];
normalizeQuat(quat1);
normalizeQuat(quat2);
BringDownToFundamentalRegion(quat1,q1FR,SGNr);
BringDownToFundamentalRegion(quat2,q2FR,SGNr);
q1Inv[0] = -q1FR[0];
Expand Down Expand Up @@ -302,6 +312,8 @@ inline
double GetMisOrientationAngle(double quat1[4], double quat2[4], double *Angle, int NrSymmetries, double Sym[24][4])
{
double q1FR[4], q2FR[4], QP[4], MisV[4];
normalizeQuat(quat1);
normalizeQuat(quat2);
BringDownToFundamentalRegionSym(quat1,q1FR,NrSymmetries,Sym);
BringDownToFundamentalRegionSym(quat2,q2FR,NrSymmetries,Sym);
q1FR[0] = -q1FR[0];
Expand Down

0 comments on commit e07a7c9

Please sign in to comment.