From d139da653a7b544663e36a81d12850a83dd808ac Mon Sep 17 00:00:00 2001
From: Walter Van Herck <w.van.herck@fz-juelich.de>
Date: Thu, 26 Jul 2018 18:20:18 +0200
Subject: [PATCH] Remove delta parameter in 2d decay functions and simplify
 InterferenceFunction2DLattice::transformToPrincipalAxes

---
 Core/Aggregate/FTDecayFunctions.cpp           | 14 ++++-----
 Core/Aggregate/FTDecayFunctions.h             |  4 ---
 .../InterferenceFunction2DLattice.cpp         |  8 ++---
 .../Aggregate/InterferenceFunction2DLattice.h |  2 +-
 auto/Wrap/libBornAgainCore.py                 | 12 --------
 auto/Wrap/libBornAgainCore_wrap.cpp           | 30 -------------------
 6 files changed, 10 insertions(+), 60 deletions(-)

diff --git a/Core/Aggregate/FTDecayFunctions.cpp b/Core/Aggregate/FTDecayFunctions.cpp
index c6739578907..b3098199cac 100644
--- a/Core/Aggregate/FTDecayFunctions.cpp
+++ b/Core/Aggregate/FTDecayFunctions.cpp
@@ -144,19 +144,15 @@ double FTDecayFunction1DCosine::evaluate(double q) const
 //! @param gamma: distribution orientation with respect to the corresponding lattice vector
 //! in radians
 IFTDecayFunction2D::IFTDecayFunction2D(double decay_length_x, double decay_length_y, double gamma)
-    : m_decay_length_x(decay_length_x), m_decay_length_y(decay_length_y), m_gamma(gamma),
-      m_delta(M_PI_2)
-{
-}
+    : m_decay_length_x(decay_length_x), m_decay_length_y(decay_length_y), m_gamma(gamma)
+{}
 
 void IFTDecayFunction2D::transformToStarBasis(double qX, double qY, double alpha, double a,
                                               double b, double& qa, double& qb) const
 {
-    double prefactor = 1.0 / M_TWOPI; // divide by sin(m_delta)
-                                      // for unnormalized X*,Y* basis
-    qa = a * prefactor * (std::sin(m_gamma + m_delta) * qX - std::sin(m_gamma) * qY);
-    qb = b * prefactor
-         * (-std::sin(alpha - m_gamma - m_delta) * qX + std::sin(alpha - m_gamma) * qY);
+    double prefactor = 1.0 / M_TWOPI;
+    qa = a * prefactor * (std::cos(m_gamma) * qX - std::sin(m_gamma) * qY);
+    qb = b * prefactor * (std::cos(alpha - m_gamma) * qX + std::sin(alpha - m_gamma) * qY);
 }
 
 void IFTDecayFunction2D::register_decay_lengths()
diff --git a/Core/Aggregate/FTDecayFunctions.h b/Core/Aggregate/FTDecayFunctions.h
index abf68ed53f8..226fb65e000 100644
--- a/Core/Aggregate/FTDecayFunctions.h
+++ b/Core/Aggregate/FTDecayFunctions.h
@@ -117,9 +117,6 @@ public:
     //! get angle between first lattice vector and X-axis of distribution (both in direct space)
     double gamma() const { return m_gamma; }
 
-    //! get angle between X- and Y-axis of distribution (in direct space)
-    double delta() const { return m_delta; }
-
     //! get decay length in distribution's X-direction
     double decayLengthX() const { return m_decay_length_x; }
 
@@ -140,7 +137,6 @@ protected:
     double m_decay_length_x;
     double m_decay_length_y;
     double m_gamma;
-    double m_delta;
 };
 
 
diff --git a/Core/Aggregate/InterferenceFunction2DLattice.cpp b/Core/Aggregate/InterferenceFunction2DLattice.cpp
index b59af137945..eb967dc3ec2 100644
--- a/Core/Aggregate/InterferenceFunction2DLattice.cpp
+++ b/Core/Aggregate/InterferenceFunction2DLattice.cpp
@@ -172,16 +172,16 @@ double InterferenceFunction2DLattice::interferenceAtOneRecLatticePoint(double qx
             " -> Error! No decay function defined.");
     double qp1, qp2;
     double gamma = m_decay->gamma();
-    double delta = m_decay->delta();
-    transformToPrincipalAxes(qx, qy, gamma, delta, qp1, qp2);
+    transformToPrincipalAxes(qx, qy, gamma, qp1, qp2);
     return m_decay->evaluate(qp1, qp2);
 }
 
+// Rotate between orthonormal systems (q_x,q_y) -> (q_X,q_Y)
 void InterferenceFunction2DLattice::transformToPrincipalAxes(
-    double qx, double qy, double gamma, double delta, double &q_pa_1, double &q_pa_2) const
+    double qx, double qy, double gamma, double &q_pa_1, double &q_pa_2) const
 {
     q_pa_1 = qx * std::cos(gamma) + qy * std::sin(gamma);
-    q_pa_2 = qx * std::cos(gamma + delta) + qy * std::sin(gamma + delta);
+    q_pa_2 = -qx * std::sin(gamma) + qy * std::cos(gamma);
 }
 
 void InterferenceFunction2DLattice::calculateReciprocalVectorFraction(
diff --git a/Core/Aggregate/InterferenceFunction2DLattice.h b/Core/Aggregate/InterferenceFunction2DLattice.h
index 46126f735df..74183727585 100644
--- a/Core/Aggregate/InterferenceFunction2DLattice.h
+++ b/Core/Aggregate/InterferenceFunction2DLattice.h
@@ -66,7 +66,7 @@ private:
 
     //! Returns reciprocal coordinates in the principal axis system
     void transformToPrincipalAxes(double qx, double qy, double gamma,
-                                  double delta, double& q_pa_1, double& q_pa_2) const;
+                                  double& q_pa_1, double& q_pa_2) const;
 
     //! Returns qx,qy coordinates of q - qint, where qint is a reciprocal lattice vector
     //! bounding the reciprocal unit cell to which q belongs
diff --git a/auto/Wrap/libBornAgainCore.py b/auto/Wrap/libBornAgainCore.py
index 0f9e7585e67..30c4b4286dd 100644
--- a/auto/Wrap/libBornAgainCore.py
+++ b/auto/Wrap/libBornAgainCore.py
@@ -10340,18 +10340,6 @@ class IFTDecayFunction2D(ICloneable, INode):
         return _libBornAgainCore.IFTDecayFunction2D_gamma(self)
 
 
-    def delta(self):
-        """
-        delta(IFTDecayFunction2D self) -> double
-
-        double IFTDecayFunction2D::delta() const
-
-        get angle between X- and Y-axis of distribution (in direct space) 
-
-        """
-        return _libBornAgainCore.IFTDecayFunction2D_delta(self)
-
-
     def decayLengthX(self):
         """
         decayLengthX(IFTDecayFunction2D self) -> double
diff --git a/auto/Wrap/libBornAgainCore_wrap.cpp b/auto/Wrap/libBornAgainCore_wrap.cpp
index 9f73b66123c..59145feefb4 100644
--- a/auto/Wrap/libBornAgainCore_wrap.cpp
+++ b/auto/Wrap/libBornAgainCore_wrap.cpp
@@ -66393,28 +66393,6 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_IFTDecayFunction2D_delta(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  IFTDecayFunction2D *arg1 = (IFTDecayFunction2D *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  double result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:IFTDecayFunction2D_delta",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_IFTDecayFunction2D, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IFTDecayFunction2D_delta" "', argument " "1"" of type '" "IFTDecayFunction2D const *""'"); 
-  }
-  arg1 = reinterpret_cast< IFTDecayFunction2D * >(argp1);
-  result = (double)((IFTDecayFunction2D const *)arg1)->delta();
-  resultobj = SWIG_From_double(static_cast< double >(result));
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
 SWIGINTERN PyObject *_wrap_IFTDecayFunction2D_decayLengthX(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   IFTDecayFunction2D *arg1 = (IFTDecayFunction2D *) 0 ;
@@ -128409,14 +128387,6 @@ static PyMethodDef SwigMethods[] = {
 		"get angle between first lattice vector and X-axis of distribution (both in direct space) \n"
 		"\n"
 		""},
-	 { (char *)"IFTDecayFunction2D_delta", _wrap_IFTDecayFunction2D_delta, METH_VARARGS, (char *)"\n"
-		"IFTDecayFunction2D_delta(IFTDecayFunction2D self) -> double\n"
-		"\n"
-		"double IFTDecayFunction2D::delta() const\n"
-		"\n"
-		"get angle between X- and Y-axis of distribution (in direct space) \n"
-		"\n"
-		""},
 	 { (char *)"IFTDecayFunction2D_decayLengthX", _wrap_IFTDecayFunction2D_decayLengthX, METH_VARARGS, (char *)"\n"
 		"IFTDecayFunction2D_decayLengthX(IFTDecayFunction2D self) -> double\n"
 		"\n"
-- 
GitLab