The <QtMath> header file provides various math functions. 更多...
头: | #include <QtMath> |
qreal | qAcos (qreal v ) |
qreal | qAsin (qreal v ) |
qreal | qAtan2 (qreal y , qreal x ) |
qreal | qAtan (qreal v ) |
int | qCeil (qreal v ) |
qreal | qCos (qreal v ) |
float | qDegreesToRadians (float degrees ) |
double | qDegreesToRadians (double degrees ) |
qreal | qExp (qreal v ) |
qreal | qFabs (qreal v ) |
int | qFloor (qreal v ) |
qreal | qLn (qreal v ) |
quint32 | qNextPowerOfTwo (quint32 value ) |
quint64 | qNextPowerOfTwo (quint64 value ) |
quint32 | qNextPowerOfTwo (qint32 value ) |
quint64 | qNextPowerOfTwo (qint64 value ) |
qreal | qPow (qreal x , qreal y ) |
float | qRadiansToDegrees (float radians ) |
double | qRadiansToDegrees (double radians ) |
qreal | qSin (qreal v ) |
qreal | qSqrt (qreal v ) |
qreal | qTan (qreal v ) |
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:
常量 | 描述 |
---|---|
M_E
|
The base of the natural logarithms, e = exp(1) |
M_LOG2E
|
The base-two logarithm of e |
M_LOG10E
|
The base-ten logarithm of e |
M_LN2
|
The natural logarithm of two |
M_LN10
|
The natural logarithm of ten |
M_PI
|
The ratio of a circle's circumference to diameter, π |
M_PI_2
|
Half M_PI, π / 2 |
M_PI_4
|
Quarter M_PI, π / 4 |
M_1_PI
|
The inverse of M_PI, 1 / π |
M_2_PI
|
Twice the inverse of M_PI, 2 / π |
M_2_SQRTPI
|
Two divided by the square root of pi, 2 / √π |
M_SQRT2
|
The square root of two, √2 |
M_SQRT1_2
|
The square roof of half, 1 / √2 |
Returns the arccosine of v as an angle in radians. Arccosine is the inverse operation of cosine.
另请参阅 qAtan (), qAsin (),和 qCos ().
Returns the arcsine of v as an angle in radians. Arcsine is the inverse operation of sine.
另请参阅 qSin (), qAtan (),和 qAcos ().
Returns the arctangent of a point specified by the coordinates y and x . This function will return the angle (argument) of that point.
另请参阅 qAtan ().
Returns the arctangent of v as an angle in radians. Arctangent is the inverse operation of tangent.
另请参阅 qTan (), qAcos (),和 qAsin ().
Return the ceiling of the value v .
The ceiling is the smallest integer that is not less than v . For example, if v is 41.2, then the ceiling is 42.
另请参阅 qFloor ().
Returns the cosine of an angle v in radians.
This function converts the degrees in float to radians.
范例:
float degrees = 180.0f float radians = qDegreesToRadians(degrees)
该函数在 Qt 5.1 引入。
另请参阅 qRadiansToDegrees ().
This function converts the degrees in double to radians.
范例:
double degrees = 180.0 double radians = qDegreesToRadians(degrees)
该函数在 Qt 5.1 引入。
另请参阅 qRadiansToDegrees ().
Returns the exponential function of
e
to the power of
v
.
另请参阅 qLn ().
Returns the absolute value of v as a qreal.
Return the floor of the value v .
The floor is the largest integer that is not greater than v . For example, if v is 41.2, then the floor is 41.
另请参阅 qCeil ().
Returns the natural logarithm of v . Natural logarithm uses base e.
另请参阅 qExp ().
This function returns the nearest power of two greater than value . For 0 it returns 1, and for values larger than or equal to 2^31 it returns 0.
该函数在 Qt 5.4 引入。
This function returns the nearest power of two greater than value . For 0 it returns 1, and for values larger than or equal to 2^63 it returns 0.
该函数在 Qt 5.4 引入。
这是重载函数。
This function returns the nearest power of two greater than value . For negative values it returns 0.
该函数在 Qt 5.4 引入。
这是重载函数。
This function returns the nearest power of two greater than value . For negative values it returns 0.
该函数在 Qt 5.4 引入。
返回值为 x raised to the power of y . That is, x is the base and y is the exponent.
另请参阅 qSqrt ().
This function converts the radians in float to degrees.
范例:
float radians = float(M_PI) float degrees = qRadiansToDegrees(radians)
该函数在 Qt 5.1 引入。
另请参阅 qDegreesToRadians ().
This function converts the radians in double to degrees.
范例:
double radians = M_PI double degrees = qRadiansToDegrees(radians)
该函数在 Qt 5.1 引入。
另请参阅 qDegreesToRadians ().
Returns the sine of the angle v in radians.
Returns the square root of v . This function returns a NaN if v is a negative number.
另请参阅 qPow ().
Returns the tangent of an angle v in radians.