Header Generic Math Functions

(<QtMath> - Generic Math Functions)

The <QtMath> header file provides various math functions. More...

Header: #include <>

Functions

float qDegreesToRadians(float degrees)
double qDegreesToRadians(double degrees)
float qRadiansToDegrees(float radians)
double qRadiansToDegrees(double radians)

Detailed Description

These functions are partly convenience definitions for basic math operations not available in the C or Standard Template Libraries.

The header also ensures some constants specified in POSIX, but not present in C++ standards (so absent from <math.h> on some platforms), are defined:

ConstantDescription
M_EThe base of the natural logarithms, e = exp(1)
M_LOG2EThe base-two logarithm of e
M_LOG10EThe base-ten logarithm of e
M_LN2The natural logarithm of two
M_LN10The natural logarithm of ten
M_PIThe ratio of a circle's circumference to diameter, π
M_PI_2Half M_PI, π / 2
M_PI_4Quarter M_PI, π / 4
M_1_PIThe inverse of M_PI, 1 / π
M_2_PITwice the inverse of M_PI, 2 / π
M_2_SQRTPITwo divided by the square root of pi, 2 / √π
M_SQRT2The square root of two, √2
M_SQRT1_2The square roof of half, 1 / √2

Function Documentation

float <QtMath>::qDegreesToRadians(float degrees)

This function converts the degrees in float to radians.

Example:


  float degrees = 180.0f
  float radians = qDegreesToRadians(degrees)

This function was introduced in Qt 5.1.

See also qRadiansToDegrees().

double <QtMath>::qDegreesToRadians(double degrees)

This function converts the degrees in double to radians.

Example:


  double degrees = 180.0
  double radians = qDegreesToRadians(degrees)

This function was introduced in Qt 5.1.

See also qRadiansToDegrees().

float <QtMath>::qRadiansToDegrees(float radians)

This function converts the radians in float to degrees.

Example:


  float radians = float(M_PI)
  float degrees = qRadiansToDegrees(radians)

This function was introduced in Qt 5.1.

See also qDegreesToRadians().

double <QtMath>::qRadiansToDegrees(double radians)

This function converts the radians in double to degrees.

Example:


  double radians = M_PI
  double degrees = qRadiansToDegrees(radians)

This function was introduced in Qt 5.1.

See also qDegreesToRadians().