00001 /* LICENSE_BEGIN 00002 SutoiTools library supply support for debugging, testing and 00003 setting good bases for you application. It is part of the 00004 SugoiEngine project. 00005 Copyright (C) 2006 Allusse Yannick (yannick dot allusse at laposte dot net) 00006 00007 00008 This program is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU General Public License 00010 as published by the Free Software Foundation; either version 2 00011 of the License, or (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program; if not, write to the Free Software 00020 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00021 LICENSE_END 00022 */ 00023 00024 /* \file math.h 00025 * \brief Some basic function to help about mathematic operation. 00026 * \author Yannick Allusse 00027 */ 00028 #ifndef SG_TLS_MATH_H 00029 #define SG_TLS_MATH_H 00030 00031 00032 #include "SugoiTools\config.h" 00033 00034 namespace SGE{ 00035 00040 template <typename Type> 00041 const Type & Min(const Type &_val1, const Type &_val2) 00042 { 00043 if(_val1<_val2) 00044 return _val1; 00045 return _val2; 00046 } 00047 00052 template <typename Type> 00053 const Type & Max(const Type &_val1, const Type &_val2) 00054 { 00055 if(_val1>_val2) 00056 return _val1; 00057 return _val2; 00058 } 00059 00063 template <typename Type> 00064 Type vAbs(Type _val) 00065 { 00066 return (_val < 0)?-_val:_val; 00067 } 00068 00069 };//namespace SGE 00070 00071 #endif