bazar
1.3.1
Main Page
Modules
Classes
Files
Examples
File List
File Members
starter
general
general.h
Go to the documentation of this file.
1
/*
2
Copyright 2005, 2006 Computer Vision Lab,
3
Ecole Polytechnique Federale de Lausanne (EPFL), Switzerland.
4
All rights reserved.
5
6
This file is part of BazAR.
7
8
BazAR is free software; you can redistribute it and/or modify it under the
9
terms of the GNU General Public License as published by the Free Software
10
Foundation; either version 2 of the License, or (at your option) any later
11
version.
12
13
BazAR is distributed in the hope that it will be useful, but WITHOUT ANY
14
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15
PARTICULAR PURPOSE. See the GNU General Public License for more details.
16
17
You should have received a copy of the GNU General Public License along with
18
BazAR; if not, write to the Free Software Foundation, Inc., 51 Franklin
19
Street, Fifth Floor, Boston, MA 02110-1301, USA
20
*/
21
#ifndef GENERAL_H
22
#define GENERAL_H
23
24
#include <stdlib.h>
25
26
float
rand_01
(
void
);
27
float
rand_m1p1
(
void
);
28
float
rand
(
float
min,
float
max);
29
30
#ifndef M_PI
31
#define M_PI 3.141592653589793238462643383279
32
#endif
33
34
int
gf_sqr
(
const
int
x);
35
//float gf_sqr(const float x);
36
37
//double dist2(double u1, double v1, double u2, double v2);
38
39
// inline functions:
40
41
inline
float
rand_01
(
void
)
42
{
43
return
(
rand
() % RAND_MAX) / (float)RAND_MAX;
44
}
45
46
inline
float
rand_m1p1
(
void
)
47
{
48
return
2.f *
rand_01
() - 1.f;
49
}
50
51
inline
float
rand
(
float
min,
float
max)
52
{
53
return
min +
rand_01
() * (max - min);
54
}
55
56
inline
int
gf_sqr
(
const
int
x)
57
{
58
return
x * x;
59
}
60
61
inline
float
gf_sqr
(
const
float
x)
62
{
63
return
x * x;
64
}
65
66
//inline double dist2(double u1, double v1, double u2, double v2)
67
//{
68
// return (u1 - u2) * (u1 - u2) + (v1 - v2) * (v1 - v2);
69
//}
70
71
#endif // GENERAL_H
Generated on Tue Jan 15 2013 12:50:21 for bazar by
1.8.1.2