20 #ifndef JDFTX_FLUID_EULER_H 21 #define JDFTX_FLUID_EULER_H 34 #include <gsl/gsl_sf_gamma.h> 35 #include <gsl/gsl_sf_pow_int.h> 36 #include <core/matrix3.h> 40 {
double sBeta = sin(beta);
41 return vector3<>(sBeta*cos(alpha), sBeta*sin(alpha), cos(beta));
46 { euler[1] = acos(newZ[2]/newZ.length());
47 if(euler[1]*(M_PI-euler[1]) < 1e-6)
51 { euler[0] = atan2(newZ[1], newZ[0]);
57 {
return rotation(euler[0], 2)
58 * rotation(euler[1], 1)
59 * rotation(euler[2], 2);
64 {
if(fabs(mat(2,2))>1.-1e-7)
66 (mat(2,2)>0 ? 0. : M_PI),
67 atan2(-mat(1,0),mat(1,1)) );
69 return vector3<>( atan2(mat(1,2),-mat(0,2)),
71 atan2(mat(2,1),mat(2,0)) );
76 inline double wigner_d(
const int j,
const int m1,
const int m2,
const double beta)
80 int t4 = 2*j + m1 - m2;
82 int sMin = (-t3 < 0) ? 0 : -t3;
83 int sMax = (t2 < t1) ? t2 : t1;
85 double cosbeta = cos(beta * 0.5);
86 double sinbeta = sin(beta * 0.5);
87 double a = 0.5*(gsl_sf_lnfact(t1) + gsl_sf_lnfact(t2) + gsl_sf_lnfact(j-m1) + gsl_sf_lnfact(j+m2));
90 double sign = (sMin % 2 ? -1.0 : 1.0);
91 for(
int s = sMin; s <= sMax; s++)
92 { result += copysign(gsl_sf_pow_int(cosbeta, t4-2*s) * gsl_sf_pow_int(sinbeta, t3+2*s)
93 *
exp(a - (gsl_sf_lnfact(t1 - s) + gsl_sf_lnfact(t2 - s) + gsl_sf_lnfact(t3 + s) + gsl_sf_lnfact(s))), sign);
102 #endif // JDFTX_FLUID_EULER_H
void getEulerAxis(const vector3<> &newZ, vector3<> &euler)
Calculates euler[0]=alpha and euler[1]=beta given newZ, the direction of the Z-axis in the rotated fr...
Definition: Euler.h:45
vector3 eulerFromMatrix(const matrix3<> &mat)
Calculate euler angles from rotation matrices.
Definition: Euler.h:63
ScalarField exp(const ScalarField &)
Elementwise exponential (preserve input)
vector3 polarUnitVector(double alpha, double beta)
Get the position of the new Z-axis, given alpha and beta (does not depend on gamma) ...
Definition: Euler.h:39
matrix3 matrixFromEuler(const vector3<> &euler)
Calculate rotation matrices from euler angles.
Definition: Euler.h:56
double wigner_d(const int j, const int m1, const int m2, const double beta)
Wigner d-function d^j_{m1 m2}(beta) for ZYZ Euler angles.
Definition: Euler.h:76