QWT API (中文) 7.0.1
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt3d_helper.h
1#ifndef __HELPER_H__
2#define __HELPER_H__
3
4#include <math.h>
5#include <float.h>
6#include <vector>
7#include <algorithm>
8
9namespace {
10// Returns the minimum of two double values
11inline double Min_(double a, double b)
12{
13 return (a < b) ? a : b;
14}
15}
16
17namespace Qwt3D {
18
19// Checks if a value is practically zero (within floating-point epsilon)
20inline bool isPracticallyZero(double a, double b = 0)
21{
22 if (!b)
23 return (fabs(a) <= DBL_MIN);
24
25 return (fabs(a - b) <= Min_(fabs(a), fabs(b)) * DBL_EPSILON);
26}
27
28// Rounds a double value to the nearest integer
29inline int round(double d)
30{
31 return (d > 0) ? int(d + 0.5) : int(d - 0.5);
32}
33
34} // ns
35
36#endif