/// 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
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