From e6c78ef4d650783009308c698cd4186cf64b7aac Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Mon, 7 May 2007 16:27:07 +1000 Subject: [PATCH] Resolved conflict in favour of release 1.3 r1943 | ffr | 2007-05-07 16:27:07 +1000 (Mon, 07 May 2007) | 2 lines --- nxscript.c | 111 ++++++++++------------------------------------------- 1 file changed, 20 insertions(+), 91 deletions(-) diff --git a/nxscript.c b/nxscript.c index 7043c41a..b7990fa4 100644 --- a/nxscript.c +++ b/nxscript.c @@ -918,69 +918,35 @@ static void putArray(SConnection *pCon, SicsInterp *pSics, /* ANSTO MOD1 START */ /**\brief Calculates polar angles on a 2D grid for cylindrical detectors. * - * param dradius detector radius * param angsep angular separation between detector columns in radians * param active_height_mm of a detector in mm * param det_rot_rad detector rotation in radians - * param row_zero vertical pixel at beam centre. - * param ROI_row_offset horizontal pixel offset of ROI * param col_zero horizontal pixel at beam centre for detector rotation of zero. - * param ROI_col_offset vertical pixel offset of ROI * param rownum number of detector rows * param colnum number of detector columns * * Detector pixel layout uses display coordinates viewed from the sample. * ie If you stand at the sample and face the detector the (0,0) is at the - * left. + * top left corner. */ float *G_TwoThetaArr=NULL; -void polar_angle(int folding, int dim, double dradius, double angsep, double active_height_mm, double det_rot_rad, double row_zero, double ROI_row_offset, double col_zero, double ROI_col_offset, double pixelrownum, double pixelcolnum) { +void polar_angle(double angsep, double active_height_mm, double det_rot_rad, double col_zero, double rownum, double colnum) { - int row,col; - double rowsep, height, alpha, pang; - double rowstart, rowend, rownum, colnum, pixelrow, pixelcol; - - if (folding == 1) { - rownum = pixelrownum; - colnum = pixelcolnum; - } else { - rownum = pixelrownum/2; - colnum = pixelcolnum*2; - } + int col; + double rowsep, alpha; + double deg_per_rad = 57.29578; if (G_TwoThetaArr != NULL) free(G_TwoThetaArr); - G_TwoThetaArr = (float *)malloc(rownum*colnum*sizeof(float)); + G_TwoThetaArr = (float *)malloc(colnum*sizeof(float)); rowsep = active_height_mm/(rownum-1); - if (dim==1) { - rowstart = rownum/2; - rowend = rownum/2; - } else { - rowstart = 0; - rowend = rownum; - } - for (row=rowstart; row < rowend; row++) { - height=(row_zero - ROI_row_offset - row)*rowsep; - for (col=0; col < colnum; col++) { - alpha = (col_zero - ROI_col_offset - col)*angsep + det_rot_rad; - pang = acos(dradius * cos(alpha)/sqrt(dradius*dradius+ height*height)); - if (folding == 1) { - G_TwoThetaArr[(int)(row*colnum+col)]=pang; - } else { - if (col%2==0) { - pixelrow = row + rownum; - pixelcol = col/2; - } else { - pixelrow = (rownum - 1) - row; - pixelcol = (col-1)/2; - } - G_TwoThetaArr[(int)(pixelrow*pixelcolnum+pixelcol)]=pang; - } - } + for (col=0; col < colnum; col++) { + alpha = fabs((col_zero - col)*angsep + det_rot_rad); + G_TwoThetaArr[col]=(float)(alpha*deg_per_rad); } } @@ -992,9 +958,8 @@ static void putPolarArray(SConnection *pCon, SicsInterp *pSics, char buffer[256]; Tcl_Interp *tcl = NULL; - int folding, dim; - double angsep, det_rot_rad, active_height_mm, rowsep; - double row_zero, ROI_row_offset, col_zero, ROI_col_offset, dradius; + double angsep, det_rot_rad, active_height_mm; + double col_zero; double rownum, colnum; if(argc < 11){ @@ -1017,79 +982,43 @@ static void putPolarArray(SConnection *pCon, SicsInterp *pSics, SCWrite(pCon,"ERROR: failed to convert size value list", eError); return; } - status = Tcl_GetInt(tcl,argv[5],&folding); + status = Tcl_GetDouble(tcl,argv[5],&angsep); if(status != TCL_OK){ - sprintf(buffer,"ERROR: failed to convert %s to int",argv[5]); + sprintf(buffer,"ERROR: failed to convert %s to double",argv[5]); SCWrite(pCon,buffer,eError); return; } - status = Tcl_GetInt(tcl,argv[6],&dim); + status = Tcl_GetDouble(tcl,argv[6],&active_height_mm); if(status != TCL_OK){ - sprintf(buffer,"ERROR: failed to convert %s to int",argv[6]); + sprintf(buffer,"ERROR: failed to convert %s to double",argv[6]); SCWrite(pCon,buffer,eError); return; } - status = Tcl_GetDouble(tcl,argv[7],&dradius); + status = Tcl_GetDouble(tcl,argv[7],&det_rot_rad); if(status != TCL_OK){ sprintf(buffer,"ERROR: failed to convert %s to double",argv[7]); SCWrite(pCon,buffer,eError); return; } - status = Tcl_GetDouble(tcl,argv[8],&angsep); + status = Tcl_GetDouble(tcl,argv[8],&col_zero); if(status != TCL_OK){ sprintf(buffer,"ERROR: failed to convert %s to double",argv[8]); SCWrite(pCon,buffer,eError); return; } - status = Tcl_GetDouble(tcl,argv[9],&active_height_mm); + status = Tcl_GetDouble(tcl,argv[9],&rownum); if(status != TCL_OK){ sprintf(buffer,"ERROR: failed to convert %s to double",argv[9]); SCWrite(pCon,buffer,eError); return; } - status = Tcl_GetDouble(tcl,argv[10],&det_rot_rad); + status = Tcl_GetDouble(tcl,argv[10],&colnum); if(status != TCL_OK){ sprintf(buffer,"ERROR: failed to convert %s to double",argv[10]); SCWrite(pCon,buffer,eError); return; - } - status = Tcl_GetDouble(tcl,argv[11],&row_zero); - if(status != TCL_OK){ - sprintf(buffer,"ERROR: failed to convert %s to double",argv[11]); - SCWrite(pCon,buffer,eError); - return; - } - status = Tcl_GetDouble(tcl,argv[12],&ROI_row_offset); - if(status != TCL_OK){ - sprintf(buffer,"ERROR: failed to convert %s to double",argv[12]); - SCWrite(pCon,buffer,eError); - return; - } - status = Tcl_GetDouble(tcl,argv[13],&col_zero); - if(status != TCL_OK){ - sprintf(buffer,"ERROR: failed to convert %s to double",argv[13]); - SCWrite(pCon,buffer,eError); - return; - } - status = Tcl_GetDouble(tcl,argv[14],&ROI_col_offset); - if(status != TCL_OK){ - sprintf(buffer,"ERROR: failed to convert %s to double",argv[14]); - SCWrite(pCon,buffer,eError); - return; - } - status = Tcl_GetDouble(tcl,argv[15],&rownum); - if(status != TCL_OK){ - sprintf(buffer,"ERROR: failed to convert %s to double",argv[15]); - SCWrite(pCon,buffer,eError); - return; - } - status = Tcl_GetDouble(tcl,argv[16],&colnum); - if(status != TCL_OK){ - sprintf(buffer,"ERROR: failed to convert %s to double",argv[16]); - SCWrite(pCon,buffer,eError); - return; } - polar_angle(folding, dim, dradius, angsep, active_height_mm, det_rot_rad, row_zero, ROI_row_offset, col_zero, ROI_col_offset, rownum, colnum); + polar_angle(angsep, active_height_mm, det_rot_rad, col_zero, rownum, colnum); // status = NXDputalias(self->fileHandle, self->dictHandle,argv[2],G_TwoThetaArr); status = NXDopenalias(self->fileHandle, self->dictHandle,argv[2]);