]> git.mxchange.org Git - simgear.git/blobdiff - simgear/math/point3d.hxx
Merge branch 'ehofman/sound'
[simgear.git] / simgear / math / point3d.hxx
index 529674fa4a91eacf90b392f854c619d90163c0aa..089da93aa3f1ab9bc069090d47f59cdf81ca1e43 100644 (file)
 
 #include <simgear/compiler.h>
 
-#ifdef SG_MATH_EXCEPTION_CLASH
-# define exception c_exception
-#endif
-
-#ifdef SG_HAVE_STD_INCLUDES
-# include <iostream>
-# include <cassert>
-# include <cmath>
-#else
-# include <iostream.h>
-# include <assert.h>
-# include <math.h>
-#endif
+#include <ostream>
+#include <istream>
+#include <cassert>
+#include <cmath>
 
 #include "SGMath.hxx"
 
-// I don't understand ... <math.h> or <cmath> should be included
-// already depending on how you defined SG_HAVE_STD_INCLUDES, but I
-// can go ahead and add this -- CLO
-#ifdef __MWERKS__
-SG_USING_NAMESPACE(std);
-#endif
-
-SG_USING_STD(ostream);
-SG_USING_STD(istream);
-
-
 const double fgPoint3_Epsilon = 0.0000001;
 
 enum {PX, PY, PZ};                 // axes
 
 // Kludge for msvc++ 6.0 - requires forward decls of friend functions.
 class Point3D;
-istream& operator>> ( istream&, Point3D& );
-ostream& operator<< ( ostream&, const Point3D& );
+std::istream& operator>> ( std::istream&, Point3D& );
+std::ostream& operator<< ( std::ostream&, const Point3D& );
 Point3D operator- (const Point3D& p);              // -p1
 bool operator== (const Point3D& a, const Point3D& b);  // p1 == p2?
 
@@ -97,6 +77,8 @@ public:
     static Point3D fromSGGeod(const SGGeod& geod);
     static Point3D fromSGGeoc(const SGGeoc& geoc);
     static Point3D fromSGVec3(const SGVec3<double>& cart);
+    static Point3D fromSGVec3(const SGVec3<float>& cart);
+    static Point3D fromSGVec2(const SGVec2<double>& cart);
 
     // Assignment operators
 
@@ -132,11 +114,15 @@ public:
     SGGeod toSGGeod(void) const;
     SGGeoc toSGGeoc(void) const;
 
+    SGVec3d toSGVec3d(void) const;
+    SGVec3f toSGVec3f(void) const;
+    SGVec2f toSGVec2f(void) const;
+
     // friends
     friend Point3D operator - (const Point3D& p);                  // -p1
     friend bool operator == (const Point3D& a, const Point3D& b);  // p1 == p2?
-    friend istream& operator>> ( istream&, Point3D& );
-    friend ostream& operator<< ( ostream&, const Point3D& );
+    friend std::istream& operator>> ( std::istream&, Point3D& );
+    friend std::ostream& operator<< ( std::ostream&, const Point3D& );
 
     // Special functions
     double distance3D(const Point3D& a) const;        // distance between
@@ -145,8 +131,8 @@ public:
 
 
 // input from stream
-inline istream&
-operator >> ( istream& in, Point3D& p)
+inline std::istream&
+operator >> ( std::istream& in, Point3D& p)
 {
     char c;
 
@@ -177,8 +163,8 @@ operator >> ( istream& in, Point3D& p)
     return in;
 }
 
-inline ostream&
-operator<< ( ostream& out, const Point3D& p )
+inline std::ostream&
+operator<< ( std::ostream& out, const Point3D& p )
 {
     return out << p.n[PX] << ", " << p.n[PY] << ", " << p.n[PZ];
 }
@@ -239,6 +225,24 @@ inline Point3D Point3D::fromSGVec3(const SGVec3<double>& cart)
   return pt;
 }
 
+inline Point3D Point3D::fromSGVec3(const SGVec3<float>& cart)
+{
+  Point3D pt;
+  pt.setx(cart.x());
+  pt.sety(cart.y());
+  pt.setz(cart.z());
+  return pt;
+}
+
+inline Point3D Point3D::fromSGVec2(const SGVec2<double>& cart)
+{
+  Point3D pt;
+  pt.setx(cart.x());
+  pt.sety(cart.y());
+  pt.setz(0);
+  return pt;
+}
+
 // ASSIGNMENT OPERATORS
 
 inline Point3D& Point3D::operator = (const Point3D& p)
@@ -341,6 +345,21 @@ inline SGGeoc Point3D::toSGGeoc(void) const
   return geoc;
 }
 
+inline SGVec3d Point3D::toSGVec3d(void) const
+{
+  return SGVec3d(x(), y(), z());
+}
+
+inline SGVec3f Point3D::toSGVec3f(void) const
+{
+  return SGVec3f(x(), y(), z());
+}
+
+inline SGVec2f Point3D::toSGVec2f(void) const
+{
+  return SGVec2f(x(), y());
+}
+
 // FRIENDS
 
 inline Point3D operator - (const Point3D& a)