source: trunk/poppler/mypoppler/splash/SplashMath.h @ 2

Last change on this file since 2 was 2, checked in by Eugene Romanenko, 16 years ago

First import

File size: 1.4 KB
Line 
1//========================================================================
2//
3// SplashMath.h
4//
5//========================================================================
6
7#ifndef SPLASHMATH_H
8#define SPLASHMATH_H
9
10#if USE_FIXEDPONT
11#include "FixedPoint.h"
12#else
13#include <math.h>
14#endif
15#include "SplashTypes.h"
16
17static inline SplashCoord splashAbs(SplashCoord x) {
18#if USE_FIXEDPOINT
19  return FixedPoint::abs(x);
20#else
21  return fabs(x);
22#endif
23}
24
25static inline int splashFloor(SplashCoord x) {
26  #if USE_FIXEDPOINT
27    return FixedPoint::floor(x);
28  #else
29    return (int)floor(x);
30  #endif
31}
32
33static inline int splashCeil(SplashCoord x) {
34#if USE_FIXEDPOINT
35  return FixedPoint::ceil(x);
36#else
37  return (int)ceil(x);
38#endif
39}
40
41static inline int splashRound(SplashCoord x) {
42#if USE_FIXEDPOINT
43  return FixedPoint::round(x);
44#else
45  return (int)floor(x + 0.5);
46#endif
47}
48
49static inline SplashCoord splashSqrt(SplashCoord x) {
50#if USE_FIXEDPOINT
51  return FixedPoint::sqrt(x);
52#else
53  return sqrt(x);
54#endif
55}
56
57static inline SplashCoord splashPow(SplashCoord x, SplashCoord y) {
58#if USE_FIXEDPOINT
59  return FixedPoint::pow(x, y);
60#else
61  return pow(x, y);
62#endif
63}
64
65static inline SplashCoord splashDist(SplashCoord x0, SplashCoord y0,
66                                     SplashCoord x1, SplashCoord y1) {
67  SplashCoord dx, dy;
68  dx = x1 - x0;
69  dy = y1 - y0;
70#if USE_FIXEDPOINT
71  return FixedPoint::sqrt(dx * dx + dy * dy);
72#else
73  return sqrt(dx * dx + dy * dy);
74#endif
75}
76
77#endif
Note: See TracBrowser for help on using the repository browser.