71 return const_cast<T&
> (
static_cast<const TemplatePoint&
> (*this)[idx]);
82 virtual void write (std::ostream &os)
const
84 std::copy(
x_.cbegin(),
x_.cend(), std::ostream_iterator<T>(os,
" "));
88 virtual void read (std::istream &is)
90 std::copy(std::istream_iterator<T>(is), std::istream_iterator<T>(),
95 std::array<T, DIM>
x_;
98 template <
typename T, std::
size_t DIM>
102 template <
typename T, std::
size_t DIM>
108 template <
typename T, std::
size_t DIM>
111 T
const sqr_dist(
sqrDist(a,b));
112 auto const eps = std::numeric_limits<T>::epsilon();
113 return (sqr_dist < eps*eps);
116 template <
typename T, std::
size_t DIM>
119 for (std::size_t i = 0; i < DIM; ++i)
147 template <
typename T, std::
size_t DIM>
149 double eps = std::numeric_limits<double>::epsilon())
151 auto coordinateIsLargerEps = [&eps](T
const u, T
const v) ->
bool
153 return std::abs(u - v) > eps * std::min(std::abs(v), std::abs(u)) &&
154 std::abs(u - v) > eps;
157 for (std::size_t i = 0; i < DIM; ++i)
160 if (coordinateIsLargerEps(a[i], b[i]))
162 return static_cast<bool>(a[i] <= b[i]);
172 template <
typename T, std::
size_t DIM>
180 template <
typename T, std::
size_t DIM>
class-template for points can be instantiated by a numeric type.
virtual ~TemplatePoint()=default
virtual void write(std::ostream &os) const
TemplatePoint(TemplatePoint const &)=default
TemplatePoint(std::array< T, DIM > x)
const T * getCoords() const
TemplatePoint & operator=(TemplatePoint const &)=default
const T & operator[](std::size_t idx) const
const access operator The access to the point coordinates is like the access to a field....
virtual void read(std::istream &is)
void copy(PETScVector const &x, PETScVector &y)
bool operator==(TemplatePoint< T, DIM > const &a, TemplatePoint< T, DIM > const &b)
std::ostream & operator<<(std::ostream &os, const TemplatePoint< T, DIM > &p)
bool operator<(TemplatePoint< T, DIM > const &a, TemplatePoint< T, DIM > const &b)
std::istream & operator>>(std::istream &is, TemplatePoint< T, DIM > &p)
bool lessEq(TemplatePoint< T, DIM > const &a, TemplatePoint< T, DIM > const &b, double eps=std::numeric_limits< double >::epsilon())
double sqrDist(MathLib::Point3d const &p0, MathLib::Point3d const &p1)