QtCore/qmath.h File Reference

qmath.h File Reference
#include <math.h>
#include <QtCore/qglobal.h>

Macros

#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]
 

Macro Definition Documentation

#define QT_SINE_TABLE_SIZE   256

Definition at line 59 of file qmath.h.

#define M_PI   (3.14159265358979323846)

Definition at line 261 of file qmath.h.

Function Documentation

int qCeil ( qreal  v)
inline

Definition at line 63 of file qmath.h.

64 {
65 #ifdef QT_USE_MATH_H_FLOATS
66  if (sizeof(qreal) == sizeof(float))
67  return int(ceilf(float(v)));
68  else
69 #endif
70  return int(ceil(v));
71 }
unsigned int(APIENTRYP PFNGLXGETAGPOFFSETMESAPROC)(const void *pointer)
Definition: GLee.h:10762
const GLdouble * v
Definition: GLee.h:1174
int qFloor ( qreal  v)
inline

Definition at line 73 of file qmath.h.

74 {
75 #ifdef QT_USE_MATH_H_FLOATS
76  if (sizeof(qreal) == sizeof(float))
77  return int(floorf(float(v)));
78  else
79 #endif
80  return int(floor(v));
81 }
unsigned int(APIENTRYP PFNGLXGETAGPOFFSETMESAPROC)(const void *pointer)
Definition: GLee.h:10762
const GLdouble * v
Definition: GLee.h:1174
qreal qFabs ( qreal  v)
inline

Definition at line 83 of file qmath.h.

84 {
85 #ifdef QT_USE_MATH_H_FLOATS
86  if(sizeof(qreal) == sizeof(float))
87  return fabsf(float(v));
88  else
89 #endif
90  return fabs(v);
91 }
const GLdouble * v
Definition: GLee.h:1174
qreal qSin ( qreal  v)
inline

Definition at line 93 of file qmath.h.

94 {
95 #ifdef Q_OS_SYMBIAN
96  TReal sin_v;
97  Math::Sin(sin_v, static_cast<TReal>(v));
98  return static_cast<qreal>(sin_v);
99 #else
100 # ifdef QT_USE_MATH_H_FLOATS
101  if (sizeof(qreal) == sizeof(float))
102  return sinf(float(v));
103  else
104 # endif
105  return sin(v);
106 #endif
107 }
const GLdouble * v
Definition: GLee.h:1174
qreal qCos ( qreal  v)
inline

Definition at line 109 of file qmath.h.

110 {
111 #ifdef Q_OS_SYMBIAN
112  TReal cos_v;
113  Math::Cos(cos_v, static_cast<TReal>(v));
114  return static_cast<qreal>(cos_v);
115 #else
116 # ifdef QT_USE_MATH_H_FLOATS
117  if (sizeof(qreal) == sizeof(float))
118  return cosf(float(v));
119  else
120 # endif
121  return cos(v);
122 #endif
123 }
const GLdouble * v
Definition: GLee.h:1174
qreal qTan ( qreal  v)
inline

Definition at line 125 of file qmath.h.

126 {
127 #ifdef Q_OS_SYMBIAN
128  TReal tan_v;
129  Math::Tan(tan_v, static_cast<TReal>(v));
130  return static_cast<qreal>(tan_v);
131 #else
132 # ifdef QT_USE_MATH_H_FLOATS
133  if (sizeof(qreal) == sizeof(float))
134  return tanf(float(v));
135  else
136 # endif
137  return tan(v);
138 #endif
139 }
const GLdouble * v
Definition: GLee.h:1174
qreal qAcos ( qreal  v)
inline

Definition at line 141 of file qmath.h.

142 {
143 #ifdef Q_OS_SYMBIAN
144  TReal acos_v;
145  Math::ACos(acos_v, static_cast<TReal>(v));
146  return static_cast<qreal>(acos_v);
147 #else
148 # ifdef QT_USE_MATH_H_FLOATS
149  if (sizeof(qreal) == sizeof(float))
150  return acosf(float(v));
151  else
152 # endif
153  return acos(v);
154 #endif
155 }
const GLdouble * v
Definition: GLee.h:1174
qreal qAsin ( qreal  v)
inline

Definition at line 157 of file qmath.h.

158 {
159 #ifdef Q_OS_SYMBIAN
160  TReal asin_v;
161  Math::ASin(asin_v, static_cast<TReal>(v));
162  return static_cast<qreal>(asin_v);
163 #else
164 # ifdef QT_USE_MATH_H_FLOATS
165  if (sizeof(qreal) == sizeof(float))
166  return asinf(float(v));
167  else
168 # endif
169  return asin(v);
170 #endif
171 }
const GLdouble * v
Definition: GLee.h:1174
qreal qAtan ( qreal  v)
inline

Definition at line 173 of file qmath.h.

174 {
175 #ifdef Q_OS_SYMBIAN
176  TReal atan_v;
177  Math::ATan(atan_v, static_cast<TReal>(v));
178  return static_cast<qreal>(atan_v);
179 #else
180 # ifdef QT_USE_MATH_H_FLOATS
181  if(sizeof(qreal) == sizeof(float))
182  return atanf(float(v));
183  else
184 # endif
185  return atan(v);
186 #endif
187 }
const GLdouble * v
Definition: GLee.h:1174
qreal qAtan2 ( qreal  x,
qreal  y 
)
inline

Definition at line 189 of file qmath.h.

190 {
191 #ifdef Q_OS_SYMBIAN
192  TReal atan2_v;
193  Math::ATan(atan2_v, static_cast<TReal>(x), static_cast<TReal>(y));
194  return static_cast<qreal>(atan2_v);
195 #else
196 # ifdef QT_USE_MATH_H_FLOATS
197  if(sizeof(qreal) == sizeof(float))
198  return atan2f(float(x), float(y));
199  else
200 # endif
201  return atan2(x, y);
202 #endif
203 }
GLenum GLint GLint y
Definition: GLee.h:876
GLenum GLint x
Definition: GLee.h:876
qreal qSqrt ( qreal  v)
inline

Definition at line 205 of file qmath.h.

206 {
207 #ifdef Q_OS_SYMBIAN
208  TReal sqrt_v;
209  Math::Sqrt(sqrt_v, static_cast<TReal>(v));
210  return static_cast<qreal>(sqrt_v);
211 #else
212 # ifdef QT_USE_MATH_H_FLOATS
213  if (sizeof(qreal) == sizeof(float))
214  return sqrtf(float(v));
215  else
216 # endif
217  return sqrt(v);
218 #endif
219 }
const GLdouble * v
Definition: GLee.h:1174
qreal qLn ( qreal  v)
inline

Definition at line 221 of file qmath.h.

222 {
223 #ifdef QT_USE_MATH_H_FLOATS
224  if (sizeof(qreal) == sizeof(float))
225  return logf(float(v));
226  else
227 #endif
228  return log(v);
229 }
const GLdouble * v
Definition: GLee.h:1174
qreal qExp ( qreal  v)
inline

Definition at line 231 of file qmath.h.

232 {
233 #ifdef Q_OS_SYMBIAN
234  TReal exp_v;
235  Math::Exp(exp_v, static_cast<TReal>(v));
236  return static_cast<qreal>(exp_v);
237 #else
238  // only one signature
239  // exists, exp(double)
240  return exp(v);
241 #endif
242 }
const GLdouble * v
Definition: GLee.h:1174
qreal qPow ( qreal  x,
qreal  y 
)
inline

Definition at line 244 of file qmath.h.

245 {
246 #ifdef Q_OS_SYMBIAN
247  TReal pow_v;
248  Math::Pow(pow_v, static_cast<TReal>(x), static_cast<TReal>(y));
249  return static_cast<qreal>(pow_v);
250 #else
251 # ifdef QT_USE_MATH_H_FLOATS
252  if (sizeof(qreal) == sizeof(float))
253  return powf(float(x), float(y));
254  else
255 # endif
256  return pow(x, y);
257 #endif
258 }
GLenum GLint GLint y
Definition: GLee.h:876
GLenum GLint x
Definition: GLee.h:876
qreal qFastSin ( qreal  x)
inline

Definition at line 264 of file qmath.h.

265 {
266  int si = int(x * (0.5 * QT_SINE_TABLE_SIZE / M_PI)); // Would be more accurate with qRound, but slower.
267  qreal d = x - si * (2.0 * M_PI / QT_SINE_TABLE_SIZE);
268  int ci = si + QT_SINE_TABLE_SIZE / 4;
269  si &= QT_SINE_TABLE_SIZE - 1;
270  ci &= QT_SINE_TABLE_SIZE - 1;
271  return qt_sine_table[si] + (qt_sine_table[ci] - 0.5 * qt_sine_table[si] * d) * d;
272 }
unsigned int(APIENTRYP PFNGLXGETAGPOFFSETMESAPROC)(const void *pointer)
Definition: GLee.h:10762
#define M_PI
Definition: qmath.h:261
GLenum GLint x
Definition: GLee.h:876
#define QT_SINE_TABLE_SIZE
Definition: qmath.h:59
Q_CORE_EXPORT const qreal qt_sine_table[QT_SINE_TABLE_SIZE]
qreal qFastCos ( qreal  x)
inline

Definition at line 274 of file qmath.h.

275 {
276  int ci = int(x * (0.5 * QT_SINE_TABLE_SIZE / M_PI)); // Would be more accurate with qRound, but slower.
277  qreal d = x - ci * (2.0 * M_PI / QT_SINE_TABLE_SIZE);
278  int si = ci + QT_SINE_TABLE_SIZE / 4;
279  si &= QT_SINE_TABLE_SIZE - 1;
280  ci &= QT_SINE_TABLE_SIZE - 1;
281  return qt_sine_table[si] - (qt_sine_table[ci] + 0.5 * qt_sine_table[si] * d) * d;
282 }
unsigned int(APIENTRYP PFNGLXGETAGPOFFSETMESAPROC)(const void *pointer)
Definition: GLee.h:10762
#define M_PI
Definition: qmath.h:261
GLenum GLint x
Definition: GLee.h:876
#define QT_SINE_TABLE_SIZE
Definition: qmath.h:59
Q_CORE_EXPORT const qreal qt_sine_table[QT_SINE_TABLE_SIZE]

Variable Documentation

Q_CORE_EXPORT const qreal qt_sine_table[QT_SINE_TABLE_SIZE]

Go to the source code of this file.