Changeset 8698a0d in sasmodels for sasmodels/kernel_header.c
- Timestamp:
- Oct 17, 2017 9:53:01 PM (7 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 32f87a5
- Parents:
- becded3
- git-author:
- Paul Kienzle <pkienzle@…> (10/17/17 16:23:09)
- git-committer:
- Paul Kienzle <pkienzle@…> (10/17/17 21:53:01)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kernel_header.c
r73cbc5b r8698a0d 87 87 88 88 #if defined(NEED_EXPM1) 89 // TODO: precision is a half digit lower than numpy on mac in [1e-7, 0.5] 90 // Run "explore/precision.py sas_expm1" to see this (may have to fiddle 91 // the xrange for log to see the complete range). 89 92 static SAS_DOUBLE expm1(SAS_DOUBLE x_in) { 90 93 double x = (double)x_in; // go back to float for single precision kernels … … 147 150 inline double cube(double x) { return x*x*x; } 148 151 inline double sas_sinx_x(double x) { return x==0 ? 1.0 : sin(x)/x; } 149 150 // To rotate from the canonical position to theta, phi, psi, first rotate by151 // psi about the major axis, oriented along z, which is a rotation in the152 // detector plane xy. Next rotate by theta about the y axis, aligning the major153 // axis in the xz plane. Finally, rotate by phi in the detector plane xy.154 // To compute the scattering, undo these rotations in reverse order:155 // rotate in xy by -phi, rotate in xz by -theta, rotate in xy by -psi156 // The returned q is the length of the q vector and (xhat, yhat, zhat) is a unit157 // vector in the q direction.158 // To change between counterclockwise and clockwise rotation, change the159 // sign of phi and psi.160 161 #if 1162 //think cos(theta) should be sin(theta) in new coords, RKH 11Jan2017163 #define ORIENT_SYMMETRIC(qx, qy, theta, phi, q, sn, cn) do { \164 SINCOS(phi*M_PI_180, sn, cn); \165 q = sqrt(qx*qx + qy*qy); \166 cn = (q==0. ? 1.0 : (cn*qx + sn*qy)/q * sin(theta*M_PI_180)); \167 sn = sqrt(1 - cn*cn); \168 } while (0)169 #else170 // SasView 3.x definition of orientation171 #define ORIENT_SYMMETRIC(qx, qy, theta, phi, q, sn, cn) do { \172 SINCOS(theta*M_PI_180, sn, cn); \173 q = sqrt(qx*qx + qy*qy);\174 cn = (q==0. ? 1.0 : (cn*cos(phi*M_PI_180)*qx + sn*qy)/q); \175 sn = sqrt(1 - cn*cn); \176 } while (0)177 #endif178 179 #if 1180 #define ORIENT_ASYMMETRIC(qx, qy, theta, phi, psi, q, xhat, yhat, zhat) do { \181 q = sqrt(qx*qx + qy*qy); \182 const double qxhat = qx/q; \183 const double qyhat = qy/q; \184 double sin_theta, cos_theta; \185 double sin_phi, cos_phi; \186 double sin_psi, cos_psi; \187 SINCOS(theta*M_PI_180, sin_theta, cos_theta); \188 SINCOS(phi*M_PI_180, sin_phi, cos_phi); \189 SINCOS(psi*M_PI_180, sin_psi, cos_psi); \190 xhat = qxhat*(-sin_phi*sin_psi + cos_theta*cos_phi*cos_psi) \191 + qyhat*( cos_phi*sin_psi + cos_theta*sin_phi*cos_psi); \192 yhat = qxhat*(-sin_phi*cos_psi - cos_theta*cos_phi*sin_psi) \193 + qyhat*( cos_phi*cos_psi - cos_theta*sin_phi*sin_psi); \194 zhat = qxhat*(-sin_theta*cos_phi) \195 + qyhat*(-sin_theta*sin_phi); \196 } while (0)197 #else198 // SasView 3.x definition of orientation199 #define ORIENT_ASYMMETRIC(qx, qy, theta, phi, psi, q, cos_alpha, cos_mu, cos_nu) do { \200 q = sqrt(qx*qx + qy*qy); \201 const double qxhat = qx/q; \202 const double qyhat = qy/q; \203 double sin_theta, cos_theta; \204 double sin_phi, cos_phi; \205 double sin_psi, cos_psi; \206 SINCOS(theta*M_PI_180, sin_theta, cos_theta); \207 SINCOS(phi*M_PI_180, sin_phi, cos_phi); \208 SINCOS(psi*M_PI_180, sin_psi, cos_psi); \209 cos_alpha = cos_theta*cos_phi*qxhat + sin_theta*qyhat; \210 cos_mu = (-sin_theta*cos_psi*cos_phi - sin_psi*sin_phi)*qxhat + cos_theta*cos_psi*qyhat; \211 cos_nu = (-cos_phi*sin_psi*sin_theta + sin_phi*cos_psi)*qxhat + sin_psi*cos_theta*qyhat; \212 } while (0)213 #endif
Note: See TracChangeset
for help on using the changeset viewer.