Subversion Repositories public iLand

Rev

Rev 431 | Rev 615 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 431 Rev 443
Line 75... Line 75...
75
inline int irandom(int from, int to)
75
inline int irandom(int from, int to)
76
{
76
{
77
    return from + mtRand().randInt(to-from);
77
    return from + mtRand().randInt(to-from);
78
    //return from +  rand()%(to-from);
78
    //return from +  rand()%(to-from);
79
}
79
}
-
 
80
-
 
81
// random number function with additional ptr to random function
-
 
82
inline double nrandom(MTRand &random, const double& p1, const double& p2)
-
 
83
{
-
 
84
    return p1 + random.rand(p2-p1);
-
 
85
    //return p1 + (p2-p1)*(rand()/double(RAND_MAX));
-
 
86
}
-
 
87
/// returns a random number in [0,1] (i.e.="1" is a possible result!)
-
 
88
inline double drandom(MTRand &random)
-
 
89
{
-
 
90
    return random.rand();
-
 
91
    //return rand()/double(RAND_MAX);
-
 
92
}
-
 
93
/// return a random number from "from" to "to" (incl.), i.e. irandom(3,5) results in 3, 4 or 5.
-
 
94
inline int irandom(MTRand &random, int from, int to)
-
 
95
{
-
 
96
    return from + random.randInt(to-from);
-
 
97
    //return from +  rand()%(to-from);
-
 
98
}
-
 
99
-
 
100
80
101
81
inline double limit(const double value, const double lower, const double upper)
102
inline double limit(const double value, const double lower, const double upper)
82
{
103
{
83
    return qMax(qMin(value, upper), lower);
104
    return qMax(qMin(value, upper), lower);
84
}
105
}