Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

univcoord.h

Go to the documentation of this file.
00001 // univcoord.h
00002 //
00003 // Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
00004 //
00005 // Universal coordinate is a high-precision fixed point coordinate for
00006 // locating objects in 3D space on scales ranging from millimeters to
00007 // thousands of light years.
00008 //
00009 // This program is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU General Public License
00011 // as published by the Free Software Foundation; either version 2
00012 // of the License, or (at your option) any later version.
00013 
00014 #ifndef _UNIVCOORD_H_
00015 #define _UNIVCOORD_H_
00016 
00017 #include <celutil/bigfix.h>
00018 #include <celmath/vecmath.h>
00019 
00020 class UniversalCoord
00021 {
00022  public:
00023     UniversalCoord();
00024     UniversalCoord(BigFix, BigFix, BigFix);
00025     UniversalCoord(double, double, double);
00026     UniversalCoord(const Point3d&);
00027     UniversalCoord(const Point3f&);
00028 
00029     operator Point3d() const;
00030     operator Point3f() const;
00031 
00032     friend Vec3d operator-(const UniversalCoord&, const UniversalCoord&);
00033     friend Vec3d operator-(const UniversalCoord&, const Point3d&);
00034     friend Vec3d operator-(const Point3d&, const UniversalCoord&);
00035     friend Vec3f operator-(const UniversalCoord&, const Point3f&);
00036     friend Vec3f operator-(const Point3f&, const UniversalCoord&);
00037     friend UniversalCoord operator+(const UniversalCoord&, const Vec3d&);
00038     friend UniversalCoord operator+(const UniversalCoord&, const Vec3f&);
00039     friend UniversalCoord operator-(const UniversalCoord&, const Vec3d&);
00040     friend UniversalCoord operator-(const UniversalCoord&, const Vec3f&);
00041 
00042     friend UniversalCoord operator+(const UniversalCoord&, const UniversalCoord&);
00043 
00044     double distanceTo(const UniversalCoord&);
00045     UniversalCoord difference(const UniversalCoord&) const;
00046 
00047     BigFix x, y, z;
00048 };
00049 
00050 Vec3d operator-(const UniversalCoord&, const UniversalCoord&);
00051 Vec3d operator-(const UniversalCoord&, const Point3d&);
00052 Vec3d operator-(const Point3d&, const UniversalCoord&);
00053 Vec3f operator-(const UniversalCoord&, const Point3f&);
00054 Vec3f operator-(const Point3f&, const UniversalCoord&);
00055 UniversalCoord operator+(const UniversalCoord&, const Vec3d&);
00056 UniversalCoord operator+(const UniversalCoord&, const Vec3f&);
00057 UniversalCoord operator-(const UniversalCoord&, const Vec3d&);
00058 UniversalCoord operator-(const UniversalCoord&, const Vec3f&);
00059 
00060 // Not really proper--we can't add points.  But the only way around it is
00061 // to create a separate version of UniversalCoord that acts like a vector.
00062 UniversalCoord operator+(const UniversalCoord&, const UniversalCoord&);
00063 
00064 #endif // _UNIVCOORD_H_
00065 

Generated on Sat Jan 14 22:30:29 2006 for Celestia by  doxygen 1.4.1