head 1.4; access; symbols; locks; strict; comment @# @; 1.4 date 2002.09.07.01.50.38; author curt; state Exp; branches; next 1.3; 1.3 date 2002.08.31.19.01.53; author curt; state Exp; branches; next 1.2; 1.2 date 2002.08.31.18.54.00; author curt; state Exp; branches; next 1.1; 1.1 date 2002.02.15.17.21.56; author curt; state Exp; branches; next ; desc @@ 1.4 log @Updated doxygen docs. @ text @
Main Page Class Hierarchy Compound List File List Compound Members File Members

# geocoord.cxx

    00001 /* -*- Mode: C++ -*- *****************************************************
    00002  * geocoord.h
    00003  * Written by Durk Talsma. Started March 1998.
    00004  *
    00005  * This library is free software; you can redistribute it and/or
    00006  * modify it under the terms of the GNU Library General Public
    00007  * License as published by the Free Software Foundation; either
    00008  * version 2 of the License, or (at your option) any later version.
    00009  *
    00010  * This library 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 GNU
    00013  * Library General Public License for more details.
    00014  *
    00015  * You should have received a copy of the GNU Library General Public
    00016  * License along with this library; if not, write to the
    00017  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00018  * Boston, MA  02111-1307, USA.
    00019  *
    00020  **************************************************************************/
    00021
    00022 /*************************************************************************
    00023  *
    00024  * This file defines a small and simple class to store geocentric
    00025  * coordinates. Basically, class GeoCoord is intended as a base class for
    00026  * any kind of of object, that can be categorized according to its
    00027  * location on earth, be it navaids, or aircraft. This class for originally
    00028  * written for FlightGear, in order to store Timezone control points.
    00029  *
    00030  ************************************************************************/
    00031 #include "geocoord.h"
    00032 #include <plib/sg.h>
    00033
    00034 GeoCoord::GeoCoord(const GeoCoord& other)
    00035 {
    00036   lat = other.lat;
    00037   lon = other.lon;
    00038 }
    00039
    00040 // double GeoCoord::getAngle(const GeoCoord& other) const
    00041 // {
    00042 //   Vector first(      getX(),       getY(),       getZ());
    00043 //   Vector secnd(other.getX(), other.getY(), other.getZ());
    00044 //     double
    00045 //       dot = VecDot(first, secnd),
    00046 //       len1 = first.VecLen(),
    00047 //       len2 = secnd.VecLen(),
    00048 //       len = len1 * len2,
    00049 //       angle = 0;
    00050 //     //printf ("Dot: %f, len1: %f len2: %f\n", dot, len1, len2);
    00051 //     /*Vector pPos = prevPos - Reference->prevPos;
    00052 //       Vector pVel = prevVel - Reference->prevVel;*/
    00053
    00054
    00055 //     if ( ( (dot / len) < 1) && (dot / len > -1) && len )
    00056 //      angle = acos(dot / len);
    00057 //     return angle;
    00058 // }
    00059
    00060 // GeoCoord* GeoCoordContainer::getNearest(const GeoCoord& ref) const
    00061 // {
    00062 //   float angle, maxAngle = 180;
    00063
    00064 //   GeoCoordVectorConstIterator i, nearest;
    00065 //   for (i = data.begin(); i != data.end(); i++)
    00066 //     {
    00067 //       angle = SGD_RADIANS_TO_DEGREES * (*i)->getAngle(ref);
    00068 //       if (angle < maxAngle)
    00069 //      {
    00070 //        maxAngle = angle;
    00071 //        nearest = i;
    00072 //      }
    00073 //     }
    00074 //   return *nearest;
    00075 // }
    00076
    00077
    00078 GeoCoord* GeoCoordContainer::getNearest(const GeoCoord& ref) const
    00079 {
    00080   sgVec3 first, secnd;
    00081   float dist, maxDist=SG_MAX;
    00082   sgSetVec3( first, ref.getX(), ref.getY(), ref.getZ());
    00083   GeoCoordVectorConstIterator i, nearest;
    00084   for (i = data.begin(); i != data.end(); i++)
    00085     {
    00086       sgSetVec3(secnd, (*i)->getX(), (*i)->getY(), (*i)->getZ());
    00087       dist = sgDistanceSquaredVec3(first, secnd);
    00088       if (dist < maxDist)
    00089         {
    00090           maxDist = dist;
    00091           nearest = i;
    00092         }
    00093     }
    00094   return *nearest;
    00095 }
    00096
    00097
    00098 GeoCoordContainer::~GeoCoordContainer()
    00099 {
    00100     GeoCoordVectorIterator i = data.begin();
    00101   while (i != data.end())
    00102     delete *i++;
    00103 }

@ 1.3 log @Oops, try again. @ text @d112 1 a112 1