Skip to content
Snippets Groups Projects
Commit 816d22f5 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[MaL] Move TemplatePoint functions.

... into TemplatePoint header file.
parent 80295ba2
No related branches found
No related tags found
No related merge requests found
......@@ -107,14 +107,6 @@ void crossProd (const double u[3], const double v[3], double r[3]);
double calcProjPntToLineAndDists(const double p[3], const double a[3],
const double b[3], double &lambda, double &d0);
template <typename T, std::size_t DIM>
bool operator==(TemplatePoint<T,DIM> const& a, TemplatePoint<T,DIM> const& b)
{
T const sqr_dist(sqrDist(a,b));
auto const eps = std::numeric_limits<T>::epsilon();
return (sqr_dist < eps*eps);
}
/// Computes the squared dist between the two points p0 and p1.
inline
double sqrDist(MathLib::Point3d const& p0, MathLib::Point3d const& p1)
......@@ -131,17 +123,6 @@ double sqrDist(const double* p0, const double* p1)
return scalarProduct<double,3>(v,v);
}
/** Distance between points p0 and p1 in the maximum norm. */
template <typename T>
T maxNormDist(const MathLib::TemplatePoint<T>* p0, const MathLib::TemplatePoint<T>* p1)
{
const T x = fabs((*p1)[0] - (*p0)[0]);
const T y = fabs((*p1)[1] - (*p0)[1]);
const T z = fabs((*p1)[2] - (*p0)[2]);
return std::max(x, std::max(y, z));
}
/**
* Let \f$p_0, p_1, p_2 \in R^3\f$. The function getAngle
* computes the angle between the edges \f$(p_0,p_1)\f$ and \f$(p_1,p_2)\f$
......
......@@ -101,6 +101,27 @@ TemplatePoint<T,DIM>::TemplatePoint(std::array<T,DIM> const& x) :
_x(x)
{}
/** Equality of TemplatePoint's up to an epsilon.
*/
template <typename T, std::size_t DIM>
bool operator==(TemplatePoint<T,DIM> const& a, TemplatePoint<T,DIM> const& b)
{
T const sqr_dist(sqrDist(a,b));
auto const eps = std::numeric_limits<T>::epsilon();
return (sqr_dist < eps*eps);
}
/** Distance between points p0 and p1 in the maximum norm. */
template <typename T>
T maxNormDist(const MathLib::TemplatePoint<T>* p0, const MathLib::TemplatePoint<T>* p1)
{
const T x = fabs((*p1)[0] - (*p0)[0]);
const T y = fabs((*p1)[1] - (*p0)[1]);
const T z = fabs((*p1)[2] - (*p0)[2]);
return std::max(x, std::max(y, z));
}
/** overload the output operator for class Point */
template <typename T, std::size_t DIM>
std::ostream& operator<< (std::ostream &os, const TemplatePoint<T,DIM> &p)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment