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
10
11/* ===============================================================================================================================
12 This file is part of CoastalME, the Coastal Modelling Environment.
13
14 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.
15
16 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.
17
18 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.
19===============================================================================================================================*/
20#include "2di_point.h"
21#include "cme.h"
22
25 : nX(0),
26 nY(0)
27{
28}
29
32 : nX(pPti->nGetX()),
33 nY(pPti->nGetY())
34{
35}
36
38CGeom2DIPoint::CGeom2DIPoint(int const nNewX, int const nNewY)
39 : nX(nNewX),
40 nY(nNewY)
41{
42}
43
45int CGeom2DIPoint::nGetX(void) const
46{
47 return nX;
48}
49
51int CGeom2DIPoint::nGetY(void) const
52{
53 return nY;
54}
55
58{
59 return &nX;
60}
61
64{
65 return &nY;
66}
67
69void CGeom2DIPoint::SetX(int const nNewX)
70{
71 nX = nNewX;
72}
73
75void CGeom2DIPoint::SetY(int const nNewY)
76{
77 nY = nNewY;
78}
79
81void CGeom2DIPoint::SetXY(int const nNewX, int const nNewY)
82{
83 nX = nNewX;
84 nY = nNewY;
85}
86
88// void CGeom2DIPoint::SetXY(CGeom2DIPoint const* Pti)
89// {
90// nX = Pti->nGetX();
91// nY = Pti->nGetY();
92// }
93
95void CGeom2DIPoint::AddXAddY(int const nXToAdd, int const nYToAdd)
96{
97 nX += nXToAdd;
98 nY += nYToAdd;
99}
100
102void CGeom2DIPoint::AddXAddY(double const dXToAdd, double const dYToAdd)
103{
104 nX += nRound(dXToAdd);
105 nY += nRound(dYToAdd);
106}
107
109void CGeom2DIPoint::DivXDivY(double const dXDiv, double const dYDiv)
110{
111 int const nXDiv = nRound(dXDiv);
112 int const nYDiv = nRound(dYDiv);
113
114 // Check for zero division
115 if (nXDiv != 0)
116 nX /= nXDiv;
117
118 if (nYDiv != 0)
119 nY /= nYDiv;
120}
121
124{
125 nX = pPti->nGetX();
126 nY = pPti->nGetY();
127 return *this;
128}
129
132{
133 if ((pPti->nGetX() == nX) && (pPti->nGetY() == nY))
134 return true;
135
136 return false;
137}
138
141{
142 if ((Pti.nGetX() == nX) && (Pti.nGetY() == nY))
143 return true;
144
145 return false;
146}
147
150{
151 if ((pPti->nGetX() != nX) || (pPti->nGetY() != nY))
152 return true;
153
154 return false;
155}
156
159{
160 if ((Pti.nGetX() != nX) || (Pti.nGetY() != nY))
161 return true;
162
163 return false;
164}
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:24
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:75
int nGetY(void) const
Returns the CGeom2DIPoint object's integer Y coordinate.
Definition 2di_point.cpp:51
int nY
The integer y coordinate.
Definition 2di_point.h:31
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:81
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:69
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:63
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:95
int * pnGetX()
Returns a reference to the CGeom2DIPoint object's integer X coordinate.
Definition 2di_point.cpp:57
int nGetX(void) const
Returns the CGeom2DIPoint object's integer X coordinate.
Definition 2di_point.cpp:45
int nX
The integer x coordinate.
Definition 2di_point.h:28
This file contains global definitions for CoastalME.
int nRound(double const d)
Correctly rounds doubles, returns an int.