MayaChemTools

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