00001 #ifndef __MAPPING_H__ 00002 #define __MAPPING_H__ 00003 00004 #include <math.h> 00005 #include <stdio.h> 00006 #include "utils.h" 00007 00008 #ifndef PI 00009 #define PI 3.14159 00010 #endif 00011 #ifndef PI_OVER_TWO 00012 #define PI_OVER_TWO (PI/2.0) 00013 #endif 00014 00015 namespace remap { 00016 00018 class Mapping 00019 { 00020 public: 00021 virtual ~Mapping(){} 00022 virtual bool MapTo(float lat, float lon, float &x, float &y) const = 0; 00023 virtual bool MapFrom(float x, float y, float &lat, float &lon) const = 0; 00024 00025 bool LatLongToVector(float lat, float lon, float *vector) const; 00026 bool VectorToLatLong(const float *vector, float &lat, float &lon) const; 00027 }; 00028 00029 00031 class Equirectangular : public Mapping 00032 { 00033 public: 00034 Equirectangular(int xres, int yres, float phi1); 00035 virtual ~Equirectangular(); 00036 virtual bool MapTo(float lat, float lon, float &x, float &y) const; 00037 virtual bool MapFrom(float x, float y, float &lat, float &lon) const; 00038 private: 00039 int m_xres, m_yres; 00040 float m_phi1; 00041 }; 00042 00044 class AngularFisheye : public Mapping 00045 { 00046 public: 00047 AngularFisheye(float centre_x, float centre_y, float radius); 00048 virtual ~AngularFisheye(); 00049 virtual bool MapTo(float lat, float lon, float &x, float &y) const; 00050 virtual bool MapFrom(float x, float y, float &lat, float &lon) const; 00051 00052 bool SetZenith(float x, float y); 00053 void GetCentre(float &x, float &y) const; 00054 void GetZenith(float &x, float &y) const; 00055 private: 00056 float m_centre_x, m_centre_y, 00057 m_zenith_x, m_zenith_y, 00058 m_radius; 00059 Matrix33 m_forward_transform, 00060 m_inverse_transform; 00061 }; 00062 00063 void circumcircle(float, float, float, float, float, float, float&, float&, float&); 00064 00066 00067 } 00068 00069 #endif 00070