.. include:: ../../toolkit-substitutions

.. oe:namespace:: OEMolPotential



.. meta::
   :keywords: OEQuatAdaptor, QuatAdaptor


.. _OEMolPotential_OEQuatAdaptor:

.. oe:class:: OEQuatAdaptor

   .. attention::

      |TWOLANGUAGE|

   .. oe:api::


      class OEQuatAdaptor : public OEMolAdaptor

   The :ref:`OEQuatAdaptor <OEMolPotential_OEQuatAdaptor>` class provides the ability to rotate and translate
   a molecule as single rigid unit or solid body in the presence of an external field. Rotations
   are represented with quaternion variables.

   .. _figure_OEQuatAdaptor_Hierarchy:

   .. figure:: ../images/OEQuatAdaptor.*
      :align:  center

   The following methods are publicly inherited from :ref:`OEAdaptor <OEOpt_OEAdaptor>`:
    * :oe:meth:`AdaptVar<OEOpt::OEAdaptor::AdaptVar>` 
    * :oe:meth:`GetVar<OEOpt::OEAdaptor::GetVar>`

   The following methods are publicly inherited from :ref:`OEFunc0 <OEOpt_OEFunc0>`:
    * :oe:meth:`operator()<OEOpt::OEFunc0::operator()>`         
    * :oe:meth:`GetFComponents<OEOpt::OEFunc0::GetFComponents>` 
    * :oe:meth:`NumVar<OEOpt::OEFunc0::NumVar>`

   The following methods are publicly inherited from :ref:`OEFunc1 <OEOpt_OEFunc1>`:
    * :oe:meth:`operator()<OEOpt::OEFunc1::operator()>`
   
   The following methods are publicly inherited from :ref:`OEMolFunc <OEMolPotential_OEMolFunc>`:
    * :oe:meth:`Clear<OEMolPotential::OEMolFunc::Clear>`   
    * :oe:meth:`ClearPredicates<OEMolPotential::OEMolFunc::ClearPredicates>`
    * :oe:meth:`GetInteractions<OEMolPotential::OEMolFunc::GetInteractions>`
    * :oe:meth:`Setup<OEMolPotential::OEMolFunc::Setup>`

   The following methods are publicly inherited from :ref:`OEMolAdaptor <OEMolPotential_OEMolAdaptor>`:
    * :oe:meth:`SetMolFunc<OEMolPotential::OEMolAdaptor::SetMolFunc>`

   The :ref:`OEQuatAdaptor <OEMolPotential_OEQuatAdaptor>` class defines the following public methods:
    * :oe:meth:`AdaptGrad<OEMolPotential::OEQuatAdaptor::AdaptGrad>`
    * :oe:meth:`IsRedundant<OEMolPotential::OEQuatAdaptor::IsRedundant>`

   .. oe:method:: Constructors

      .. oe:language:: c++ java csharp

         .. oe:api::

            OEQuatAdaptor(OEMolFunc1 &, bool own = false,
                          bool excludeInteract = true)

      .. oe:language:: python

         .. oe:api:: python

            OEQuatAdaptor(arg2: OEMolFunc1, own: bool = False,
                          excludeInteract: bool = True) -> OEQuatAdaptor

      Default and copy constructors.

      Constructs an :ref:`OEQuatAdaptor <OEMolPotential_OEQuatAdaptor>` instance. The molecule function used
      for function evaluation must be provided as the first argument to the constructor. The 
      second argument specifies whether the :ref:`OEQuatAdaptor <OEMolPotential_OEQuatAdaptor>` object takes
      ownership of the memory of the molecule function instance. By default that does not happen,
      so the :ref:`OEQuatAdaptor <OEMolPotential_OEQuatAdaptor>` destructor does not delete the molecule function
      instance. If ownership of the molecule function is transferred to the
      :ref:`OEQuatAdaptor <OEMolPotential_OEQuatAdaptor>` instance, the molecule function's delete operator will
      be called in the :ref:`OEQuatAdaptor <OEMolPotential_OEQuatAdaptor>` destructor. The third argument
      controls the inclusion of invariant molecule function interactions. By default, interactions 
      which remain constant during the solid-body optimization (all intramolecular interactions)
      are excluded from calculation. If the third calling argument is ``false`` then all
      interactions will be computed during every function evaluation.

   .. oe:method:: operator=
      :language: c++

      .. oe:api::

         OEQuatAdaptor & operator=(const OEQuatAdaptor &)

      Assignment operator.


   .. oe:method:: AdaptGrad

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool AdaptGrad(double* qg, const double* g, const double* quat,
                           const double* coords) const

      .. oe:language:: python

         .. oe:api:: python

            AdaptGrad(qg: OEDoubleArray, g: OEDoubleArray, quat: OEDoubleArray,
                      coords: OEDoubleArray) -> bool

      Transforms a set of the input Cartesian gradients (second argument) into rotation and translation 
      gradients which are copied to the first argument array. Third and fourth arguments are the arrays 
      of quaternion plus translation vector and Cartesian coordinates respectively, used for the
      transformation.

   .. oe:method:: IsRedundant

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool IsRedundant(const double* x, const double* y,
                             const double tolerance = 0.1) const

      .. oe:language:: python

         .. oe:api:: python

            IsRedundant(x: OEDoubleArray, y: OEDoubleArray,
                        tolerance: float = 0.1) -> bool

      Compares two sets of quaternions-translational vectors coordinates. If points ``x`` and
      ``y`` represent the same point in Cartesian space within given tolerance, method returns
      ``true``.  


