- added makeauxub to tasub
- fixes for MARS - extended maximize to honour maxpts and the in360 flag - added regression histmem driver
This commit is contained in:
100
tasublib.c
100
tasublib.c
@ -139,6 +139,38 @@ static double calcTheta(double ki, double kf, double two_theta){
|
||||
return rtan(ABS(ki) - ABS(kf)*Cosd(two_theta),
|
||||
ABS(kf)*Sind(two_theta))/DEGREE_RAD;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
double tasAngleBetweenReflections(MATRIX B, tasReflection r1, tasReflection r2){
|
||||
MATRIX chi1, chi2, h1, h2;
|
||||
double angle;
|
||||
|
||||
h1 = makeVector();
|
||||
if(h1 == NULL){
|
||||
return -9999.99;
|
||||
}
|
||||
h1[0][0] = r1.qe.qh;
|
||||
h1[1][0] = r1.qe.qk;
|
||||
h1[2][0] = r1.qe.ql;
|
||||
|
||||
h2 = makeVector();
|
||||
if(h2 == NULL){
|
||||
return -999.99;
|
||||
}
|
||||
h2[0][0] = r2.qe.qh;
|
||||
h2[1][0] = r2.qe.qk;
|
||||
h2[2][0] = r2.qe.ql;
|
||||
|
||||
chi1 = mat_mul(B,h1);
|
||||
chi2 = mat_mul(B,h2);
|
||||
if(chi1 != NULL && chi2 != NULL){
|
||||
angle = angleBetween(chi1,chi2);
|
||||
killVector(chi1);
|
||||
killVector(chi2);
|
||||
}
|
||||
killVector(h1);
|
||||
killVector(h2);
|
||||
return angle;
|
||||
}
|
||||
/*--------------------------------------------------------------------*/
|
||||
static MATRIX uFromAngles(double om, double sgu, double sgl){
|
||||
MATRIX u;
|
||||
@ -161,6 +193,59 @@ static MATRIX calcTasUVectorFromAngles(tasReflection r){
|
||||
om = r.angles.a3 - theta;
|
||||
return uFromAngles(om,r.angles.sgu, r.angles.sgl);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
static MATRIX tasReflectionToQC(tasQEPosition r, MATRIX UB){
|
||||
MATRIX Q, QC;
|
||||
|
||||
Q = makeVector();
|
||||
if(Q == NULL){
|
||||
return NULL;
|
||||
}
|
||||
vectorSet(Q,0,r.qh);
|
||||
vectorSet(Q,1,r.qk);
|
||||
vectorSet(Q,2,r.ql);
|
||||
QC = mat_mul(UB,Q);
|
||||
killVector(Q);
|
||||
return QC;
|
||||
}
|
||||
/*-----------------------------------------------------------------*/
|
||||
int makeAuxReflection(MATRIX B, tasReflection r1, tasReflection *r2,
|
||||
int ss){
|
||||
double theta, om, q, cos2t;
|
||||
MATRIX QC;
|
||||
|
||||
r2->angles = r1.angles;
|
||||
r2->qe.ki = r1.qe.ki;
|
||||
r2->qe.kf= r1.qe.kf;
|
||||
|
||||
theta = calcTheta(r1.qe.ki,r1.qe.kf,r1.angles.sample_two_theta);
|
||||
om = r1.angles.a3 - theta;
|
||||
om += tasAngleBetweenReflections(B,r1,*r2);
|
||||
|
||||
QC = tasReflectionToHC(r2->qe,B);
|
||||
if(QC == NULL){
|
||||
return UBNOMEMORY;
|
||||
}
|
||||
|
||||
q = vectorLength(QC);
|
||||
q = 2.*PI*vectorLength(QC);
|
||||
cos2t = (r1.qe.ki*r1.qe.ki + r1.qe.kf*r1.qe.kf - q*q)/
|
||||
(2. * ABS(r1.qe.ki) * ABS(r1.qe.kf));
|
||||
if(ABS(cos2t) > 1.){
|
||||
killVector(QC);
|
||||
return TRIANGLENOTCLOSED;
|
||||
}
|
||||
r2->angles.sample_two_theta = ss*Acosd(cos2t);
|
||||
theta = calcTheta(r1.qe.ki,r1.qe.kf,r2->angles.sample_two_theta);
|
||||
r2->angles.a3 = om + theta;
|
||||
r2->angles.a3 -= 180.;
|
||||
if(r2->angles.a3 < -180.){
|
||||
r2->angles.a3 += 360.;
|
||||
}
|
||||
mat_free(QC);
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------*/
|
||||
MATRIX calcPlaneNormal(tasReflection r1, tasReflection r2){
|
||||
MATRIX u1 = NULL, u2 = NULL, planeNormal = NULL;
|
||||
@ -326,21 +411,6 @@ static MATRIX buildTVMatrix(MATRIX U1V, MATRIX U2V){
|
||||
killVector(T3V);
|
||||
return T;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
static MATRIX tasReflectionToQC(tasQEPosition r, MATRIX UB){
|
||||
MATRIX Q, QC;
|
||||
|
||||
Q = makeVector();
|
||||
if(Q == NULL){
|
||||
return NULL;
|
||||
}
|
||||
vectorSet(Q,0,r.qh);
|
||||
vectorSet(Q,1,r.qk);
|
||||
vectorSet(Q,2,r.ql);
|
||||
QC = mat_mul(UB,Q);
|
||||
killVector(Q);
|
||||
return QC;
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static MATRIX buildRMatrix(MATRIX UB, MATRIX planeNormal,
|
||||
tasQEPosition qe, int *errorCode){
|
||||
|
Reference in New Issue
Block a user