Sha256: 5cff7fff11f54373b62e0b1e0aae7486a3dfe7feee035a25a77e7a3949cc1914
Contents?: true
Size: 1.74 KB
Versions: 2
Compression:
Stored size: 1.74 KB
Contents
//======================================================================== // // SplashMath.h // //======================================================================== #ifndef SPLASHMATH_H #define SPLASHMATH_H #include <aconf.h> #if USE_FIXEDPONT #include "FixedPoint.h" #else #include <math.h> #endif #include "SplashTypes.h" static inline SplashCoord splashAbs(SplashCoord x) { #if USE_FIXEDPOINT return FixedPoint::abs(x); #else return fabs(x); #endif } static inline int splashFloor(SplashCoord x) { #if USE_FIXEDPOINT return FixedPoint::floor(x); #else return (int)floor(x); #endif } static inline int splashCeil(SplashCoord x) { #if USE_FIXEDPOINT return FixedPoint::ceil(x); #else return (int)ceil(x); #endif } static inline int splashRound(SplashCoord x) { #if USE_FIXEDPOINT return FixedPoint::round(x); #else return (int)floor(x + 0.5); #endif } static inline SplashCoord splashSqrt(SplashCoord x) { #if USE_FIXEDPOINT return FixedPoint::sqrt(x); #else return sqrt(x); #endif } static inline SplashCoord splashPow(SplashCoord x, SplashCoord y) { #if USE_FIXEDPOINT return FixedPoint::pow(x, y); #else return pow(x, y); #endif } static inline SplashCoord splashDist(SplashCoord x0, SplashCoord y0, SplashCoord x1, SplashCoord y1) { SplashCoord dx, dy; dx = x1 - x0; dy = y1 - y0; #if USE_FIXEDPOINT // this handles the situation where dx*dx or dy*dy is too large to // fit in the 16.16 fixed point format SplashCoord dxa, dya; dxa = splashAbs(dx); dya = splashAbs(dy); if (dxa == 0 && dya == 0) { return 0; } else if (dxa > dya) { return dxa * FixedPoint::sqrt(dya / dxa + 1); } else { return dya * FixedPoint::sqrt(dxa / dya + 1); } #else return sqrt(dx * dx + dy * dy); #endif } #endif
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pdf2json-0.2.0 | pdf2json-0.52-source/splash/SplashMath.h |
pdf2json-0.1.0 | pdf2json-0.52-source/splash/SplashMath.h |