📄 maths.h
字号:
// Maths.h: interface for the Maths class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_MATHS_H__282C0FB8_27DA_471A_B62D_2271B0DC873B__INCLUDED_)
#define AFX_MATH_H__282C0FB8_27DA_471A_B62D_2271B0DC873B__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <math.h>
#include <stdlib.h> // needed for rand
typedef double AngRad; /*!< Type definition for angles in degrees. */
typedef double AngDeg; /*!< Type definition for angles in radians. */
#define pi 3.14159265358979323846
#define INF 10000000000.0
#define EPS 0.000001 /*!< Value used for floating point equality tests. */
const double UnknownDoubleValue = -1000.0; /*!< indicates unknown double */
const int UnknownIntValue = -1000; /*!< indicates unknown int */
const int UnknownTime = -20; /*!< indicates unknown time */
const long UnknownMessageNr = -30; /*!< indicates unknown message nr*/
#define M_PI 3.1415926 /* Value of pi */
class Maths
{
public:
// auxiliary numeric functions for determining the
// maximum and minimum of two given double values and the Maths::Sign of a value
static double Max ( double d1, double d2 );
static double Min ( double d1, double d2 );
static int Sign ( double d1 );
// auxiliary goniometric functions which enable you to
// specify angles in degrees rather than in radians
static AngDeg Rad2Deg ( AngRad x );
static AngRad Deg2Rad ( AngDeg x );
static double cosDeg ( AngDeg x );
static double sinDeg ( AngDeg x );
static double tanDeg ( AngDeg x );
static AngDeg atanDeg ( double x );
static double atan2Deg( double x, double y );
static AngDeg acosDeg ( double x );
static AngDeg asinDeg ( double x );
#ifdef WIN32
/*! This function shall return the integral value (represented as a double)
nearest x in the direction of the current rounding mode. The current
rounding mode is implementation-defined.
If the current rounding mode rounds toward negative infinity, then Maths::rint()
shall be equivalent to floor() . If the current rounding mode rounds
toward positive infinity, then Maths::rint() shall be equivalent to ceil().
url: http://www.opengroup.org/onlinepubs/007904975/functions/Maths::rint.html */
static double rint(double x) { return floor(x); }
/*! The Maths::drand48() function shall return non-negative,
double-precision, floating-point values, uniformly distributed over the
interval [0.0,1.0).
url: http://www.opengroup.org/onlinepubs/007904975/functions/Maths::drand48.html */
static double drand48() { return ((double)(rand() % 100)) / 100; }
#endif
};
#endif // !defined(AFX_MATHS_H__282C0FB8_27DA_471A_B62D_2271B0DC873B__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -