Mercurial > hg > nsaunier > traffic-intelligence
view include/utils.hpp @ 91:daa05fae1a70
modified the type of the result of interval lengths to float, added comments
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Thu, 09 Jun 2011 16:03:17 -0400 |
| parents | a52653dca25d |
| children | b32947b002da |
line wrap: on
line source
#ifndef UTILS_HPP #define UTILS_HPP #include <iosfwd> static const double pi = 3.14159265358979323846; /** Opens file for writing with fixed scientific precision. */ void openWriteScientificPrecision(std::ofstream& out, const std::string& filename, const int& precision); void openWritePrecision(std::ofstream& out, const std::string& filename, const int& precision); /** Opens files and checks how it went. */ bool openCheck(std::ifstream& f, const std::string& filename, const std::string& callingFunctionName); bool openCheck(std::ofstream& f, const std::string& filename, const std::string& callingFunctionName); // inline inline double square(const int& a) { return a*a;} /** Implements key bindings, for example for cvWaitKey(). */ inline bool forwardKey(const int& pressedKey) { return (((char)pressedKey) == '+');} inline bool backwardKey(const int& pressedKey) { return (((char)pressedKey) == '-');} inline bool saveKey(const int& pressedKey) { return (((char)pressedKey) == 's' || ((char)pressedKey) == 'S');} inline bool interruptionKey(const int& pressedKey) { return (((char)pressedKey) == 'q' || ((char)pressedKey) == 'Q');} inline bool skipKey(const int& pressedKey) { return (((char)pressedKey) == 'n' || ((char)pressedKey) == 'N');} #endif
