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 #pragma once
00022 
00023 #include <cmath>
00024 
00025 namespace distance_transform
00026 {
00027   typedef unsigned char uchar;
00028 
00029   typedef struct { uchar r, g, b; } rgb;
00030 
00031   inline bool operator==(const rgb &a, const rgb &b) {
00032     return ((a.r == b.r) && (a.g == b.g) && (a.b == b.b));
00033   }
00034 
00035   template <class T>
00036   inline T abs(const T &x) { return (x > 0 ? x : -x); };
00037 
00038   template <class T>
00039   inline int sign(const T &x) { return (x >= 0 ? 1 : -1); };
00040 
00041   template <class T>
00042   inline T square(const T &x) { return x*x; };
00043 
00044   template <class T>
00045   inline T bound(const T &x, const T &min, const T &max) {
00046     return (x < min ? min : (x > max ? max : x));
00047   }
00048 
00049   template <class T>
00050   inline bool check_bound(const T &x, const T&min, const T &max) {
00051     return ((x < min) || (x > max));
00052   }
00053 
00054   inline int vlib_round(float x) { return (int)(x + 0.5F); }
00055 
00056   inline int vlib_round(double x) { return (int)(x + 0.5); }
00057 
00058   inline double gaussian(double val, double sigma) {
00059     return exp(-square(val/sigma)/2)/(sqrt(2*M_PI)*sigma);
00060   }
00061 
00062 } // namespace


grid_map_sdf
Author(s): Takahiro Miki , Péter Fankhauser
autogenerated on Mon Oct 9 2017 03:09:34