• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

/home/pascal/depot/filedata/src/geometry/geometry_common.h

00001 /***************************************************************************
00002  *   Copyright (C) 2012 by Nicolas PASCAL                                  *
00003  *   nicolas.pascal@icare.univ-lille1.fr                                   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 /***************************************************************************
00022  *  Descrition :                                                           *
00023  *  implements common geometry constants and functions                     *
00024  *                                                                         *
00025  *  History :                                                              *
00026  *  2012/02/03 : start                                                     *
00027  ***************************************************************************/
00028 
00029 #ifndef GEOMETRY_COMMON_H
00030 #define GEOMETRY_COMMON_H
00031 
00032 #include <cmath>
00033 
00035 static const double M_2PI = 2. * M_PI;
00037 // static const double M_PI_2 = M_PI / 2.;
00038 
00040 const double DEG2RAD = double ( M_PI ) / double ( 180.);
00042 const double RAD2DEG = double ( 180. ) * double ( M_1_PI );
00043 
00049 inline const double radians (const double alpha) {
00050     return DEG2RAD * alpha;
00051 };
00057 inline const double degrees (const double alpha) {
00058     return RAD2DEG * alpha;
00059 };
00060 
00066 inline double format_lat (double lat) {
00067     while (lat < - 90.)
00068         lat = -180. - lat;
00069     while (lat > 90.)
00070         lat = 180. - lat;
00071     return lat;
00072 };
00073 
00079 inline double format_lon (double lon) {
00080     while (lon < - 180.)
00081         lon += 360.;
00082     while (lon >= 180.)
00083         lon -= 360.;
00084     return lon;
00085 };
00086 
00087 #endif

Generated on Thu Feb 14 2013 17:59:03 for filedata.kdevelop by  doxygen 1.7.1