CoastalME (Coastal Modelling Environment)
Simulates the long-term behaviour of complex coastlines
Loading...
Searching...
No Matches
2di_point.cpp
Go to the documentation of this file.
1
12
13/* ===============================================================================================================================
14
15 This file is part of CoastalME, the Coastal Modelling Environment.
16
17 CoastalME 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.
18
19 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.
20
21 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.
22
23===============================================================================================================================*/
24#include "2di_point.h"
25#include "cme.h"
26
29 : nX(0),
30 nY(0)
31{
32}
33
36 : nX(pPti->nGetX()),
37 nY(pPti->nGetY())
38{
39}
40
42CGeom2DIPoint::CGeom2DIPoint(int const nNewX, int const nNewY)
43 : nX(nNewX),
44 nY(nNewY)
45{
46}
47
49int CGeom2DIPoint::nGetX(void) const
50{
51 return nX;
52}
53
55int CGeom2DIPoint::nGetY(void) const
56{
57 return nY;
58}
59
62{
63 return &nX;
64}
65
68{
69 return &nY;
70}
71
73void CGeom2DIPoint::SetX(int const nNewX)
74{
75 nX = nNewX;
76}
77
79void CGeom2DIPoint::SetY(int const nNewY)
80{
81 nY = nNewY;
82}
83
85void CGeom2DIPoint::SetXY(int const nNewX, int const nNewY)
86{
87 nX = nNewX;
88 nY = nNewY;
89}
90
92// void CGeom2DIPoint::SetXY(CGeom2DIPoint const* Pti)
93// {
94// nX = Pti->nGetX();
95// nY = Pti->nGetY();
96// }
97
99void CGeom2DIPoint::AddXAddY(int const nXToAdd, int const nYToAdd)
100{
101 nX += nXToAdd;
102 nY += nYToAdd;
103}
104
106void CGeom2DIPoint::AddXAddY(double const dXToAdd, double const dYToAdd)
107{
108 nX += nRound(dXToAdd);
109 nY += nRound(dYToAdd);
110}
111
113void CGeom2DIPoint::DivXDivY(double const dXDiv, double const dYDiv)
114{
115 int const nXDiv = nRound(dXDiv);
116 int const nYDiv = nRound(dYDiv);
117
118 // Check for zero division
119 if (nXDiv != 0)
120 nX /= nXDiv;
121
122 if (nYDiv != 0)
123 nY /= nYDiv;
124}
125
128{
129 nX = pPti->nGetX();
130 nY = pPti->nGetY();
131 return *this;
132}
133
136{
137 if ((pPti->nGetX() == nX) && (pPti->nGetY() == nY))
138 return true;
139
140 return false;
141}
142
145{
146 if ((Pti.nGetX() == nX) && (Pti.nGetY() == nY))
147 return true;
148
149 return false;
150}
151
154{
155 if ((pPti->nGetX() != nX) || (pPti->nGetY() != nY))
156 return true;
157
158 return false;
159}
160
163{
164 if ((Pti.nGetX() != nX) || (Pti.nGetY() != nY))
165 return true;
166
167 return false;
168}
Contains CGeom2DIPoint definitions.
CGeom2DIPoint(void)
Constructor with no parameters (the X and Y coordinates of the new CGeom2DIPoint object are set to ze...
Definition 2di_point.cpp:28
bool operator!=(CGeom2DIPoint const *) const
Compares two CGeom2DIPoint objects for inequality.
void SetY(int const)
The integer parameter sets a value for the CGeom2DIPoint object's Y coordinate.
Definition 2di_point.cpp:79
int nGetY(void) const
Returns the CGeom2DIPoint object's integer Y coordinate.
Definition 2di_point.cpp:55
int nY
The integer y coordinate.
Definition 2di_point.h:35
void SetXY(int const, int const)
The two integer parameters set values for the CGeom2DIPoint object's X and Y coordinates.
Definition 2di_point.cpp:85
bool operator==(CGeom2DIPoint const *) const
Compares two CGeom2DIPoint objects for equality.
void DivXDivY(double const, double const)
Divides the CGeom2DIPoint object's X coordinate by the first double parameter (rounded),...
void SetX(int const)
The integer parameter sets a value for the CGeom2DIPoint object's X coordinate.
Definition 2di_point.cpp:73
CGeom2DIPoint & operator=(CGeom2DIPoint const *)
Sets one CGeom2DIPoint object to be the same as another.
int * pnGetY()
Returns a reference to the CGeom2DIPoint object's integer Y coordinate.
Definition 2di_point.cpp:67
void AddXAddY(int const, int const)
The parameter is a pointer to a CGeom2DIPoint object, this is used to set values for the CGeom2DIPoin...
Definition 2di_point.cpp:99
int * pnGetX()
Returns a reference to the CGeom2DIPoint object's integer X coordinate.
Definition 2di_point.cpp:61
int nGetX(void) const
Returns the CGeom2DIPoint object's integer X coordinate.
Definition 2di_point.cpp:49
int nX
The integer x coordinate.
Definition 2di_point.h:32
This file contains global definitions for CoastalME.
int nRound(double const d)
Version of the above that returns an int.