~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to karbon/common/KarbonGlobal.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
namespace KarbonGlobal
38
38
{
39
 
    const qreal pi                      =  3.14159265358979323846;      // pi
40
 
    const qreal twopi           =  6.28318530717958647692;      // 2pi
41
 
    const qreal pi_2            =  1.57079632679489661923;      // pi/2
42
 
    const qreal pi_180          =  0.01745329251994329576;      // pi/180
43
 
    const qreal one_pi_180      = 57.29577951308232087684;      // 180/pi
44
 
    const qreal sqrt2           =  1.41421356237309504880;      // sqrt(2)
45
 
    const qreal one_3           =  0.33333333333333333333;      // 1/3
46
 
    const qreal two_3           =  0.66666666666666666667;      // 2/3
47
 
    const qreal one_6           =  0.16666666666666666667;      // 1/6
48
 
    const qreal one_7           =  0.14285714285714285714;      // 1/7
49
 
 
50
 
    /**
51
 
    * Constants used to decide if a number is equal zero or nearly the same
52
 
    * as another number.
53
 
    */
54
 
    const qreal veryBigNumber = 1.0e8;
55
 
    const qreal verySmallNumber = 1.0e-8;
56
 
 
57
 
    /**
58
 
    * A bezier with this flatness is considered "flat". Used in subdividing.
59
 
    */
60
 
    const qreal flatnessTolerance = 0.01;
61
 
 
62
 
    /**
63
 
    * A tolerance used to approximate bezier lengths. If the relative difference
64
 
    * between chordlength and polylength (length of the controlpolygon) is smaller
65
 
    * than this value, the length of the bezier is 1/2 chordlength + 1/2 polylength.
66
 
    */
67
 
    const qreal lengthTolerance = 0.005;
68
 
 
69
 
    /**
70
 
    * A tolerance used to calculate param t on a segment at a given arc
71
 
    * length (counting from t=0).
72
 
    * If the relative difference between a length approximation and the given
73
 
    * length is smaller than this value, they are assumed to be identical.
74
 
    */
75
 
    const qreal paramLengthTolerance = 0.001;
76
 
 
77
 
    /**
78
 
    * A range for the isNear() check, to decide if a QPointF "is the same"
79
 
    * as another.
80
 
    */
81
 
    const qreal isNearRange = 0.001;
82
 
 
83
 
    /**
84
 
    * A tolerance for multiplying normalized (length=1) vectors. A result of
85
 
    * >= parallelTolerance indicates parallel vectors.
86
 
    */
87
 
    const qreal parallelTolerance = 0.99;
88
 
 
89
 
    /**
90
 
    * Returns the sign of parameter a.
91
 
    */
92
 
    inline int sign( qreal a )
93
 
    {
94
 
        return a < 0.0
95
 
            ? -1
96
 
            : 1;
97
 
    }
98
 
 
99
 
    /**
100
 
    * Calculates the binomial coefficient n! / ( k! * ( n - k)! ).
101
 
    */
102
 
    int binomialCoeff( unsigned n, unsigned k );
103
 
 
104
 
    /**
105
 
    * Calculates the value ln( n! ).
106
 
    */
107
 
    qreal factorialLn( unsigned n );
108
 
 
109
 
    /**
110
 
    * Calculates the value ln| Gamma(x) | for x > 0.
111
 
    */
112
 
    qreal gammaLn( qreal x );
113
 
 
114
 
    /// Returns scalar product of two given vectors
115
 
    KARBONCOMMON_EXPORT qreal scalarProduct(const QPointF &p1, const QPointF &p2);
116
 
 
117
 
    bool pointsAreNear(const QPointF &p1, const QPointF &p2, qreal range);
118
 
 
119
 
    /// Returns the cross product of two given vectors 
120
 
    QPointF crossProduct( const QPointF &v1, const QPointF &v2 );
 
39
const qreal pi          =  3.14159265358979323846;  // pi
 
40
const qreal twopi       =  6.28318530717958647692;  // 2pi
 
41
const qreal pi_2        =  1.57079632679489661923;  // pi/2
 
42
const qreal pi_180      =  0.01745329251994329576;  // pi/180
 
43
const qreal one_pi_180  = 57.29577951308232087684;  // 180/pi
 
44
const qreal sqrt2       =  1.41421356237309504880;  // sqrt(2)
 
45
const qreal one_3       =  0.33333333333333333333;  // 1/3
 
46
const qreal two_3       =  0.66666666666666666667;  // 2/3
 
47
const qreal one_6       =  0.16666666666666666667;  // 1/6
 
48
const qreal one_7       =  0.14285714285714285714;  // 1/7
 
49
 
 
50
/**
 
51
* Constants used to decide if a number is equal zero or nearly the same
 
52
* as another number.
 
53
*/
 
54
const qreal veryBigNumber = 1.0e8;
 
55
const qreal verySmallNumber = 1.0e-8;
 
56
 
 
57
/**
 
58
* A bezier with this flatness is considered "flat". Used in subdividing.
 
59
*/
 
60
const qreal flatnessTolerance = 0.01;
 
61
 
 
62
/**
 
63
* A tolerance used to approximate bezier lengths. If the relative difference
 
64
* between chordlength and polylength (length of the controlpolygon) is smaller
 
65
* than this value, the length of the bezier is 1/2 chordlength + 1/2 polylength.
 
66
*/
 
67
const qreal lengthTolerance = 0.005;
 
68
 
 
69
/**
 
70
* A tolerance used to calculate param t on a segment at a given arc
 
71
* length (counting from t=0).
 
72
* If the relative difference between a length approximation and the given
 
73
* length is smaller than this value, they are assumed to be identical.
 
74
*/
 
75
const qreal paramLengthTolerance = 0.001;
 
76
 
 
77
/**
 
78
* A range for the isNear() check, to decide if a QPointF "is the same"
 
79
* as another.
 
80
*/
 
81
const qreal isNearRange = 0.001;
 
82
 
 
83
/**
 
84
* A tolerance for multiplying normalized (length=1) vectors. A result of
 
85
* >= parallelTolerance indicates parallel vectors.
 
86
*/
 
87
const qreal parallelTolerance = 0.99;
 
88
 
 
89
/**
 
90
* Returns the sign of parameter a.
 
91
*/
 
92
inline int sign(qreal a)
 
93
{
 
94
    return a < 0.0
 
95
           ? -1
 
96
           : 1;
 
97
}
 
98
 
 
99
/**
 
100
* Calculates the binomial coefficient n! / ( k! * ( n - k)! ).
 
101
*/
 
102
int binomialCoeff(unsigned n, unsigned k);
 
103
 
 
104
/**
 
105
* Calculates the value ln( n! ).
 
106
*/
 
107
qreal factorialLn(unsigned n);
 
108
 
 
109
/**
 
110
* Calculates the value ln| Gamma(x) | for x > 0.
 
111
*/
 
112
qreal gammaLn(qreal x);
 
113
 
 
114
/// Returns scalar product of two given vectors
 
115
KARBONCOMMON_EXPORT qreal scalarProduct(const QPointF &p1, const QPointF &p2);
 
116
 
 
117
bool pointsAreNear(const QPointF &p1, const QPointF &p2, qreal range);
 
118
 
 
119
/// Returns the cross product of two given vectors
 
120
QPointF crossProduct(const QPointF &v1, const QPointF &v2);
121
121
}
122
122
 
123
123
#endif // KARBONGLOBAL_H