static PyObject * makeBinaryRotMat(PyObject * self, PyObject * args) { PyArrayObject *axis, *rMat; int da; npy_intp na, dims[2]; double *aPtr, *rPtr; /* Parse arguments */ if ( !PyArg_ParseTuple(args,"O", &axis)) return(NULL); if ( axis == NULL ) return(NULL); /* Verify shape of input arrays */ da = PyArray_NDIM(axis); assert( da == 1 ); /* Verify dimensions of input arrays */ na = PyArray_DIMS(axis)[0]; assert( na == 3 ); /* Allocate the result matrix with appropriate dimensions and type */ dims[0] = 3; dims[1] = 3; rMat = (PyArrayObject*)PyArray_EMPTY(2,dims,NPY_DOUBLE,0); /* Grab pointers to the various data arrays */ aPtr = (double*)PyArray_DATA(axis); rPtr = (double*)PyArray_DATA(rMat); /* Call the actual function */ makeBinaryRotMat_cfunc(aPtr,rPtr); return((PyObject*)rMat); }
void gvecToDetectorXYOne_cfunc(double * gVec_c, double * rMat_d, double * rMat_sc, double * tVec_d, double * bHat_l, double * nVec_l, double num, double * P0_l, double * result) { int j, k; double bDot, ztol, denom, u; double gHat_c[3], gVec_l[3], dVec_l[3], P2_l[3], P2_d[3]; double brMat[9]; ztol = epsf; /* Compute unit reciprocal lattice vector in crystal frame w/o translation */ unitRowVector_cfunc(3,gVec_c,gHat_c); /* Compute unit reciprocal lattice vector in lab frame and dot with beam vector */ bDot = 0.0; for (j=0; j<3; j++) { gVec_l[j] = 0.0; for (k=0; k<3; k++) gVec_l[j] += rMat_sc[3*j+k]*gHat_c[k]; bDot -= bHat_l[j]*gVec_l[j]; } if ( bDot >= ztol && bDot <= 1.0-ztol ) { /* If we are here diffraction is possible so increment the number of admissable vectors */ makeBinaryRotMat_cfunc(gVec_l,brMat); denom = 0.0; for (j=0; j<3; j++) { dVec_l[j] = 0.0; for (k=0; k<3; k++) dVec_l[j] -= brMat[3*j+k]*bHat_l[k]; denom += nVec_l[j]*dVec_l[j]; } if ( denom < -ztol ) { u = num/denom; for (j=0; j<3; j++) P2_l[j] = P0_l[j]+u*dVec_l[j]; for (j=0; j<2; j++) { P2_d[j] = 0.0; for (k=0; k<3; k++) P2_d[j] += rMat_d[3*k+j]*(P2_l[k]-tVec_d[k]); result[j] = P2_d[j]; } } else { result[0] = NAN; result[1] = NAN; } } else { result[0] = NAN; result[1] = NAN; } }