Loading...
Searching...
No Matches
point

d-dimensional physical point or vector

# Description

The point defines a vertex or vector in the physical d-dimensional space, d=1,2,3. It is represented as an array of coordinates. The coordinate index starts at zero and finishes at d-1, e.g. x[0], x[1] and x[2].

The default constructor set all components to zero:

        point x;

and this default could be overridden:

        point x (1, 2, 3.14);

or alternatively:

        point x = {1, 2, 3.14};

The standard linear algebra for vectors is supported by the point class.

# Implementation

This documentation has been generated from file fem/geo_element/point.h

The point class is simply an alias to the point_basic class

typedef point_basic<Float> point;

The point_basic class is a template class with the floating type as parameter:

template <class T>
class point_basic {
public:
// typedefs:
typedef size_t size_type;
typedef T element_type;
typedef T scalar_type;
typedef T float_type;
// allocators:
explicit point_basic();
explicit point_basic (const T& x0, const T& x1 = 0, const T& x2 = 0);
template <class T1>
point_basic<T>(const point_basic<T1>& p);
template <class T1>
point_basic<T>& operator= (const point_basic<T1>& p);
point_basic (const std::initializer_list<T>& il);
// accessors:
T& operator[](int i_coord) { return _x[i_coord%3]; }
T& operator()(int i_coord) { return _x[i_coord%3]; }
const T& operator[](int i_coord) const { return _x[i_coord%3]; }
const T& operator()(int i_coord) const { return _x[i_coord%3]; }
// algebra:
bool operator== (const point_basic<T>& v) const;
bool operator!= (const point_basic<T>& v) const;
point_basic<T> operator+ (const point_basic<T>& v) const;
point_basic<T> operator- (const point_basic<T>& v) const;
point_basic<T> operator- () const;
point_basic<T>& operator+= (const point_basic<T>& v);
point_basic<T>& operator-= (const point_basic<T>& v);
point_basic<T>& operator*= (const T& a);
point_basic<T>& operator/= (const T& a);
template <class U>
typename
std::enable_if<
details::is_rheolef_arithmetic<U>::value
,point_basic<T>
>::type
operator* (const U& a) const;
point_basic<T> operator/ (const T& a) const;
point_basic<T> operator/ (point_basic<T> v) const;
// i/o:
std::istream& get (std::istream& s, int d = 3);
std::ostream& put (std::ostream& s, int d = 3) const;
};

These linear and nonlinear functions are completed by some usual functions:

template<class T>
std::istream& operator >> (std::istream& s, point_basic<T>& p);
template<class T>
std::ostream& operator << (std::ostream& s, const point_basic<T>& p);
template <class T, class U>
typename
std::enable_if<
details::is_rheolef_arithmetic<U>::value
,point_basic<T>
>::type
operator* (const U& a, const point_basic<T>& u);
template<class T>
point_basic<T>
vect (const point_basic<T>& v, const point_basic<T>& w);
// metrics:
template<class T>
T dot (const point_basic<T>& x, const point_basic<T>& y);
template<class T>
T norm2 (const point_basic<T>& x);
template<class T>
T norm (const point_basic<T>& x);
template<class T>
T dist2 (const point_basic<T>& x, const point_basic<T>& y);
template<class T>
T dist (const point_basic<T>& x, const point_basic<T>& y);
template<class T>
T dist_infty (const point_basic<T>& x, const point_basic<T>& y);
template <class T>
T vect2d (const point_basic<T>& v, const point_basic<T>& w);
template <class T>
T mixt (const point_basic<T>& u, const point_basic<T>& v, const point_basic<T>& w);
// robust(exact) floating point predicates: return the sign of the value as (0, > 0, < 0)
// formally: orient2d(a,b,x) = vect2d(a-x,b-x)
template <class T>
int sign_orient2d (
const point_basic<T>& a,
const point_basic<T>& b,
const point_basic<T>& c);
template <class T>
int sign_orient3d (
const point_basic<T>& a,
const point_basic<T>& b,
const point_basic<T>& c,
const point_basic<T>& d);
// compute also the value:
template <class T>
T orient2d(
const point_basic<T>& a,
const point_basic<T>& b,
const point_basic<T>& c);
// formally: orient3d(a,b,c,x) = mixt3d(a-x,b-x,c-x)
template <class T>
T orient3d(
const point_basic<T>& a,
const point_basic<T>& b,
const point_basic<T>& c,
const point_basic<T>& d);
template <class T>
std::string ptos (const point_basic<T>& x, int d = 3);
// ccomparators: lexicographic order
template<class T, size_t d>
bool lexicographically_less (const point_basic<T>& a, const point_basic<T>& b);