Point2D< T_ > Class Template Reference

Defines a 2-D point with arbitrary type coordinates. More...

#include <Point2D.h>

Public Member Functions

 Point2D ()
 Default constructor.
 
 Point2D (T_ a, T_ b=T_(0))
 Constructor that assigns a, b to x-, y- and y-coordinates respectively.
 
 Point2D (T_ *a)
 Initialize point coordinates with C-array a.
 
 Point2D (const Point2D< T_ > &pt)
 Copy constructor.
 
 Point2D (const Point< T_ > &pt)
 Copy constructor from class Point.
 
T_ & operator() (size_t i)
 Operator() : Non constant version.
 
const T_ & operator() (size_t i) const
 Operator() : Constant version.
 
T_ & operator[] (size_t i)
 Operator[]: Non constant version.
 
const T_ & operator[] (size_t i) const
 Operator[] Constant version.
 
Point2D< T_ > & operator= (const Point2D< T_ > &p)
 Operator =
 
Point2D< T_ > & operator+= (const Point2D< T_ > &p)
 Operator +=
 
Point2D< T_ > & operator-= (const Point2D< T_ > &p)
 Operator -=
 
Point2D< T_ > & operator= (const T_ &a)
 Operator =
 
Point2D< T_ > & operator+= (const T_ &a)
 Operator +=
 
Point2D< T_ > & operator-= (const T_ &a)
 Operator -=
 
Point2D< T_ > & operator*= (const T_ &a)
 Operator *=
 
Point2D< T_ > & operator/= (const T_ &a)
 Operator /=
 
bool operator== (const Point2D< T_ > &p)
 Operator ==
 
bool operator!= (const Point2D< T_ > &p)
 Operator !=
 
real_t CrossProduct (const Point2D< real_t > &lp, const Point2D< real_t > &rp)
 Return Cross product of two vectors lp and rp
 
real_t NNorm () const
 Return squared norm (length) of vector.
 
real_t Norm () const
 Return norm (length) of vector.
 
Point2D< real_t > Director (const Point2D< real_t > &p) const
 Return Director (Normalized vector)
 
bool isCloseTo (const Point2D< real_t > &a, real_t toler=OFELI_TOLERANCE) const
 Return true if current point is close to instance a (up to tolerance toler)
 

Public Attributes

T_ x
 First coordinate of point.
 
T_ y
 Second coordinate of point.
 

Detailed Description

template<class T_>
class OFELI::Point2D< T_ >

Defines a 2-D point with arbitrary type coordinates.

Operators = and () are overloaded. The actual

Template Parameters
T_Data type (double, float, complex<double>, ...)
Author
Rachid Touzani

Constructor & Destructor Documentation

◆ Point2D()

template<class T_ >
Point2D ( T_  a,
T_  b = T_(0) 
)

Constructor that assigns a, b to x-, y- and y-coordinates respectively.

Default value for b is 0

Member Function Documentation

◆ operator!=()

template<class T_ >
bool operator!= ( const Point2D< T_ > &  p)

Operator !=

Return false if current instance is equal to p, true otherwise.

◆ operator()() [1/2]

template<class T_ >
T_ & operator() ( size_t  i)

Operator() : Non constant version.

Values i = 1,2 correspond to x and y respectively

◆ operator()() [2/2]

template<class T_ >
const T_ & operator() ( size_t  i) const

Operator() : Constant version.

Values i=1,2 correspond to x and y respectively

◆ operator*=()

template<class T_ >
Point2D< T_ > & operator*= ( const T_ &  a)

Operator *=

Multiply constant a by current instance coordinates

◆ operator+=() [1/2]

template<class T_ >
Point2D< T_ > & operator+= ( const Point2D< T_ > &  p)

Operator +=

Add point p to current instance

◆ operator+=() [2/2]

template<class T_ >
Point2D< T_ > & operator+= ( const T_ &  a)

Operator +=

Add constant a to current instance coordinates

◆ operator-=() [1/2]

template<class T_ >
Point2D< T_ > & operator-= ( const Point2D< T_ > &  p)

Operator -=

Subtract point p from current instance

◆ operator-=() [2/2]

template<class T_ >
Point2D< T_ > & operator-= ( const T_ &  a)

Operator -=

Subtract constant a from current instance coordinates

◆ operator/=()

template<class T_ >
Point2D< T_ > & operator/= ( const T_ &  a)

Operator /=

Divide current instance coordinates by a

◆ operator=() [1/2]

template<class T_ >
Point2D< T_ > & operator= ( const Point2D< T_ > &  p)

Operator =

Assign point p to current instance

◆ operator=() [2/2]

template<class T_ >
Point2D< T_ > & operator= ( const T_ &  a)

Operator =

Assign constant a to current instance coordinates

◆ operator==()

template<class T_ >
bool operator== ( const Point2D< T_ > &  p)

Operator ==

Return true if current instance is equal to p, false otherwise.

◆ operator[]() [1/2]

template<class T_ >
T_ & operator[] ( size_t  i)

Operator[]: Non constant version.

Values i=0,1 correspond to x and y respectively

◆ operator[]() [2/2]

template<class T_ >
const T_ & operator[] ( size_t  i) const

Operator[] Constant version.

Values i=0,1 correspond to x and y respectively