(9)

Point2D< T_ > Class Template Reference

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

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. More...
 
 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. More...
 
const T_ & operator() (size_t i) const
 Operator() : Constant version. More...
 
T_ & operator[] (size_t i)
 Operator[]: Non constant version. More...
 
const T_ & operator[] (size_t i) const
 Operator[] Constant version. More...
 
Point2D< T_ > & operator= (const Point2D< T_ > &p)
 Operator = More...
 
Point2D< T_ > & operator+= (const Point2D< T_ > &p)
 Operator += More...
 
Point2D< T_ > & operator-= (const Point2D< T_ > &p)
 Operator -= More...
 
Point2D< T_ > & operator= (const T_ &a)
 Operator = More...
 
Point2D< T_ > & operator+= (const T_ &a)
 Operator += More...
 
Point2D< T_ > & operator-= (const T_ &a)
 Operator -= More...
 
Point2D< T_ > & operator*= (const T_ &a)
 Operator *= More...
 
Point2D< T_ > & operator/= (const T_ &a)
 Operator /= More...
 
bool operator== (const Point2D< T_ > &p)
 Operator == More...
 
bool operator!= (const Point2D< T_ > &p)
 Operator != More...
 
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_tDirector (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()

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!=()

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

Operator !=

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

◆ operator()() [1/2]

T_& operator() ( size_t  i)

Operator() : Non constant version.

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

◆ operator()() [2/2]

const T_& operator() ( size_t  i) const

Operator() : Constant version.

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

◆ operator*=()

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

Operator *=

Multiply constant a by current instance coordinates

◆ operator+=() [1/2]

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

Operator +=

Add point p to current instance

◆ operator+=() [2/2]

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

Operator +=

Add constant a to current instance coordinates

◆ operator-=() [1/2]

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

Operator -=

Subtract point p from current instance

◆ operator-=() [2/2]

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

Operator -=

Subtract constant a from current instance coordinates

◆ operator/=()

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

Operator /=

Divide current instance coordinates by a

◆ operator=() [1/2]

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

Operator =

Assign point p to current instance

◆ operator=() [2/2]

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

Operator =

Assign constant a to current instance coordinates

◆ operator==()

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

Operator ==

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

◆ operator[]() [1/2]

T_& operator[] ( size_t  i)

Operator[]: Non constant version.

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

◆ operator[]() [2/2]

const T_& operator[] ( size_t  i) const

Operator[] Constant version.

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