00001 #ifndef GSGL_PERIAPSIS_ASTRONOMY_H 00002 #define GSGL_PERIAPSIS_ASTRONOMY_H 00003 00004 // 00005 // $Id: astronomy.hpp 2 2008-03-01 20:58:50Z kulibali $ 00006 // 00007 // Copyright (c) 2008, The Periapsis Project. All rights reserved. 00008 // 00009 // Redistribution and use in source and binary forms, with or without 00010 // modification, are permitted provided that the following conditions are 00011 // met: 00012 // 00013 // * Redistributions of source code must retain the above copyright notice, 00014 // this list of conditions and the following disclaimer. 00015 // 00016 // * Redistributions in binary form must reproduce the above copyright 00017 // notice, this list of conditions and the following disclaimer in the 00018 // documentation and/or other materials provided with the distribution. 00019 // 00020 // * Neither the name of the The Periapsis Project nor the names of its 00021 // contributors may be used to endorse or promote products derived from 00022 // this software without specific prior written permission. 00023 // 00024 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 00025 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 00026 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00027 // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 00028 // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00029 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00030 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00031 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00032 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00033 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00034 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00035 // 00036 00037 #include "space/space.hpp" 00038 #include "math/math.hpp" 00039 #include "math/transform.hpp" 00040 00041 namespace periapsis 00042 { 00043 00044 namespace space 00045 { 00046 00047 extern SPACE_API double J2000; 00048 00049 00050 /// \name Coordinate System Transforms 00051 /// Note that these are for the usual OpenGL setup where transforms are done by multiplying the matrix by the vector to transform. 00052 /// @{ 00053 00054 extern SPACE_API gsgl::math::transform EQUATORIAL_WRT_GALACTIC; 00055 extern SPACE_API gsgl::math::transform GALACTIC_WRT_EQUATORIAL; 00056 00057 extern SPACE_API gsgl::math::transform ECLIPTIC_WRT_EQUATORIAL; 00058 extern SPACE_API gsgl::math::transform EQUATORIAL_WRT_ECLIPTIC; 00059 00060 extern SPACE_API gsgl::math::transform ECLIPTIC_WRT_GALACTIC; 00061 extern SPACE_API gsgl::math::transform GALACTIC_WRT_ECLIPTIC; 00062 00063 /// @} 00064 00065 /// \name Geographic Coordinates 00066 /// @{ 00067 00068 /// Converts from geocentric cartesian coordinates to geographic polar coordinates. 00069 /// 00070 /// This function is much more expensive than its inverse, so use sparingly... 00071 /// 00072 /// \param polar_radius The polar radius of the planet. 00073 /// \param equatorial_radius The equatorial radius of the planet. 00074 /// \param x The x coordinate. 00075 /// \param y The y coordinate. 00076 /// \param z The z coordinate. 00077 /// \param lat The resulting geodedic latitude. 00078 /// \param lon The resulting geodedic longitude. 00079 /// \param alt The altitude above the surface of the earth. 00080 void SPACE_API geocentric_to_geographic(const gsgl::real_t & polar_radius, const gsgl::real_t & equatorial_radius, 00081 const gsgl::real_t & x, const gsgl::real_t & y, const gsgl::real_t & z, 00082 gsgl::real_t & lat, gsgl::real_t & lon, gsgl::real_t & alt); 00083 00084 /// Converts from geographic polar coordinates to geocentric cartesian coordinates. 00085 /// 00086 /// \param polar_radius The polar radius of the planet. 00087 /// \param equatorial_radius The equatorial radius of the planet. 00088 /// \param lat The geodedic latitude. 00089 /// \param lon The geodedic longitude. 00090 /// \param alt The altitude above the planet. 00091 /// \param x The resulting x coordinate. 00092 /// \param y The resulting y coordinate. 00093 /// \param z The resulting z coordinate. 00094 void SPACE_API geographic_to_geocentric(const gsgl::real_t & polar_radius, const gsgl::real_t & equatorial_radius, 00095 const gsgl::real_t & lat, const gsgl::real_t & lon, const gsgl::real_t & alt, 00096 gsgl::real_t & x, gsgl::real_t & y, gsgl::real_t & z); 00097 00098 /// @} 00099 00100 } // namespace space 00101 00102 } // namespace periapsis 00103 00104 #endif