1 /*!
2  *
3  * \file 2d_point.cpp
4  * \brief Class used to represent 2D point objects with floating-point co-ordinates
5  * \details The C2DPoint class is used to represent 2D points where the x and y co-ordinates are floating-point values, e.g. points for which the x and y co-ordinates are in the external CRS (co-ordinate reference system)
6  * \author David Favis-Mortlock
7  * \author Andres Payo
8  * \author Jim Hall
9  * \date 2017
10  * \copyright GNU General Public License
11  *
12  */
13 
14 /*===============================================================================================================================
15 
16  This file is part of CliffMetrics, the Coastal Modelling Environment.
17 
18  CliffMetrics is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
19 
20  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 
24 ===============================================================================================================================*/
25 #include "cliffmetrics.h"
26 #include "2d_point.h"
27 
28 
C2DPoint(void)29 C2DPoint::C2DPoint(void)
30 :  dX(0),
31    dY(0)
32 {
33 }
34 
C2DPoint(double const dNewX,double const dNewY)35 C2DPoint::C2DPoint(double const dNewX, double const dNewY)
36 :  dX(dNewX),
37    dY(dNewY)
38 {
39 }
40 
41 
dGetX(void) const42 double C2DPoint::dGetX(void) const
43 {
44    return dX;
45 }
46 
dGetY(void) const47 double C2DPoint::dGetY(void) const
48 {
49    return dY;
50 }
51 
SetX(double const dNewX)52 void C2DPoint::SetX(double const dNewX)
53 {
54    dX = dNewX;
55 }
56 
SetY(double const dNewY)57 void C2DPoint::SetY(double const dNewY)
58 {
59    dY = dNewY;
60 }
61 
62 // void C2DPoint::SetXY(double const dNewX, double const dNewY)
63 // {
64 //    dX = dNewX;
65 //    dY = dNewY;
66 // }
67 
68 // void C2DPoint::SetXY(C2DPoint const* Pt)
69 // {
70 //    dX = Pt->dGetX();
71 //    dY = Pt->dGetY();
72 // }
73 
74 //! Sets one C2DPoint object equal to another
operator =(C2DPoint * pPt)75 void C2DPoint::operator= (C2DPoint* pPt)
76 {
77    dX = pPt->dGetX();
78    dY = pPt->dGetY();
79 }
80 
81 // //! Compares two C2DPoint objects for equality
82 // bool C2DPoint::operator== (C2DPoint* pPt) const
83 // {
84 //    if ((pPt->dGetX() == dX) && (pPt->dGetY() == dY))
85 //       return true;
86 //
87 //    return false;
88 // }
89 
90 //! Compares two C2DPoint objects for equality
operator ==(C2DPoint * pPt) const91 bool C2DPoint::operator== (C2DPoint* pPt) const
92 {
93    if ((pPt->dGetX() == dX) && (pPt->dGetY() == dY))
94       return true;
95 
96    return false;
97 }
98 
99 //! Compares two C2DPoint objects for inequality
operator !=(C2DPoint * pPt) const100 bool C2DPoint::operator!= (C2DPoint* pPt) const
101 {
102    if ((pPt->dGetX() == dX) && (pPt->dGetY() == dY))
103       return false;
104 
105    return true;
106 }
107