Math Class Reference

Class providing access to various standard math functions. More...

List of all members.

Trigonometric Functions

float cos (float x)
 Compute cosine.
float sin (float x)
 Compute sine.
float tan (float x)
 Compute tangent.
float acos (float x)
 Compute arc cosine.
float asin (float x)
 Compute arc sine.
float atan (float x)
 Compute arc tangent.
float atan2 (float y, float x)
 Compute arc tangent with two parameters.

Hyperbolic Functions

float cosh (float x)
 Compute hyperbolic cosine.
float sinh (float x)
 Compute hyperbolic sine.
float tanh (float x)
 Compute hyperbolic tangent.

Exponential and Logarithmic Functions

float exp (float x)
 Compute exponential function.
float log (float x)
 Compute natural logarithm.

Power Functions

float sqrt (float x)
 Compute square root.

Rounding, Absolute Value and Remainder Functions

float abs (float x)
 Compute absolute value.
float ceil (float x)
 Round up value.
float floor (float x)
 Round down value.
float fmod (float numerator, float denominator)
 Compute remainder of division.

Random Number Functions

int rand ()
 Generate random number.
int rand (int lower, int upper)
 Generate random number.

Conversion Functions

float deg2rad (float x)
 Convert value from degrees to the radian equivalent.
float rad2deg (float x)
 Convert value from radians to the equivalent value in degrees.

Detailed Description

Class providing access to various standard math functions.

This is mainly an indirection to the standard C math functions.


Member Function Documentation

float Math::cos ( float  x)

Compute cosine.

Returns the cosine of an angle of x radians.

Parameters:
xFloating point value representing an angle expressed in radians.
Returns:
Cosine of x.
float Math::sin ( float  x)

Compute sine.

Returns the sine of an angle of x radians.

Parameters:
xFloating point value representing an angle expressed in radians.
Returns:
Sine of x.
float Math::tan ( float  x)

Compute tangent.

Returns the tangent of an angle of x radians.

Parameters:
xFloating point value representing an angle expressed in radians.
Returns:
Tangent of x.
float Math::acos ( float  x)

Compute arc cosine.

Returns the principal value of the arc cosine of x, expressed in radians. In trigonometrics, arc cosine is the inverse operation of cosine.

Parameters:
xFloating point value in the interval [-1,+1].
Returns:
Principal arc cosine of x, in the interval [0,pi] radians.
float Math::asin ( float  x)

Compute arc sine.

Returns the principal value of the arc sine of x, expressed in radians. In trigonometrics, arc sine is the inverse operation of sine.

Parameters:
xFloating point value in the interval [-1,+1].
Returns:
Arc sine of x, in the interval [-pi/2,+pi/2] radians.
float Math::atan ( float  x)

Compute arc tangent.

Returns the principal value of the arc tangent of x, expressed in radians. In trigonometrics, arc tangent is the inverse operation of tangent. Notice that because of the sign ambiguity, a function cannot determine with certainty in which quadrant the angle falls only by its tangent value. You can use atan2() if you need to determine the quadrant.

Parameters:
xFloating point value.
Returns:
Principal arc tangent of x, in the interval [-pi/2,+pi/2] radians.
float Math::atan2 ( float  y,
float  x 
)

Compute arc tangent with two parameters.

Returns the principal value of the arc tangent of y/x, expressed in radians. To compute the value, the function uses the sign of both arguments to determine the quadrant.

Parameters:
yFloating point value representing an y-coordinate.
xFloating point value representing an x-coordinate.
Returns:
Principal arc tangent of y/x, in the interval [-pi,+pi] radians.
float Math::cosh ( float  x)

Compute hyperbolic cosine.

Returns the hyperbolic cosine of x.

Parameters:
xFloating point value.
Returns:
Hyperbolic cosine of x.
float Math::sinh ( float  x)

Compute hyperbolic sine.

Returns the hyperbolic sine of x.

Parameters:
xFloating point value.
Returns:
Hyperbolic sine of x.
float Math::tanh ( float  x)

Compute hyperbolic tangent.

Returns the hyperbolic tangent of x.

Parameters:
xFloating point value.
Returns:
Hyperbolic tangent of x.
float Math::exp ( float  x)

Compute exponential function.

Returns the base-e exponential function of x, which is the e number raised to the power x.

Parameters:
xFloating point value.
Returns:
Exponential value of x.
float Math::log ( float  x)

Compute natural logarithm.

Returns the natural logarithm of x. The natural logarithm is the base-e logarithm, the inverse of the natural exponential function (exp()).

Parameters:
xFloating point value.
Returns:
Natural logarithm of x.
float Math::sqrt ( float  x)

Compute square root.

Returns the square root of x.

Parameters:
xFloating point value.
Returns:
Square root of x.
float Math::abs ( float  x)

Compute absolute value.

Returns the absolute value of x (|x|)

Parameters:
xFloating point value.
Returns:
The absolute value of x.
float Math::ceil ( float  x)

Round up value.

Returns the smallest integral value that is not less than x.

Parameters:
xFloating point value.
Returns:
The smallest integral value not less than x.
float Math::floor ( float  x)

Round down value.

Returns the largest integral value that is not greater than x.

Parameters:
xFloating point value.
Returns:
The largest integral value not greater than x.
float Math::fmod ( float  numerator,
float  denominator 
)

Compute remainder of division.

Returns the floating-point remainder of numerator/denominator. The remainder of a division operation is the result of subtracting the integral quotient multiplied by the denominator from the numerator:

remainder = numerator - quotient * denominator

Parameters:
numeratorFloating point value with the division numerator.
denominatorFloating point value with the division denominator.
Returns:
The remainder of dividing the arguments.
int Math::rand ( )

Generate random number.

Returns a pseudo-random integral number in the range 0 to RAND_MAX. RAND_MAX is a constant defined internally. Its default value may vary between implementations but it is granted to be at least 32767.

Returns:
An integer value between 0 and RAND_MAX.
int Math::rand ( int  lower,
int  upper 
)

Generate random number.

Returns a pseudo-random integral number in the range lower to upper.

Parameters:
lowerLower bound ofrange.
upperUpper bound of range.
Returns:
An integer value between lower and upper.
float Math::deg2rad ( float  x)

Convert value from degrees to the radian equivalent.

Parameters:
xFloating point value representing an angle expressed in degrees.
Returns:
x converted to radians.
float Math::rad2deg ( float  x)

Convert value from radians to the equivalent value in degrees.

Parameters:
xFloating point value representing an angle expressed in radians.
Returns:
x converted to degrees.