.. oe:namespace:: OEChem

.. meta::
   :keywords: OEGetRadiusOfGyration

.. oe:function:: OEGetRadiusOfGyration

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

      .. oe:api::

         bool OEGetRadiusOfGyration(double* radiusOfGyration,
                                    const double* pmi, const OEMolBase& mol)
         bool OEGetRadiusOfGyration(double* radiusOfGyration,
                                    const double* pmi, const OEConfBase& mol)
         bool OEGetRadiusOfGyration(double* radiusOfGyration,
                                    const double* pmi, const OEMCMolBase& mol)

   .. oe:language:: python

      .. oe:api:: python

         OEGetRadiusOfGyration(rGyration: OEDoubleArray, pmi: OEDoubleArray,
                               mol: Union[OEGraphMol,OEQMol]) -> bool
         OEGetRadiusOfGyration(rGyration: OEDoubleArray, pmi: OEDoubleArray,
                               mol: OEConfBase) -> bool
         OEGetRadiusOfGyration(rGyration: OEDoubleArray, pmi: OEDoubleArray,
                               mol: OEMol) -> bool

   Calculates the radius of gyration of the given molecule, using the given PMI that has already been calculated
   with the function :oe:func:`OEChem::OECalcPMI`. Units of the calculated radius are the same as those used to
   set the radius of the molecule, which need to be the same radius units used to calculate the PMI.

   The function returns true if calculation is successful, false otherwise. If the molecule is not centered, or
   radius of gyration values are all 0, the function will return false,

   Note that for an :ref:`OEMCMolBase <OEChem_OEMCMolBase>`, the :oe:func:`OEChem::OECalcPMI` only calculates the PMI for the
   active conformer, and therefore this function similarly uses only the mass of the active conformer to calculate the
   radius of gyration.


   *radiusOfGyration*
      This double array will be populated by the radius of gyration in each dimension, X, Y, and Z.  
   
   *pmi*
      This is a pointer to the PMI of the given molecule in each dimension, in X, Y, and Z.

   *mol*
      This is the molecule for which the PMI is calculated. It must have a set radius and set mass for the calculation
      to be valid. 

   .. warning::

      These functions only work correctly with a molecule that has been centered using the function
      :oe:func:`OEChem::OECenter`. If the molecule has not been centered, the function will return false.

   .. seealso::

      * :oe:func:`OEChem::OECalcPMI` function to calculate principle moment of inertia.

   The following code snippet demonstrates how to calculate the PMI and radius of gyration for a molecule.

.. oe:source:: CalcPMI.cpp
   :language: c++
   :noindent:
   :frag:     SNIPPET-CALC-PMI

.. oe:source:: CalcPMI.py
   :language: python
   :noindent:
   :frag:     SNIPPET-CALC-PMI

.. oe:source:: CalcPMI.java
   :language: java
   :noindent:
   :frag:     SNIPPET-CALC-PMI

.. oe:source:: CalcPMI.cs
   :language: csharp
   :noindent:
   :frag:     SNIPPET-CALC-PMI