]> git.mxchange.org Git - simgear.git/blobdiff - simgear/math/SGVec3.hxx
Add dist and distSqr functions
[simgear.git] / simgear / math / SGVec3.hxx
index 1d2a16277a92434f9f39b833934d75366c6532af..e6ea50aa8ec00d909953cfb2e36afba4f4675c40 100644 (file)
@@ -43,16 +43,6 @@ public:
   /// make sure it has at least 3 elements
   explicit SGVec3(const T* data)
   { _data[0] = data[0]; _data[1] = data[1]; _data[2] = data[2]; }
-  /// Constructor. Initialize by a geodetic coordinate
-  /// Note that this conversion is relatively expensive to compute
-  /// depricated
-  SGVec3(const SGGeod& geod)
-  { SGGeodesy::SGGeodToCart(geod, *this); }
-  /// Constructor. Initialize by a geocentric coordinate
-  /// Note that this conversion is relatively expensive to compute
-  /// depricated
-  SGVec3(const SGGeoc& geoc)
-  { SGGeodesy::SGGeocToCart(geoc, *this); }
 
   /// Access by index, the index is unchecked
   const T& operator()(unsigned i) const
@@ -306,6 +296,20 @@ equivalent(const SGVec3<T>& v1, const SGVec3<T>& v2)
   return equivalent(v1, v2, tol, tol);
 }
 
+/// The euclidean distance of the two vectors
+template<typename T>
+inline
+T
+dist(const SGVec3<T>& v1, const SGVec3<T>& v2)
+{ return norm(v1 - v2); }
+
+/// The squared euclidean distance of the two vectors
+template<typename T>
+inline
+T
+distSqr(const SGVec3<T>& v1, const SGVec3<T>& v2)
+{ SGVec3<T> tmp = v1 - v2; return dot(tmp, tmp); }
+
 #ifndef NDEBUG
 template<typename T>
 inline