Add dist and distSqr functions

This commit is contained in:
frohlich 2006-06-15 19:13:24 +00:00
parent 6d4f23919c
commit 52f57160aa
2 changed files with 28 additions and 0 deletions

View File

@ -296,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

View File

@ -248,6 +248,20 @@ equivalent(const SGVec4<T>& v1, const SGVec4<T>& v2)
return equivalent(v1, v2, tol, tol);
}
/// The euclidean distance of the two vectors
template<typename T>
inline
T
dist(const SGVec4<T>& v1, const SGVec4<T>& v2)
{ return norm(v1 - v2); }
/// The squared euclidean distance of the two vectors
template<typename T>
inline
T
distSqr(const SGVec4<T>& v1, const SGVec4<T>& v2)
{ SGVec4<T> tmp = v1 - v2; return dot(tmp, tmp); }
#ifndef NDEBUG
template<typename T>
inline