- Removed -fwritable-string

SKIPPED:
	psi/dornier2.c
	psi/ecbdriv.c
	psi/el734hp.c
	psi/libpsi.a
	psi/make_gen
	psi/makefile_linux
	psi/pimotor.c
	psi/pipiezo.c
	psi/sinqhttp.c
	psi/tcpdornier.c
	psi/velodornier.c
This commit is contained in:
koennecke
2006-03-31 15:24:52 +00:00
parent 4081448055
commit 51a60375d6
38 changed files with 1232 additions and 154 deletions

135
ubfour.c
View File

@ -10,6 +10,7 @@
*
* Mark Koennecke, March 2005
*/
#include <math.h>
#include "ubfour.h"
#include <assert.h>
#include "vector.h"
@ -376,3 +377,137 @@ int searchIndex(lattice direct, double lambda, double two_theta, double max_devi
LLDdelete(list);
return status;
}
/*-------------------------------------------------------------------------*/
double angleBetweenReflections(MATRIX B, reflection r1, reflection r2){
MATRIX chi1, chi2, h1, h2;
double angle;
h1 = makeVector();
if(h1 == NULL){
return -9999.99;
}
h1[0][0] = r1.h;
h1[1][0] = r1.k;
h1[2][0] = r1.l;
h2 = makeVector();
if(h2 == NULL){
return -999.99;
}
h2[0][0] = r2.h;
h2[1][0] = r2.k;
h2[2][0] = r2.l;
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;
}
/*---------------------------------------------------------------------------*/
MATRIX makeInstToConeVectorMatrix(reflection r,double lambda){
double z1[3], alpha, beta;
MATRIX mAlpha = NULL, mBeta = NULL, inst2CS = NULL;
z1FromAngles(lambda,r.s2t,r.om,r.chi,r.phi,z1);
alpha = atan2(z1[1],z1[0]);
beta = -atan2(z1[0],z1[2]);
/* printf("alpha = %f, beta = %f\n", alpha*57.57, beta*57.57);*/
mAlpha = mat_creat(3,3,ZERO_MATRIX);
mBeta = mat_creat(3,3,ZERO_MATRIX);
if(mAlpha == NULL || mBeta == NULL){
return NULL;
}
mAlpha[0][0] = cos(alpha);
mAlpha[0][1] = sin(alpha);
mAlpha[1][0] = -sin(alpha);
mAlpha[1][1] = cos(alpha);
mAlpha[2][2] = 1.;
mBeta[0][0] = cos(beta);
mBeta[0][2] = sin(beta);
mBeta[1][1] = 1.;
mBeta[2][0] = -sin(beta);
mBeta[2][2] = cos(beta);
inst2CS = mat_mul(mBeta,mAlpha);
mat_free(mAlpha);
mat_free(mBeta);
return inst2CS;
}
/*--------------------------------------------------------------------------*/
MATRIX calcConeVector(double openingAngle, double coneAngle,
double length, MATRIX coneToPsi){
MATRIX coneRot = NULL, nullVector = NULL, coneVector = NULL;
MATRIX coneVectorScatter = NULL;
double testAngle;
MATRIX z;
z = makeVector();
z[2][0] = 1.;
coneRot = mat_creat(3,3,ZERO_MATRIX);
if(coneRot == NULL){
return NULL;
}
coneRot[0][0] = Cosd(coneAngle);
coneRot[0][1] = -Sind(coneAngle);
coneRot[1][0] = Sind(coneAngle);
coneRot[1][1] = Cosd(coneAngle);
coneRot[2][2] = 1.0;
nullVector = makeVector();
if(nullVector == NULL){
return NULL;
}
nullVector[0][0] = Sind(openingAngle);
nullVector[1][0] = .0;
nullVector[2][0] = Cosd(openingAngle);
normalizeVector(nullVector);
scaleVector(nullVector,length);
testAngle = angleBetween(z,nullVector);
coneVector = mat_mul(coneRot,nullVector);
if(coneVector == NULL){
return NULL;
}
testAngle = angleBetween(z,coneVector);
coneVectorScatter = mat_mul(coneToPsi,coneVector);
mat_free(coneRot);
killVector(nullVector);
killVector(coneVector);
return coneVectorScatter;
}
/*---------------------------------------------------------------------------*/
double scatteringVectorLength(MATRIX B, reflection r){
MATRIX h = NULL, psi = NULL;
double length;
h = makeVector();
if(h == NULL){
return -9999.9;
}
h[0][0] = r.h;
h[1][0] = r.k;
h[2][0] = r.l;
psi = mat_mul(B,h);
length = vectorLength(psi);
killVector(h);
killVector(psi);
return length;
}