Qt 4.8
Macros | Functions | Variables
qmath.h File Reference
#include <math.h>
#include <QtCore/qglobal.h>

Go to the source code of this file.

Macros

#define M_PI   (3.14159265358979323846)
 
#define QT_SINE_TABLE_SIZE   256
 

Functions

qreal qAcos (qreal v)
 
qreal qAsin (qreal v)
 
qreal qAtan (qreal v)
 
qreal qAtan2 (qreal x, qreal y)
 
int qCeil (qreal v)
 
qreal qCos (qreal v)
 
qreal qExp (qreal v)
 
qreal qFabs (qreal v)
 
qreal qFastCos (qreal x)
 
qreal qFastSin (qreal x)
 
int qFloor (qreal v)
 
qreal qLn (qreal v)
 
qreal qPow (qreal x, qreal y)
 
qreal qSin (qreal v)
 
qreal qSqrt (qreal v)
 
qreal qTan (qreal v)
 

Variables

Q_CORE_EXPORT const qreal qt_sine_table [QT_SINE_TABLE_SIZE]
 

Macro Definition Documentation

◆ M_PI

#define M_PI   (3.14159265358979323846)

◆ QT_SINE_TABLE_SIZE

#define QT_SINE_TABLE_SIZE   256

Definition at line 59 of file qmath.h.

Referenced by qFastCos(), and qFastSin().

Function Documentation

◆ qAcos()

qreal qAcos ( qreal  v)
inline

Definition at line 141 of file qmath.h.

Referenced by addCircle(), QLineF::angle(), and QQuaternion::slerp().

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 }
double qreal
Definition: qglobal.h:1193

◆ qAsin()

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 }
double qreal
Definition: qglobal.h:1193

◆ qAtan()

qreal qAtan ( qreal  v)
inline

Definition at line 173 of file qmath.h.

Referenced by QStyleHelper::angle().

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 }
double qreal
Definition: qglobal.h:1193

◆ qAtan2()

qreal qAtan2 ( qreal  x,
qreal  y 
)
inline

Definition at line 189 of file qmath.h.

Referenced by QLineF::angle(), computeAngle(), pathArc(), qt_fetch_conical_gradient(), and QDialPrivate::valueFromPoint().

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 }
double qreal
Definition: qglobal.h:1193

◆ qCeil()

int qCeil ( qreal  v)
inline

Definition at line 63 of file qmath.h.

Referenced by QFontEngine::alphaMapForGlyph(), alphaMapFromPath(), QSvgAnimateColor::apply(), QDeclarativePath::createPointCache(), QCommandLinkButtonPrivate::descriptionHeight(), QDeclarativePaintedItem::dirtyCache(), QDeclarativeFlow::doPositioning(), QPaintEngine::drawImage(), QRasterPaintEngine::drawImage(), drawTextItemDecoration(), QOpenGLPaintEngine::drawTiledPixmap(), QTextDocumentLayout::dynamicPageCount(), fetchTransformedBilinear(), QTimeLine::frameForTime(), QDeclarativeRectangle::generateRoundedRect(), generateWavyPixmap(), QRasterPaintEnginePrivate::getPenFunc(), intmaxlog(), QPrintPreviewWidgetPrivate::layoutPages(), QPaintBuffer::metric(), QDeclarativePaintedItem::paint(), pathArc(), QPdf::patternForBrush(), QGLPixmapBlurFilter::processGL(), qDrawBorderPixmap(), qSubImage(), qt_scale_image_16bit(), qt_scale_image_32bit(), qt_transform_image(), QMdi::RegularTiler::rearrange(), QComboBoxPrivate::recomputeSizeHint(), QMdiAreaPrivate::resizeToMinimumTileSize(), QSvgAnimateTransform::resolveMatrix(), QSvgPaintEngine::saveGradientStops(), QDeclarativeTextPrivate::setupTextLayout(), QLabelPrivate::sizeForWidth(), QMacStyle::subControlRect(), QCommonStyle::subElementRect(), QItemDelegate::textRectangle(), QRectF::toAlignedRect(), QDeclarativeListView::trackedPositionChanged(), QDeclarativeTextEdit::updateSize(), QCommonStylePrivate::viewItemSize(), and QPicturePaintEngine::writeCmdLength().

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 }
double qreal
Definition: qglobal.h:1193
#define ceil(x)

◆ qCos()

qreal qCos ( qreal  v)
inline

Definition at line 109 of file qmath.h.

Referenced by calcArrow(), QStyleHelper::calcLines(), QStyleHelper::calcRadialPos(), QQuaternion::fromAxisAndAngle(), QLineF::fromPolar(), pathArc(), pathArcSegment(), QMatrix4x4::perspective(), QMatrix4x4::projectedRotate(), qt_t_for_arc_angle(), QAccessibleDial::rect(), QMatrix::rotate(), QTransform::rotate(), QMatrix4x4::rotate(), QTransform::rotateRadians(), and QLineF::setAngle().

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 }
double qreal
Definition: qglobal.h:1193

◆ qExp()

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 }
double qreal
Definition: qglobal.h:1193

◆ qFabs()

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 }
double qreal
Definition: qglobal.h:1193

◆ qFastCos()

qreal qFastCos ( qreal  x)
inline

Definition at line 274 of file qmath.h.

Referenced by QGL2PaintEngineExPrivate::drawPixmapFragments(), and QTriangulatingStroker::process().

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 }
double d
Definition: qnumeric_p.h:62
double qreal
Definition: qglobal.h:1193
#define M_PI
Definition: qmath.h:261
#define QT_SINE_TABLE_SIZE
Definition: qmath.h:59
Q_CORE_EXPORT const qreal qt_sine_table[QT_SINE_TABLE_SIZE]
Definition: qmath.cpp:46

◆ qFastSin()

qreal qFastSin ( qreal  x)
inline

Definition at line 264 of file qmath.h.

Referenced by QGL2PaintEngineExPrivate::drawPixmapFragments(), and QTriangulatingStroker::process().

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 }
double d
Definition: qnumeric_p.h:62
double qreal
Definition: qglobal.h:1193
#define M_PI
Definition: qmath.h:261
#define QT_SINE_TABLE_SIZE
Definition: qmath.h:59
Q_CORE_EXPORT const qreal qt_sine_table[QT_SINE_TABLE_SIZE]
Definition: qmath.cpp:46

◆ qFloor()

int qFloor ( qreal  v)
inline

◆ qLn()

qreal qLn ( qreal  v)
inline

Definition at line 221 of file qmath.h.

Referenced by intmaxlog().

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 }
double qreal
Definition: qglobal.h:1193

◆ qPow()

qreal qPow ( qreal  x,
qreal  y 
)
inline

Definition at line 244 of file qmath.h.

Referenced by QODBCResult::exec(), expblur(), growthFactorBelowPreferredSize(), qt_build_pow_tables(), and qt_sRGB_to_linear_RGB().

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 }
double qreal
Definition: qglobal.h:1193

◆ qSin()

qreal qSin ( qreal  v)
inline

Definition at line 93 of file qmath.h.

Referenced by calcArrow(), QStyleHelper::calcLines(), QStyleHelper::calcRadialPos(), QQuaternion::fromAxisAndAngle(), QLineF::fromPolar(), pathArc(), pathArcSegment(), QMatrix4x4::perspective(), QMatrix4x4::projectedRotate(), qt_t_for_arc_angle(), QAccessibleDial::rect(), QMatrix::rotate(), QTransform::rotate(), QMatrix4x4::rotate(), QTransform::rotateRadians(), QLineF::setAngle(), and QQuaternion::slerp().

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 }
double qreal
Definition: qglobal.h:1193

◆ qSqrt()

qreal qSqrt ( qreal  v)
inline

Definition at line 205 of file qmath.h.

Referenced by addCircle(), QDeclarativeParentChangePrivate::doChange(), QOpenGLPaintEngine::drawPath(), drawTrapezoid(), QToolBarLayout::expandedSize(), RadialFetchPlain::fetch(), QDeclarativeGridViewPrivate::flick(), QDeclarativeListViewPrivate::flick(), QQuaternion::fromAxisAndAngle(), QPrintPreviewWidgetPrivate::layoutPages(), QVector2D::length(), QVector3D::length(), QVector4D::length(), QQuaternion::length(), QLineF::length(), QStyleOptionGraphicsItem::levelOfDetailFromTransform(), QFontEngineFT::loadTransformedGlyphSet(), QMatrix::mapToPolygon(), QAccessibleWidget::navigate(), QVector2D::normalize(), normalize(), QVector3D::normalize(), QVector4D::normalize(), QQuaternion::normalize(), QVector2D::normalized(), QVector3D::normalized(), QVector4D::normalized(), QQuaternion::normalized(), pathArc(), QMatrix4x4::projectedRotate(), qIntSqrtInt(), qt_painterpath_bezier_extrema(), qt_scaleForTransform(), quadraticRoots(), QMdi::RegularTiler::rearrange(), QSmoothedAnimation::recalc(), QMdiAreaPrivate::resizeToMinimumTileSize(), QMatrix4x4::rotate(), QGLEllipseMaskGenerator::screenRect(), soft_light_op(), QBezier::stationaryYPoints(), QTessellator::tessellateRect(), QDeclarativeParentAnimation::transition(), QLineF::unitVector(), and QOpenGLPaintEnginePrivate::updateGradient().

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 }
double qreal
Definition: qglobal.h:1193

◆ qTan()

qreal qTan ( qreal  v)
inline

Definition at line 125 of file qmath.h.

Referenced by parseTransformationMatrix(), and QSvgAnimateTransform::resolveMatrix().

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 }
double qreal
Definition: qglobal.h:1193

Variable Documentation

◆ qt_sine_table

Q_CORE_EXPORT const qreal qt_sine_table[QT_SINE_TABLE_SIZE]

Definition at line 46 of file qmath.cpp.