Mercurial > hg > nsaunier > traffic-intelligence
annotate include/utils.hpp @ 22:169cd4679366
made Trajectory iterable
| author | Nicolas Saunier <nico@confins.net> |
|---|---|
| date | Fri, 04 Dec 2009 01:01:11 -0500 |
| parents | ef0d7caf8e91 |
| children | a52653dca25d |
| rev | line source |
|---|---|
|
3
ace29ecfb846
basic files and directories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
1 #ifndef UTILS_HPP |
|
ace29ecfb846
basic files and directories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
2 #define UTILS_HPP |
|
ace29ecfb846
basic files and directories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
3 |
|
20
ef0d7caf8e91
draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
12
diff
changeset
|
4 #include <iofwd> |
|
ef0d7caf8e91
draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
12
diff
changeset
|
5 |
| 12 | 6 static const double pi = 3.14159265358979323846; |
|
3
ace29ecfb846
basic files and directories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
7 |
|
20
ef0d7caf8e91
draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
12
diff
changeset
|
8 /** Opens file for writing with fixed scientific precision. */ |
|
ef0d7caf8e91
draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
12
diff
changeset
|
9 void openWriteScientific(ofstream& out, const string& filename, const int& precision); |
|
ef0d7caf8e91
draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
12
diff
changeset
|
10 |
|
ef0d7caf8e91
draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
12
diff
changeset
|
11 void openWritePrecision(ofstream& out, const string& filename, const int& precision); |
|
ef0d7caf8e91
draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
12
diff
changeset
|
12 |
|
ef0d7caf8e91
draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
12
diff
changeset
|
13 /** Opens files and checks how it went. */ |
|
ef0d7caf8e91
draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
12
diff
changeset
|
14 bool openCheck(ifstream& f, const string& filename, const string& callingFunctionName); |
|
ef0d7caf8e91
draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
12
diff
changeset
|
15 bool openCheck(ofstream& f, const string& filename, const string& callingFunctionName); |
|
ef0d7caf8e91
draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
12
diff
changeset
|
16 |
|
ef0d7caf8e91
draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
12
diff
changeset
|
17 |
|
ef0d7caf8e91
draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
12
diff
changeset
|
18 // inline |
|
ef0d7caf8e91
draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
12
diff
changeset
|
19 |
| 12 | 20 inline double square(const int& a) { return a*a;} |
| 21 | |
| 22 /** Implements key bindings, for example for cvWaitKey(). */ | |
| 23 inline bool forwardKey(const int& pressedKey) { return (((char)pressedKey) == '+');} | |
| 24 | |
| 25 inline bool backwardKey(const int& pressedKey) { return (((char)pressedKey) == '-');} | |
| 26 | |
| 27 inline bool saveKey(const int& pressedKey) { return (((char)pressedKey) == 's' || ((char)pressedKey) == 'S');} | |
| 28 | |
| 29 inline bool interruptionKey(const int& pressedKey) { return (((char)pressedKey) == 'q' || ((char)pressedKey) == 'Q');} | |
| 30 | |
| 31 inline bool skipKey(const int& pressedKey) { return (((char)pressedKey) == 'n' || ((char)pressedKey) == 'N');} | |
|
3
ace29ecfb846
basic files and directories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
32 |
|
ace29ecfb846
basic files and directories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
33 #endif |
