1 package Constants; 2 # 3 # $RCSfile: Constants.pm,v $ 4 # $Date: 2008/04/19 16:10:59 $ 5 # $Revision: 1.9 $ 6 # 7 # Author: Manish Sud <msud@san.rr.com> 8 # 9 # Copyright (C) 2004-2008 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 use 5.006; 29 use strict; 30 use Exporter; 31 32 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); 33 34 $VERSION = '1.00'; 35 @ISA = qw(Exporter); 36 37 # Groups of constants... 38 my(@MathConstants) = qw(Pi TwoPi PiByTwo PiByFour InversePi OneByPi SqrtTwoPi OneBySqrtTwoPi InverseSqrtTwoPi Phi E); 39 40 # Export all constants... 41 @EXPORT = (@MathConstants); 42 @EXPORT_OK = qw(); 43 44 # Tags to export individual groups of constants... 45 %EXPORT_TAGS = ( 46 math => [@MathConstants], 47 all => [@EXPORT, @EXPORT_OK] 48 ); 49 50 # Math constants.. 51 use constant { 52 Pi => CORE::atan2(0, -1), 53 TwoPi => 2 * CORE::atan2(0, -1), 54 PiByTwo => CORE::atan2(1, 0), 55 PiByFour => CORE::atan2(1, 1), 56 OneByPi => 1.0 / CORE::atan2(0, -1), 57 InversePi => 1.0 / CORE::atan2(0, -1), 58 SqrtTwoPi => CORE::sqrt(2 * CORE::atan2(0, -1)), 59 OneBySqrtTwoPi => 1 / CORE::sqrt(2 * CORE::atan2(0, -1)), 60 InverseSqrtTwoPi => 1 / CORE::sqrt(2 * CORE::atan2(0, -1)), 61 62 Phi => (1 + CORE::sqrt(5))/2, # Golden ratio... 63 64 E => CORE::exp(1), 65 }; 66