// $Source: /usr/local/SimSoft/SoftShop/XMath/Angle/MathDefs.h,v $
// $Revision: 1.17 $
// $Author: baum $
// $Date: 2001/11/29 15:52:25 $
//
// Login name of the user who locked the revision
// $Locker:  $
// Tag name used to checkout the file
// $Name: Release-20 $
// State assigned to revision
// $State: Exp $
//
//
// $Log: MathDefs.h,v $
// Revision 1.17  2001/11/29 15:52:25  baum
// -In Kalender.cpp und Kalender.h Handsteuerung eingebaut
//

#ifndef _MATHDEFS_H
#define _MATHDEFS_H

#include <math.h>

#define S_E         2.71828182845904523536   // Euler

#define S_PI        3.14159265358979323846   // PI
#define S_PI_2      1.57079632679489661923   // PI/2
#define S_PI_4      0.785398163397448309616  // PI/4
#define S_1_PI      0.318309886183790671538  // 1/PI
#define S_2_PI      0.636619772367581343076  // 2/PI

template <class T>
inline const T& Min (const T& a, const T& b) {
  return ((a < b) ? a : b);
}

template <class T>
inline const T& Max (const T& a, const T& b) {
  return ((a > b) ? a : b);
}

// return val forced into the specified range (between lo and hi)
template <class T>
inline T limitToRange (const T& val, const T& lo, const T& hi) {
  return (val < lo) ? lo : (val > hi) ? hi : val;
}

template <class T>
inline void Swap (T& a, T& b) {
  T tmp = a;
  a = b;
  b = tmp;
}

inline double Sqr (const double& a) {
  return ((a) * (a));
}

inline double Hypot (const double& a, const double& b) {
  return (a || b ? sqrt (Sqr(a) + Sqr(b)) : 0.0);
}

inline double Round (const double& a) {
  return ((a < 0.0 ) ? ceil (a - 0.5) : floor (a + 0.5));
}

inline int Sign (const double& a) {
  return ((a < 0.0) ? -1 : 1);
}

#endif	// ifndef _MATHDEFS_H

