       1 package Constants;
       2 #
       3 # $RCSfile: Constants.pm,v $
       4 # $Date: 2015/02/28 20:47:02 $
       5 # $Revision: 1.21 $
       6 #
       7 # Author: Manish Sud <msud@san.rr.com>
       8 #
       9 # Copyright (C) 2015 Manish Sud. All rights reserved.
      10 #
      11 # This file is part of MayaChemTools.
      12 #
      13 # MayaChemTools is free software; you can redistribute it and/or modify it under
      14 # the terms of the GNU Lesser General Public License as published by the Free
      15 # Software Foundation; either version 3 of the License, or (at your option) any
      16 # later version.
      17 #
      18 # MayaChemTools is distributed in the hope that it will be useful, but without
      19 # any warranty; without even the implied warranty of merchantability of fitness
      20 # for a particular purpose.  See the GNU Lesser General Public License for more
      21 # details.
      22 #
      23 # You should have received a copy of the GNU Lesser General Public License
      24 # along with MayaChemTools; if not, see <http://www.gnu.org/licenses/> or
      25 # write to the Free Software Foundation Inc., 59 Temple Place, Suite 330,
      26 # Boston, MA, 02111-1307, USA.
      27 #
      28
      29 use strict;
      30 use Exporter;
      31
      32 use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
      33
      34 @ISA = qw(Exporter);
      35
      36 # Groups of constants...
      37 my(@MathConstants) = qw(Pi TwoPi PiByTwo PiByFour InversePi OneByPi SqrtTwoPi OneBySqrtTwoPi InverseSqrtTwoPi Phi E BigNumber);
      38
      39 # Export all constants...
      40 @EXPORT = (@MathConstants);
      41 @EXPORT_OK = qw();
      42
      43 # Tags to export individual groups of constants...
      44 %EXPORT_TAGS = (
      45                 math => [@MathConstants],
      46                 all  => [@EXPORT, @EXPORT_OK]
      47                );
      48
      49 # Math constants..
      50 use constant {
      51   Pi => CORE::atan2(0, -1),
      52   TwoPi => 2 * CORE::atan2(0, -1),
      53   PiByTwo => CORE::atan2(1, 0),
      54   PiByFour => CORE::atan2(1, 1),
      55   OneByPi => 1.0 / CORE::atan2(0, -1),
      56   InversePi => 1.0 / CORE::atan2(0, -1),
      57   SqrtTwoPi => CORE::sqrt(2 * CORE::atan2(0, -1)),
      58   OneBySqrtTwoPi => 1 / CORE::sqrt(2 * CORE::atan2(0, -1)),
      59   InverseSqrtTwoPi => 1 / CORE::sqrt(2 * CORE::atan2(0, -1)),
      60
      61   Phi => (1 + CORE::sqrt(5))/2, # Golden ratio...
      62
      63   E => CORE::exp(1),
      64
      65   BigNumber => 2**31 - 1, # Unsigned 31 bit number
      66
      67 };
      68