- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

Defines | Functions | Variables

# qmath.h File Reference

`#include <math.h>`
`#include <QtCore/qglobal.h>`

Go to the source code of this file.

## Defines
#define | QT_SINE_TABLE_SIZE 256
#define | M_PI (3.14159265358979323846)
## Functions
int | qCeil (qreal v)
int | qFloor (qreal v)
qreal | qFabs (qreal v)
qreal | qSin (qreal v)
qreal | qCos (qreal v)
qreal | qTan (qreal v)
qreal | qAcos (qreal v)
qreal | qAsin (qreal v)
qreal | qAtan (qreal v)
qreal | qAtan2 (qreal x, qreal y)
qreal | qSqrt (qreal v)
qreal | qLn (qreal v)
qreal | qExp (qreal v)
qreal | qPow (qreal x, qreal y)
qreal | qFastSin (qreal x)
qreal | qFastCos (qreal x)
## Variables
Q_CORE_EXPORT const qreal | qt_sine_table [QT_SINE_TABLE_SIZE]

## Define Documentation

#define QT_SINE_TABLE_SIZE 256

Search for all occurrences

Definition at line 59 of file qmath.h.

#define M_PI (3.14159265358979323846)

Search for all occurrences

Definition at line 261 of file qmath.h.

## Function Documentation

int qCeil | ( | qreal | v | ) | `[inline]`

Search for all occurrences

Definition at line 63 of file qmath.h.

    {
    #ifdef QT_USE_MATH_H_FLOATS
        if (sizeof(qreal) == sizeof(float))
            return int(ceilf(float(v)));
        else
    #endif
            return int(ceil(v));
    }

int qFloor | ( | qreal | v | ) | `[inline]`

Search for all occurrences

Definition at line 73 of file qmath.h.

    {
    #ifdef QT_USE_MATH_H_FLOATS
        if (sizeof(qreal) == sizeof(float))
            return int(floorf(float(v)));
        else
    #endif
            return int(floor(v));
    }

qreal qFabs | ( | qreal | v | ) | `[inline]`

Search for all occurrences

Definition at line 83 of file qmath.h.

    {
    #ifdef QT_USE_MATH_H_FLOATS
        if(sizeof(qreal) == sizeof(float))
            return fabsf(float(v));
        else
    #endif
            return fabs(v);
    }

qreal qSin | ( | qreal | v | ) | `[inline]`

Search for all occurrences

Definition at line 93 of file qmath.h.

    {
    #ifdef Q_OS_SYMBIAN
        TReal sin_v;
        Math::Sin(sin_v, static_cast<TReal>(v));
        return static_cast<qreal>(sin_v);
    #else
    #    ifdef QT_USE_MATH_H_FLOATS
            if (sizeof(qreal) == sizeof(float))
                return sinf(float(v));
            else
    #    endif
                return sin(v);
    #endif
    }

qreal qCos | ( | qreal | v | ) | `[inline]`

Search for all occurrences

Definition at line 109 of file qmath.h.

    {
    #ifdef Q_OS_SYMBIAN
        TReal cos_v;
        Math::Cos(cos_v, static_cast<TReal>(v));
        return static_cast<qreal>(cos_v);
    #else
    #    ifdef QT_USE_MATH_H_FLOATS
            if (sizeof(qreal) == sizeof(float))
                return cosf(float(v));
            else
    #    endif
                return cos(v);
    #endif
    }

qreal qTan | ( | qreal | v | ) | `[inline]`

Search for all occurrences

Definition at line 125 of file qmath.h.

    {
    #ifdef Q_OS_SYMBIAN
        TReal tan_v;
        Math::Tan(tan_v, static_cast<TReal>(v));
        return static_cast<qreal>(tan_v);
    #else
    #    ifdef QT_USE_MATH_H_FLOATS
            if (sizeof(qreal) == sizeof(float))
                return tanf(float(v));
            else
    #    endif
                return tan(v);
    #endif
    }

qreal qAcos | ( | qreal | v | ) | `[inline]`

Search for all occurrences

Definition at line 141 of file qmath.h.

    {
    #ifdef Q_OS_SYMBIAN
        TReal acos_v;
        Math::ACos(acos_v, static_cast<TReal>(v));
        return static_cast<qreal>(acos_v);
    #else
    #    ifdef QT_USE_MATH_H_FLOATS
            if (sizeof(qreal) == sizeof(float))
                return acosf(float(v));
            else
    #    endif
               return acos(v);
    #endif
    }

qreal qAsin | ( | qreal | v | ) | `[inline]`

Search for all occurrences

Definition at line 157 of file qmath.h.

    {
    #ifdef Q_OS_SYMBIAN
        TReal asin_v;
        Math::ASin(asin_v, static_cast<TReal>(v));
        return static_cast<qreal>(asin_v);
    #else
    #    ifdef QT_USE_MATH_H_FLOATS
            if (sizeof(qreal) == sizeof(float))
                return asinf(float(v));
            else
    #    endif
                return asin(v);
    #endif
    }

qreal qAtan | ( | qreal | v | ) | `[inline]`

Search for all occurrences

Definition at line 173 of file qmath.h.

    {
    #ifdef Q_OS_SYMBIAN
        TReal atan_v;
        Math::ATan(atan_v, static_cast<TReal>(v));
        return static_cast<qreal>(atan_v);
    #else
    #    ifdef QT_USE_MATH_H_FLOATS
            if(sizeof(qreal) == sizeof(float))
                return atanf(float(v));
            else
    #    endif
                return atan(v);
    #endif
    }

qreal qAtan2 | ( | qreal | x,
|  | qreal | y
| ) |  | `[inline]`

Search for all occurrences

Definition at line 189 of file qmath.h.

    {
    #ifdef Q_OS_SYMBIAN
        TReal atan2_v;
        Math::ATan(atan2_v, static_cast<TReal>(x), static_cast<TReal>(y));
        return static_cast<qreal>(atan2_v);
    #else
    #    ifdef QT_USE_MATH_H_FLOATS
            if(sizeof(qreal) == sizeof(float))
                return atan2f(float(x), float(y));
            else
    #    endif
                return atan2(x, y);
    #endif
    }

qreal qSqrt | ( | qreal | v | ) | `[inline]`

Search for all occurrences

Definition at line 205 of file qmath.h.

    {
    #ifdef Q_OS_SYMBIAN
        TReal sqrt_v;
        Math::Sqrt(sqrt_v, static_cast<TReal>(v));
        return static_cast<qreal>(sqrt_v);
    #else
    #    ifdef QT_USE_MATH_H_FLOATS
            if (sizeof(qreal) == sizeof(float))
                return sqrtf(float(v));
            else
    #    endif
                return sqrt(v);
    #endif
    }

qreal qLn | ( | qreal | v | ) | `[inline]`

Search for all occurrences

Definition at line 221 of file qmath.h.

    {
    #ifdef QT_USE_MATH_H_FLOATS
        if (sizeof(qreal) == sizeof(float))
            return logf(float(v));
        else
    #endif
            return log(v);
    }

qreal qExp | ( | qreal | v | ) | `[inline]`

Search for all occurrences

Definition at line 231 of file qmath.h.

    {
    #ifdef Q_OS_SYMBIAN
        TReal exp_v;
        Math::Exp(exp_v, static_cast<TReal>(v));
        return static_cast<qreal>(exp_v);
    #else
        // only one signature
        // exists, exp(double)
        return exp(v);
    #endif
    }

qreal qPow | ( | qreal | x,
|  | qreal | y
| ) |  | `[inline]`

Search for all occurrences

Definition at line 244 of file qmath.h.

    {
    #ifdef Q_OS_SYMBIAN
        TReal pow_v;
        Math::Pow(pow_v, static_cast<TReal>(x), static_cast<TReal>(y));
        return static_cast<qreal>(pow_v);
    #else
    #    ifdef QT_USE_MATH_H_FLOATS
            if (sizeof(qreal) == sizeof(float))
                return powf(float(x), float(y));
            else
    #    endif
                return pow(x, y);
    #endif
    }

qreal qFastSin | ( | qreal | x | ) | `[inline]`

Search for all occurrences

Definition at line 264 of file qmath.h.

    {
        int si = int(x * (0.5 * QT_SINE_TABLE_SIZE / M_PI)); // Would be more accurate with qRound, but slower.
        qreal d = x - si * (2.0 * M_PI / QT_SINE_TABLE_SIZE);
        int ci = si + QT_SINE_TABLE_SIZE / 4;
        si &= QT_SINE_TABLE_SIZE - 1;
        ci &= QT_SINE_TABLE_SIZE - 1;
        return qt_sine_table[si] + (qt_sine_table[ci] - 0.5 * qt_sine_table[si] * d) * d;
    }

qreal qFastCos | ( | qreal | x | ) | `[inline]`

Search for all occurrences

Definition at line 274 of file qmath.h.

    {
        int ci = int(x * (0.5 * QT_SINE_TABLE_SIZE / M_PI)); // Would be more accurate with qRound, but slower.
        qreal d = x - ci * (2.0 * M_PI / QT_SINE_TABLE_SIZE);
        int si = ci + QT_SINE_TABLE_SIZE / 4;
        si &= QT_SINE_TABLE_SIZE - 1;
        ci &= QT_SINE_TABLE_SIZE - 1;
        return qt_sine_table[si] - (qt_sine_table[ci] + 0.5 * qt_sine_table[si] * d) * d;
    }

## Variable Documentation

Q_CORE_EXPORT const qreal qt_sine_table[QT_SINE_TABLE_SIZE]

Search for all occurrences