~ubuntu-branches/ubuntu/natty/luatex/natty

« back to all changes in this revision

Viewing changes to source/libs/xpdf/xpdf-3.02/splash/SplashMath.h

  • Committer: Package Import Robot
  • Author(s): Norbert Preining
  • Date: 2010-12-13 23:22:59 UTC
  • mfrom: (0.2.1) (1.5.4) (4.3.12 experimental)
  • Revision ID: package-import@ubuntu.com-20101213232259-nqq2mq5z5x6qldw3
Tags: 0.65.0-1
* new upstream release
* ship two source packages as they are distributed by upstream, only
  renamed to match source package requirements. Fix debian/rules
  to install the manual pdf from the right place

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//========================================================================
2
 
//
3
 
// SplashMath.h
4
 
//
5
 
//========================================================================
6
 
 
7
 
#ifndef SPLASHMATH_H
8
 
#define SPLASHMATH_H
9
 
 
10
 
#include <aconf.h>
11
 
#if USE_FIXEDPONT
12
 
#include "FixedPoint.h"
13
 
#else
14
 
#include <math.h>
15
 
#endif
16
 
#include "SplashTypes.h"
17
 
 
18
 
static inline SplashCoord splashAbs(SplashCoord x) {
19
 
#if USE_FIXEDPOINT
20
 
  return FixedPoint::abs(x);
21
 
#else
22
 
  return fabs(x);
23
 
#endif
24
 
}
25
 
 
26
 
static inline int splashFloor(SplashCoord x) {
27
 
#if USE_FIXEDPOINT
28
 
  return FixedPoint::floor(x);
29
 
#else
30
 
  return (int)floor(x);
31
 
#endif
32
 
}
33
 
 
34
 
static inline int splashCeil(SplashCoord x) {
35
 
#if USE_FIXEDPOINT
36
 
  return FixedPoint::ceil(x);
37
 
#else
38
 
  return (int)ceil(x);
39
 
#endif
40
 
}
41
 
 
42
 
static inline int splashRound(SplashCoord x) {
43
 
#if USE_FIXEDPOINT
44
 
  return FixedPoint::round(x);
45
 
#else
46
 
  return (int)floor(x + 0.5);
47
 
#endif
48
 
}
49
 
 
50
 
static inline SplashCoord splashSqrt(SplashCoord x) {
51
 
#if USE_FIXEDPOINT
52
 
  return FixedPoint::sqrt(x);
53
 
#else
54
 
  return sqrt(x);
55
 
#endif
56
 
}
57
 
 
58
 
static inline SplashCoord splashPow(SplashCoord x, SplashCoord y) {
59
 
#if USE_FIXEDPOINT
60
 
  return FixedPoint::pow(x, y);
61
 
#else
62
 
  return pow(x, y);
63
 
#endif
64
 
}
65
 
 
66
 
static inline SplashCoord splashDist(SplashCoord x0, SplashCoord y0,
67
 
                                     SplashCoord x1, SplashCoord y1) {
68
 
  SplashCoord dx, dy;
69
 
  dx = x1 - x0;
70
 
  dy = y1 - y0;
71
 
#if USE_FIXEDPOINT
72
 
  // this handles the situation where dx*dx or dy*dy is too large to
73
 
  // fit in the 16.16 fixed point format
74
 
  SplashCoord dxa, dya;
75
 
  dxa = splashAbs(dx);
76
 
  dya = splashAbs(dy);
77
 
  if (dxa == 0 && dya == 0) {
78
 
    return 0;
79
 
  } else if (dxa > dya) {
80
 
    return dxa * FixedPoint::sqrt(dya / dxa + 1);
81
 
  } else {
82
 
    return dya * FixedPoint::sqrt(dxa / dya + 1);
83
 
  }
84
 
#else
85
 
  return sqrt(dx * dx + dy * dy);
86
 
#endif
87
 
}
88
 
 
89
 
#endif