PSI sics-cvs-psi-2006

This commit is contained in:
2006-05-08 02:00:00 +00:00
committed by Douglas Clowes
parent ae77364de2
commit 6e926b813f
388 changed files with 445529 additions and 14109 deletions

100
fourlib.c
View File

@@ -198,7 +198,7 @@ void pol2det(psdDescription *psd, double gamma, double nu, int *x, int *y){
turn chi and phi in order to get Z1 into the equatorial plane
*/
static void turnEquatorial(MATRIX z1, double *chi, double *phi){
if(ABS(z1[0][0]) < .0001 || ABS(z1[1][0]) < .0001){
if(ABS(z1[0][0]) < .0001 && ABS(z1[1][0]) < .00001){
*phi = .0;
*chi = 90.;
if(z1[2][0] < .0){
@@ -213,7 +213,7 @@ static void turnEquatorial(MATRIX z1, double *chi, double *phi){
/*----------------------------------------------------------------------
calculate d-spacing and theta from z1
-----------------------------------------------------------------------*/
static int calcTheta(double lambda, MATRIX z1, double *d, double *theta){
int calcTheta(double lambda, MATRIX z1, double *d, double *theta){
double dstar, sintheta;
dstar = sqrt(z1[0][0]*z1[0][0] + z1[1][0]*z1[1][0] + z1[2][0]*z1[2][0]);
@@ -447,9 +447,63 @@ double sign(double a, double b){
if(b >= .0){
return ABS(a);
} else {
-ABS(a);
return -ABS(a);
}
}
/*--------------------------------------------------------------------*/
static void makeNull(double *gamma, double *om, double *nu){
*gamma = .0;
*om = .0;
*nu = .0;
}
/*---------------------------------------------------------------------*/
int z1mToNormalBeam(double lambda, MATRIX z1m, double *gamma, double *om, double *nu){
MATRIX dum, znew;
double d, a, b, sint, theta, omdeg;
int status;
status = calcTheta(lambda,z1m,&d,&theta);
if(!status){
makeNull(gamma,om,nu);
return status;
}
/* Everything on omega axis is blind: test for this */
a = sqrt(z1m[0][0] * z1m[0][0] + z1m[1][0] * z1m[1][0]);
if(ABS(a) < .0001) {
makeNull(gamma,om,nu);
return 0;
}
sint = sin(theta/RD);
b = 2.*sint*sint/(lambda*a);
if(b >= 1.) {
makeNull(gamma,om,nu);
return 0;
}
a = -atan2(z1m[1][0], -z1m[0][0]);
b = -asin(b);
*om = a + b;
omdeg = *om*RD;
dum = mat_creat(3,3,ZERO_MATRIX);
phimat(dum,omdeg);
znew = mat_mul(dum,z1m);
if(znew[0][0] < 0) {
*om = *om -2.*atan2(-znew[0][0], -znew[1][0]);
omdeg = *om * RD;
}
b = (sign(180.,omdeg)+ omdeg)/360.;
b = sign(1,b)* floor(ABS(b));
omdeg = omdeg - 360. * b ;
*nu = asin(lambda*z1m[2][0]);
*gamma = acos(cos(2.*(theta/RD)))/cos(*nu);
*om = omdeg;
*nu = *nu * RD;
*gamma = *gamma * RD;
mat_free(dum);
mat_free(znew);
return 1;
}
/*----------------------------------------------------------------------*/
int bisToNormalBeam(double twotheta, double omega, double chi, double phi,
double *omeganb, double *gamma, double *nu){
@@ -553,6 +607,46 @@ void z1FromAllAngles(double lambda, double omega , double gamma,
z1fromz3(z1,z3,chi,phi);
mat_free(z3);
}
/*-----------------------------------------------------------------------*/
int findAllowedBisecting(double lambda, MATRIX z1, float fSet[4],
inRange testFunc, void *userData){
int status, i, mask[4];
double stt, om, chi, phi, psi, ompsi, chipsi, phipsi;
float fTest[4];
status = z1mToBisecting(lambda,z1, &stt, &om, &chi, &phi);
chi = circlify(chi);
phi = circlify(phi);
fSet[0] = stt;
fSet[1] = om;
fSet[2] = chi;
fSet[3] = phi;
if(status != 1) {
return 0;
}
for(psi = .0; psi < 360.; psi += .5){
rotatePsi(om,chi,phi,psi,&ompsi,&chipsi,&phipsi);
fTest[0] = stt;
fTest[1] = ompsi;
fTest[2] = circlify(chipsi);
fTest[3] = circlify(phipsi);
status = testFunc(userData,fTest,mask);
if(status == 1){
for(i = 0; i < 4; i++){
fSet[i] = fTest[i];
}
return 1;
}
if(mask[0] == 0) {
/*
* useless: when two theta problem there is no solution
*/
return 0;
}
}
return 0;
}
/*------------------- a test program ------------------------------------*/
#ifdef TESTCODE
int main(int argc, char *argv[]){