Salome HOME
update CDMATH
[tools/solverlab.git] / CDMATH / mesh / inc / Point.hxx
1 /*
2  * point.hxx
3  *
4  *  Created on: 23 janv. 2012
5  *      Authors: CDMAT
6  */
7
8 #ifndef POINT_HXX_
9 #define POINT_HXX_
10
11 #include <iostream>
12
13 /**
14  * Point class is defined by
15  * - The x-coordinate
16  * - The y-coordinate
17  * - The z-coordinate
18  */
19
20 class Point
21 {
22     public: //----------------------------------------------------------------
23       /**
24        * default constructor
25        */
26       Point ( void ) ;
27
28       /**
29        * constructor with data
30        * Create a point at (x, y, z)
31        * @param x : The x-coordinate
32        * @param y : The y-coordinate
33        * @param z : The z-coordinate
34        */
35       Point( const double x, const double y, const double z ) ;
36
37       /**
38        * constructor by copy
39        * @param p : The Point object to be copied
40       */
41       Point ( const Point & p ) ;
42
43       /**
44        * destructor
45        */
46       ~Point ( void ) ;
47
48      /**
49       * return address of coordinate in direction i
50       * @param i : Direction
51       * @return The address of coordinate in the given direction
52       */
53       double& operator[] ( int i ) ;
54
55      /**
56       * return x-coordinate
57       * @return x-coordinate
58       */
59       double x () const ;
60
61      /**
62       * return y-coordinate
63       * @return y-coordinate
64       */
65       double y () const ;
66
67      /**
68       * return z-coordinate
69       * @return z-coordinate
70       */
71       double z () const ;
72
73      /**
74       * return Compute sum of two points
75       * @param p : Point
76       * @return The Compute sum of two points
77       */
78       Point operator+ ( const Point& p ) const ;
79
80      /**
81       * return Compute difference of two points
82       * @param p : Point
83       * @return The Compute difference of two points
84       */
85       Point operator- ( const Point& p ) const ;
86
87      /**
88       * return Add given point
89       * @param p : Point
90       * @return Add given point
91       */
92       const Point& operator+= ( const Point& p ) ;
93
94      /**
95       * return Subtract given point
96       * @param p : Point
97       * @return Subtract given point
98       */
99       const Point& operator-= ( const Point& p ) ;
100
101      /**
102       * return Multiplication with scalar
103       * @param s : Scalar
104       * @return Multiplication with scalar
105       */
106       Point operator* ( double s ) const ;
107
108      /**
109       * return Incremental multiplication with scalar
110       * @param s : Scalar
111       * @return Incremental multiplication with scalar
112       */
113       const Point& operator*= ( double s ) ;
114
115      /**
116       * return Division with scalar
117       * @param s : Scalar
118       * @return Division with scalar
119       */
120       Point operator/ ( double s ) const ;
121
122      /**
123       * return Incremental Division with scalar
124       * @param s : Scalar
125       * @return Incremental Division with scalar
126       */
127       const Point& operator/= ( double s ) ;
128
129      /**
130       * return Assignment operator
131       * @param p : Point
132       * @return Assignment operator
133       */
134       const Point& operator= ( const Point& p ) ;
135
136      /**
137       * return Compute distance to given point
138       * @param p : Point
139       * @return The distance
140       */
141       double distance( const Point& p ) const ;
142
143      /**
144       * return Compute norm of point representing a vector from the origin
145       * @return The norm
146       */
147       double norm( void ) const ;
148
149      /**
150       * return Compute dot product with given vector
151       * @param p : Point
152       * @return The dot product with given vector
153       */
154       double dot(const Point& p) const;
155
156     private: //----------------------------------------------------------------
157       double _x[3] ;
158 };
159
160 #endif /* POINT_HXX_ */