Flumy [Free API]
Process based model for meandering chanelized systems
Point2D.hpp
1 #ifndef POINT_2D_HH
2 #define POINT_2D_HH
3 
4 #include "MCRCProgramming.hpp"
5 #include "flumy_export.hpp"
6 
13 class FLUMY_EXPORT Point2D {
14 
15 public :
16 
18  Point2D ( const MP_real & x = 0. , const MP_real & y = 0. ) ;
20  Point2D ( const Point2D & ) ;
22  virtual ~Point2D () ;
23 
25  MP_real distance ( const Point2D & ) const ;
27  Point2D & transform ( const Point2D & translate,
28  const Point2D & dilate,
29  bool do_round = false ) ;
30 
32  MP_real scalar ( const Point2D & ) const ;
34  MP_real vectorial ( const Point2D & ) const ;
36  Point2D & reset ( const MP_real & x = 0. , const MP_real & y = 0. ) ;
42  Point2D & rotate ( const Point2D& center, const MP_real& angle ) ;
44  Point2D & rotate ( const Point2D& center, const MP_real& cosinus, const MP_real& sinus) ;
46  Point2D & rotate_inv ( const Point2D& center, const MP_real& angle ) ;
48  Point2D & rotate_inv ( const Point2D& center, const MP_real& cosinus, const MP_real& sinus) ;
50  Point2D & operator = ( const Point2D & ) ;
52  Point2D & operator += ( const Point2D & ) ;
54  Point2D & operator -= ( const Point2D & ) ;
56  Point2D & operator *= ( const MP_real & ) ;
58  Point2D & operator /= ( const MP_real & ) ;
59 
61  bool operator == ( const Point2D & ) const ;
63  bool operator != ( const Point2D & ) const ;
64 
65 #ifndef SWIG
67  friend Point2D operator - ( const Point2D & ) ;
68 
70  friend Point2D operator + ( const Point2D & , const Point2D & ) ;
72  friend Point2D operator - ( const Point2D & , const Point2D & ) ;
74  friend Point2D operator * ( const Point2D & , const Point2D & ) ;
76  friend Point2D operator * ( const MP_real & , const Point2D & ) ;
78  friend Point2D operator * ( const Point2D & , const MP_real & ) ;
80  friend Point2D operator / ( const Point2D & , const Point2D & ) ;
82  friend Point2D operator / ( const MP_real & , const Point2D & ) ;
84  friend Point2D operator / ( const Point2D & , const MP_real & ) ;
85 #endif
86 
88  friend MP_real sqnorm ( const Point2D & ) ;
90  friend MP_real lgth ( const Point2D & ) ;
92  friend MP_real arc_tan ( const Point2D & ) ;
93 
95  inline MP_real get_abscissa ( ) const { return _x ; }
97  inline void set_abscissa ( MP_real x ) { _x = x ; }
99  inline MP_real get_ordinate ( ) const { return _y ; }
101  inline void set_ordinate ( MP_real y ) { _y = y ;}
102 
104  MP_string debug() const;
105 
106 #ifndef SWIG
108  friend std::ostream & operator << ( std::ostream & , const Point2D & ) ;
110  friend std::istream & operator >> ( std::istream & , Point2D & ) ;
111 #endif
112 
113 protected :
115  MP_real _x;
117  MP_real _y;
118 };
119 
120 #endif /* POINT_2D_HH */
Storage class for 2D points.
Definition: Point2D.hpp:13
MP_real scalar(const Point2D &) const
Return the scalar product (_x*x + _y*y) between current point and given point reference.
Point2D & rotate_half_pi()
Rotate 90° current point anticlockwise.
MP_real get_ordinate() const
Assessors get to the _y protected member variable.
Definition: Point2D.hpp:99
Point2D & rotate_pi()
Rotate 180° current point anticlockwise.
Point2D(const MP_real &x=0., const MP_real &y=0.)
Default constructor.
Point2D(const Point2D &)
Copy constructor.
MP_real _y
Point ordinate.
Definition: Point2D.hpp:117
Point2D & rotate(const Point2D &center, const MP_real &cosinus, const MP_real &sinus)
Rotate a point around a center given the cosinus and the sinus of the angle.
MP_real get_abscissa() const
Assessors get to the _x protected member variable.
Definition: Point2D.hpp:95
MP_string debug() const
Get debug information.
MP_real _x
Point abscissa.
Definition: Point2D.hpp:115
virtual ~Point2D()
Destructor.
Point2D & transform(const Point2D &translate, const Point2D &dilate, bool do_round=false)
Return new point dilated.
Point2D & reset(const MP_real &x=0., const MP_real &y=0.)
Reset current point coordinates to new values.
MP_real vectorial(const Point2D &) const
Return the vectorial product (_x*y - _y*x) between current point and given point reference.
friend MP_real sqnorm(const Point2D &)
Return the square norm of segment between origin and given point.
friend MP_real arc_tan(const Point2D &)
Return the arc tangante between origin and given point.
MP_real distance(const Point2D &) const
Return distance between current point and given point reference.
void set_abscissa(MP_real x)
Assessors set to the _x protected member variable.
Definition: Point2D.hpp:97
Point2D & rotate(const Point2D &center, const MP_real &angle)
Rotate a point around a center (angle in radian)
void set_ordinate(MP_real y)
Assessors set to the _y protected member variable.
Definition: Point2D.hpp:101
friend MP_real lgth(const Point2D &)
Return the distance of the segment between origin and given point.
Point2D & rotate_inv(const Point2D &center, const MP_real &cosinus, const MP_real &sinus)
Inverse rotate a point around a center given the cosinus and the sinus of the angle.
Point2D & rotate_inv(const Point2D &center, const MP_real &angle)
Inverse rotate a point around a center (angle in radian)