12 static double mod(
double a,
double b) {
24 return 12398.4172/energy;
38 return 12398.4172/wavelength;
48 return 4.0*M_PI*sin( (twoTheta*M_PI/180.0) /2.0)/wavelength;
55 return 2.0*asin(Q*wavelength/(4*M_PI))*180.0/M_PI;
59 double distance,
double xPixel,
double yPixel,
60 double pixelLength,
double pixelHeight,
61 double cos_beta,
double sin_beta,
62 double cos_rotation,
double sin_rotation)
64 double pixelLength_mm,pixelHeight_mm;
65 double xMeasured,yMeasured;
67 double xPhysical,yPhysical;
73 pixelLength_mm = pixelLength/1000.0;
74 pixelHeight_mm = pixelHeight/1000.0;
76 xMeasured = (xPixel-xCenter)*pixelLength_mm;
77 yMeasured = (yPixel-yCenter)*pixelHeight_mm;
79 bottom = distance+(xMeasured*cos_rotation+
80 yMeasured*sin_rotation)*sin_beta
86 xPhysical = distance*((xMeasured*cos_rotation+
87 yMeasured*sin_rotation)*cos_beta
91 yPhysical = distance*(-xMeasured*sin_rotation+
92 yMeasured*cos_rotation)/bottom;
94 return sqrt(xPhysical*xPhysical + yPhysical*yPhysical);
98 double distance,
double xPixel,
double yPixel,
99 double pixelLength,
double pixelHeight,
100 double cos_beta,
double sin_beta,
101 double cos_rotation,
double sin_rotation)
103 double pixelLength_mm,pixelHeight_mm;
104 double xMeasured,yMeasured;
106 double xPhysical,yPhysical;
113 pixelLength_mm = pixelLength/1000.0;
114 pixelHeight_mm = pixelHeight/1000.0;
116 xMeasured = (xPixel-xCenter)*pixelLength_mm;
117 yMeasured = (yPixel-yCenter)*pixelHeight_mm;
119 bottom = distance+(xMeasured*cos_rotation+
120 yMeasured*sin_rotation)*sin_beta
126 xPhysical = distance*((xMeasured*cos_rotation+
127 yMeasured*sin_rotation)*cos_beta
131 yPhysical = distance*(-xMeasured*sin_rotation+
132 yMeasured*cos_rotation)/bottom;
134 twoTheta = atan2(sqrt(xPhysical*xPhysical+
135 yPhysical*yPhysical),distance);
137 twoTheta = twoTheta * 180.0/M_PI;
167 double distance,
double xPixel,
double yPixel,
168 double pixelLength,
double pixelHeight,
169 double rotation,
double cos_beta,
double sin_beta,
170 double cos_alpha,
double sin_alpha,
171 double cos_rotation,
double sin_rotation,
172 double *twoTheta,
double *chi)
174 double pixelLength_mm,pixelHeight_mm;
175 double xMeasured,yMeasured;
177 double xPhysical,yPhysical;
183 pixelLength_mm = pixelLength/1000.0;
184 pixelHeight_mm = pixelHeight/1000.0;
186 xMeasured = (xPixel-xCenter)*pixelLength_mm;
187 yMeasured = (yPixel-yCenter)*pixelHeight_mm;
189 bottom = distance+(xMeasured*cos_rotation+
190 yMeasured*sin_rotation)*sin_beta+
191 (-xMeasured*sin_rotation+
192 yMeasured*cos_rotation)*sin_alpha*cos_beta;
196 xPhysical = distance*((xMeasured*cos_rotation+
197 yMeasured*sin_rotation)*cos_beta
198 -(-xMeasured*sin_rotation+
199 yMeasured*cos_rotation)*sin_alpha)/bottom;
201 yPhysical = distance*(-xMeasured*sin_rotation+
202 yMeasured*cos_rotation)*cos_alpha/bottom;
204 *twoTheta = atan2(sqrt(xPhysical*xPhysical+
205 yPhysical*yPhysical),distance);
207 *twoTheta = *twoTheta * 180.0/M_PI;
210 *chi=atan2(yPhysical,xPhysical)*180.0/M_PI;
219 *chi = (*chi + rotation*180.0/M_PI)*(-1);
222 *chi =
mod(*chi, 360.0);
227 double energy,
double xPixel,
double yPixel,
228 double pixelLength,
double pixelHeight,
229 double rotation,
double cos_beta,
double sin_beta,
230 double cos_alpha,
double sin_alpha,
231 double cos_rotation,
double sin_rotation,
232 double *q,
double *chi)
237 wavelength = 12398.4172/energy;
240 pixelLength,pixelHeight,rotation,cos_beta,sin_beta,
241 cos_alpha,sin_alpha,cos_rotation,sin_rotation,
258 double energy,
double q,
double chi,
double pixelLength,
259 double pixelHeight,
double rotation,
double cos_beta,
260 double sin_beta,
double cos_alpha,
double sin_alpha,
261 double cos_rotation,
double sin_rotation,
262 double * xPixel,
double * yPixel)
266 double xPhysical,yPhysical;
268 double pixelLength_mm,pixelHeight_mm;
269 double xMeasured,yMeasured;
273 wavelength = 12398.4172/energy;
277 chi = chi*(-1) - rotation;
279 chi =
mod(chi, 360.0);
284 twoTheta = 2.0*asin(wavelength*q/(4.0*M_PI));
287 xPhysical = fabs(distance*tan(twoTheta)/sqrt(1.0+
293 if (chi>M_PI/2.0 && chi<3.0*M_PI/2.0)
294 xPhysical = -1.0*xPhysical;
296 yPhysical=fabs(xPhysical*tan_chi);
299 if (chi > M_PI && chi < 2.0*M_PI)
300 yPhysical = -1.0*fabs(yPhysical);
303 bottom = distance*cos_beta-xPhysical*sin_beta-
304 cos_beta*(xPhysical*cos_beta+distance)/(
305 (xPhysical*cos_alpha)/(yPhysical*sin_alpha)+1);
307 xMeasured = (distance*xPhysical*cos_rotation-
308 distance*xPhysical*cos_beta*sin_rotation/
309 (xPhysical*cos_alpha/yPhysical+sin_alpha))/
312 yMeasured = (distance*xPhysical*sin_rotation+
313 distance*xPhysical*cos_beta*cos_rotation/
314 (xPhysical*cos_alpha/yPhysical+sin_alpha))/
320 pixelLength_mm = pixelLength/1000.0;
321 pixelHeight_mm = pixelHeight/1000.0;
323 *xPixel = xMeasured/pixelLength_mm + xCenter;
324 *yPixel = yMeasured/pixelHeight_mm + yCenter;
QxrdDetectorGeometry(QString name, QcepObject *parent)
static double convertEnergyToWavelength(double energy)
static double convertWavelengthToEnergy(double wavelength)
static void getQChi(double xCenter, double yCenter, double distance, double energy, double xPixel, double yPixel, double pixelLength, double pixelHeight, double rotation, double cos_beta, double sin_beta, double cos_alpha, double sin_alpha, double cos_rotation, double sin_rotation, double *q, double *chi)
static void getTwoThetaChi(double xCenter, double yCenter, double distance, double xPixel, double yPixel, double pixelLength, double pixelHeight, double rotation, double cos_beta, double sin_beta, double cos_alpha, double sin_alpha, double cos_rotation, double sin_rotation, double *twoTheta, double *chi)
static double convertTwoThetaToQ(double twoTheta, double wavelength)
static double getRadius(double xCenter, double yCenter, double distance, double xPixel, double yPixel, double pixelLength, double pixelHeight, double cos_beta, double sin_beta, double cos_rotation, double sin_rotation)
static double mod(double a, double b)
static double getTwoTheta(double xCenter, double yCenter, double distance, double xPixel, double yPixel, double pixelLength, double pixelHeight, double cos_beta, double sin_beta, double cos_rotation, double sin_rotation)
static void getXY(double xCenter, double yCenter, double distance, double energy, double q, double chi, double pixelLength, double pixelHeight, double rotation, double cos_beta, double sin_beta, double cos_alpha, double sin_alpha, double cos_rotation, double sin_rotation, double *xPixel, double *yPixel)
static double convertQToTwoTheta(double Q, double wavelength)