- Generic Math Functions | Qt Core 6.7.2 (2024)

Function Documentation

template <typename T> auto qAcos(T v)

Returns the arccosine of v as an angle in radians. Arccosine is the inverse operation of cosine.

See also qAtan(), qAsin(), and qCos().

template <typename T> auto qAsin(T v)

Returns the arcsine of v as an angle in radians. Arcsine is the inverse operation of sine.

See also qSin(), qAtan(), and qAcos().

template <typename T1, typename T2> auto qAtan2(T1 y, T2 x)

Returns the arctangent of a point specified by the coordinates y and x. This function will return the angle (argument) of that point.

See also qAtan() and qHypot().

template <typename T> auto qAtan(T v)

Returns the arctangent of v as an angle in radians. Arctangent is the inverse operation of tangent.

See also qTan(), qAcos(), and qAsin().

template <typename T> int qCeil(T v)

Returns 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.

See also qFloor().

template <typename T> auto qCos(T v)

Returns the cosine of an angle v in radians.

See also qSin() and qTan().

[constexpr] float qDegreesToRadians(float degrees)

This function converts the degrees in float to radians.

Example:

float degrees = 180.0ffloat radians = qDegreesToRadians(degrees)

See also qRadiansToDegrees().

[constexpr] double qDegreesToRadians(double degrees)

This function converts the degrees in double to radians.

Example:

double degrees = 180.0double radians = qDegreesToRadians(degrees)

See also qRadiansToDegrees().

[constexpr, since 6.0] long double qDegreesToRadians(long double degrees)

This function converts the degrees in double to radians.

This function was introduced in Qt 6.0.

See also qRadiansToDegrees().

template <typename T> auto qExp(T v)

Returns the exponential function of e to the power of v.

See also qLn().

template <typename T> auto qFabs(T v)

Returns the absolute value of v.

template <typename T> int qFloor(T v)

Returns 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.

See also qCeil().

[since 6.1] template <typename Tx, typename Ty> auto qHypot(Tx x, Ty y)

This is an overloaded function.

Returns the distance of a point (x, y) from the origin (0, 0).

This is qSqrt(x * x + y * y), optimized. In particular, underflow and overflow may be avoided.

Accepts any mix of numeric types, returning the same floating-point type as std::hypot(). If either parameter is infinite, so is the result; otherwise, if either is a NaN, so is the result.

This function was introduced in Qt 6.1.

See also qSqrt() and qAtan2().

[since 6.1] template <typename Tx, typename Ty, typename Tz> auto qHypot(Tx x, Ty y, Tz z)

This is an overloaded function.

Returns the distance of a point (x, y, z) from the origin (0, 0, 0).

This is qSqrt(x * x + y * y + z * z), optimized where supported. In particular, underflow and overflow may be avoided.

Accepts any mix of numeric types, returning the same floating-point type as std::hypot(). If any parameter is infinite, so is the result; otherwise, if any is NaN, so is the result.

This function was introduced in Qt 6.1.

See also qSqrt().

[since 6.1] template <typename F, typename... Fs> auto qHypot(F first, Fs... rest)

Returns the distance from origin in arbitrarily many dimensions

This is as for the two-argument and three-argument forms, supported by std::hypot(), but with as many numeric parameters as you care to pass to it. Uses first and each of the rest as coordinates, performing a calculation equivalent to squaring each, summing and returning the square root, save that underflow and overflow are avoided as far as possible.

This function was introduced in Qt 6.1.

See also qSqrt().

template <typename T> auto qLn(T v)

Returns the natural logarithm of v. Natural logarithm uses base e.

See also qExp().

[constexpr] quint32 qNextPowerOfTwo(quint32 value)

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 the result is undefined.

[constexpr] quint32 qNextPowerOfTwo(qint32 value)

This is an overloaded function.

This function returns the nearest power of two greater than value. For negative values the result is undefined.

[constexpr] quint64 qNextPowerOfTwo(quint64 value)

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 the result is undefined.

[constexpr] quint64 qNextPowerOfTwo(qint64 value)

This is an overloaded function.

This function returns the nearest power of two greater than value. For negative values the result is undefined.

template <typename T1, typename T2> auto qPow(T1 x, T2 y)

Returns the value of x raised to the power of y. That is, x is the base and y is the exponent.

See also qSqrt().

[constexpr] float qRadiansToDegrees(float radians)

This function converts the radians in float to degrees.

Example:

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

See also qDegreesToRadians().

[constexpr] double qRadiansToDegrees(double radians)

This function converts the radians in double to degrees.

Example:

double radians = M_PIdouble degrees = qRadiansToDegrees(radians)

See also qDegreesToRadians().

[constexpr, since 6.0] long double qRadiansToDegrees(long double radians)

This function converts the radians in double to degrees.

This function was introduced in Qt 6.0.

See also qDegreesToRadians().

template <typename T> auto qSin(T v)

Returns the sine of the angle v in radians.

See also qCos() and qTan().

template <typename T> auto qSqrt(T v)

Returns the square root of v. This function returns a NaN if v is a negative number.

See also qPow() and qHypot().

template <typename T> auto qTan(T v)

Returns the tangent of an angle v in radians.

See also qSin() and qCos().

- Generic Math Functions | Qt Core 6.7.2 (2024)
Top Articles
Latest Posts
Article information

Author: Rueben Jacobs

Last Updated:

Views: 6590

Rating: 4.7 / 5 (57 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Rueben Jacobs

Birthday: 1999-03-14

Address: 951 Caterina Walk, Schambergerside, CA 67667-0896

Phone: +6881806848632

Job: Internal Education Planner

Hobby: Candle making, Cabaret, Poi, Gambling, Rock climbing, Wood carving, Computer programming

Introduction: My name is Rueben Jacobs, I am a cooperative, beautiful, kind, comfortable, glamorous, open, magnificent person who loves writing and wants to share my knowledge and understanding with you.