summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qmath.qdoc
blob: a2e24e925bfebfcc5f342ace7be4d1ef0120eb85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
    \headerfile <QtMath>
    \title Generic Math Functions
    \ingroup funclists

    \brief The <QtMath> header file provides various math functions.

    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:

    \value M_E The base of the natural logarithms, e = exp(1)
    \value M_LOG2E The base-two logarithm of e
    \value M_LOG10E The base-ten logarithm of e
    \value M_LN2 The natural logarithm of two
    \value M_LN10 The natural logarithm of ten
    \value M_PI The ratio of a circle's circumference to diameter, \unicode{0x3C0}
    \value M_PI_2 Half M_PI, \unicode{0x3C0} / 2
    \value M_PI_4 Quarter M_PI, \unicode{0x3C0} / 4
    \value M_1_PI The inverse of M_PI, 1 / \unicode{0x3C0}
    \value M_2_PI Twice the inverse of M_PI, 2 / \unicode{0x3C0}
    \value M_2_SQRTPI Two divided by the square root of pi, 2 / \unicode{0x221A}\unicode{0x3C0}
    \value M_SQRT2 The square root of two, \unicode{0x221A}2
    \value M_SQRT1_2 The square roof of half, 1 / \unicode{0x221A}2

    \pagekeywords math trigonometry qmath floor ceiling absolute sine cosine tangent inverse tan exponent power natural logarithm pi
*/

/*!
    \fn int qCeil(qreal v)
    Return the ceiling of the value \a v.

    The ceiling is the smallest integer that is not less than \a v.
    For example, if \a v is 41.2, then the ceiling is 42.

    \relates <QtMath>
    \sa qFloor()
*/

/*!
    \fn int qFloor(qreal v)
    Return the floor of the value \a v.

    The floor is the largest integer that is not greater than \a v.
    For example, if \a v is 41.2, then the floor is 41.

    \relates <QtMath>
    \sa qCeil()
*/

/*!
    \fn qreal qFabs(qreal v)
    Returns the absolute value of \a v as a qreal.

    \relates <QtMath>
*/

/*!
    \fn qreal qSin(qreal v)
    Returns the sine of the angle \a v in radians.

    \relates <QtMath>
    \sa qCos(), qTan()
*/

/*!
    \fn  qreal qCos(qreal v)
    Returns the cosine of an angle \a v in radians.

    \relates <QtMath>
    \sa qSin(), qTan()
*/

/*!
    \fn qreal qTan(qreal v)
    Returns the tangent of an angle \a v in radians.

    \relates <QtMath>
    \sa qSin(), qCos()
*/

/*!
    \fn qreal qAcos(qreal v)
    Returns the arccosine of \a v as an angle in radians.
    Arccosine is the inverse operation of cosine.

    \relates <QtMath>
    \sa qAtan(), qAsin(), qCos()
*/

/*!
    \fn qreal qAsin(qreal v)
    Returns the arcsine of \a v as an angle in radians.
    Arcsine is the inverse operation of sine.

    \relates <QtMath>
    \sa qSin(), qAtan(), qAcos()
*/

/*!
    \fn qreal qAtan(qreal v)
    Returns the arctangent of \a v as an angle in radians.
    Arctangent is the inverse operation of tangent.

    \relates <QtMath>
    \sa qTan(), qAcos(), qAsin()
*/

/*!
    \fn qreal qAtan2(qreal y, qreal x)
    Returns the arctangent of a point specified by the coordinates \a y and \a x.
    This function will return the angle (argument) of that point.

    \relates <QtMath>
    \sa qAtan()
*/

/*!
    \fn qreal qSqrt(qreal v)
    Returns the square root of \a v.
    This function returns a NaN if \a v is a negative number.

    \relates <QtMath>
    \sa qPow()
*/

/*!
    \fn qreal qLn(qreal v)
    Returns the natural logarithm of \a v. Natural logarithm uses base e.

    \relates <QtMath>
    \sa qExp()
*/

/*!
    \fn qreal qExp(qreal v)
    Returns the exponential function of \c e to the power of \a v.

    \relates <QtMath>
    \sa qLn()
*/

/*!
    \fn qreal qPow(qreal x, qreal y)
    Returns the value of \a x raised to the power of \a y.
    That is, \a x is the base and \a y is the exponent.

    \relates <QtMath>
    \sa qSqrt()
*/

/*!
    \fn float qDegreesToRadians(float degrees)
    \relates <QtMath>
    \since 5.1

    This function converts the \a degrees in float to radians.

    Example:

    \snippet code/src_corelib_kernel_qmath.cpp 0

    \sa qRadiansToDegrees()
*/

/*!
    \fn double qDegreesToRadians(double degrees)
    \relates <QtMath>
    \since 5.1

    This function converts the \a degrees in double to radians.

    Example:

    \snippet code/src_corelib_kernel_qmath.cpp 1

    \sa qRadiansToDegrees()
*/

/*!
    \fn float qRadiansToDegrees(float radians)
    \relates <QtMath>
    \since 5.1

    This function converts the \a radians in float to degrees.

    Example:

    \snippet code/src_corelib_kernel_qmath.cpp 2

    \sa qDegreesToRadians()
*/

/*!
    \fn double qRadiansToDegrees(double radians)
    \relates <QtMath>
    \since 5.1

    This function converts the \a radians in double to degrees.

    Example:

    \snippet code/src_corelib_kernel_qmath.cpp 3

    \sa qDegreesToRadians()
*/

/*!
    \fn quint32 qNextPowerOfTwo(quint32 value)
    \relates <QtMath>
    \since 5.4

    This function returns the nearest power of two greater than \a value. For 0 it returns 1, and for values larger than or equal to 2^31 it returns 0.
*/

/*!
    \fn quint32 qNextPowerOfTwo(qint32 value)
    \relates <QtMath>
    \since 5.4
    \overload

    This function returns the nearest power of two greater than \a value. For negative values it returns 0.
*/

/*!
    \fn quint64 qNextPowerOfTwo(quint64 value)
    \relates <QtMath>
    \since 5.4

    This function returns the nearest power of two greater than \a value. For 0 it returns 1, and for values larger than or equal to 2^63 it returns 0.
*/

/*!
    \fn quint64 qNextPowerOfTwo(qint64 value)
    \relates <QtMath>
    \since 5.4
    \overload

    This function returns the nearest power of two greater than \a value. For negative values it returns 0.
*/