misc.h
Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2006 Pedro Felzenszwalb
00003 
00004 This program is free software; you can redistribute it and/or modify
00005 it under the terms of the GNU General Public License as published by
00006 the Free Software Foundation; either version 2 of the License, or
00007 (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00017 */
00018 
00019 /* random stuff */
00020 
00021 #ifndef MISC_H
00022 #define MISC_H
00023 
00024 #include <cmath>
00025 
00026 #ifndef M_PI
00027 #define M_PI 3.141592653589793
00028 #endif
00029 
00030 typedef unsigned char uchar;
00031 
00032 typedef struct { uchar r, g, b; } rgb;
00033 
00034 inline bool operator==(const rgb &a, const rgb &b) {
00035   return ((a.r == b.r) && (a.g == b.g) && (a.b == b.b));
00036 }
00037 
00038 template <class T>
00039 inline T abs(const T &x) { return (x > 0 ? x : -x); };
00040 
00041 template <class T>
00042 inline int sign(const T &x) { return (x >= 0 ? 1 : -1); };
00043 
00044 template <class T>
00045 inline T square(const T &x) { return x*x; };
00046 
00047 template <class T>
00048 inline T bound(const T &x, const T &min, const T &max) {
00049   return (x < min ? min : (x > max ? max : x));
00050 }
00051 
00052 template <class T>
00053 inline bool check_bound(const T &x, const T&min, const T &max) {
00054   return ((x < min) || (x > max));
00055 }
00056 
00057 inline int vlib_round(float x) { return (int)(x + 0.5F); }
00058 
00059 inline int vlib_round(double x) { return (int)(x + 0.5); }
00060 
00061 inline double gaussian(double val, double sigma) {
00062   return exp(-square(val/sigma)/2)/(sqrt(2*M_PI)*sigma);
00063 }
00064 
00065 #endif


iri_leaf_fitting
Author(s): Sergi Foix
autogenerated on Fri Dec 6 2013 20:28:17