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
15This file is part of CoastalME, the Coastal Modelling Environment.
16
17CoastalME 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
19This 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
21You 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
35CGeom2DIPoint::CGeom2DIPoint(int const nNewX, int const nNewY)
36: nX(nNewX),
37 nY(nNewY)
38{
39}
40
42int CGeom2DIPoint::nGetX(void) const
43{
44 return nX;
45}
46
48int CGeom2DIPoint::nGetY(void) const
49{
50 return nY;
51}
52
55{
56 return &nX;
57}
58
61{
62 return &nY;
63}
64
66void CGeom2DIPoint::SetX(int const nNewX)
67{
68 nX = nNewX;
69}
70
72void CGeom2DIPoint::SetY(int const nNewY)
73{
74 nY = nNewY;
75}
76
78void CGeom2DIPoint::SetXY(int const nNewX, int const nNewY)
79{
80 nX = nNewX;
81 nY = nNewY;
82}
83
85// void CGeom2DIPoint::SetXY(CGeom2DIPoint const* Pti)
86// {
87// nX = Pti->nGetX();
88// nY = Pti->nGetY();
89// }
90
92void CGeom2DIPoint::AddXAddY(int const nXToAdd, int const nYToAdd)
93{
94 nX += nXToAdd;
95 nY += nYToAdd;
96}
97
99void CGeom2DIPoint::AddXAddY(double const dXToAdd, double const dYToAdd)
100{
101 nX += nRound(dXToAdd);
102 nY += nRound(dYToAdd);
103}
104
106void CGeom2DIPoint::DivXDivY(double const dXDiv, double const dYDiv)
107{
108 int
109 nXDiv = nRound(dXDiv),
110 nYDiv = nRound(dYDiv);
111
112 // Check for zero division
113 if (nXDiv != 0)
114 nX /= nXDiv;
115
116 if (nYDiv != 0)
117 nY /= nYDiv;
118}
119
122{
123 nX = pPti->nGetX();
124 nY = pPti->nGetY();
125}
126
129{
130 if ((pPti->nGetX() == nX) && (pPti->nGetY() == nY))
131 return true;
132
133 return false;
134}
135
138{
139 if ((Pti.nGetX() == nX) && (Pti.nGetY() == nY))
140 return true;
141
142 return false;
143}
144
147{
148 if ((pPti->nGetX() != nX) || (pPti->nGetY() != nY))
149 return true;
150
151 return false;
152}
153
156{
157 if ((Pti.nGetX() != nX) || (Pti.nGetY() != nY))
158 return true;
159
160 return false;
161}
Contains CGeom2DIPoint definitions.
CGeom2DIPoint(void)
Constructor with no parameters (the X and Y coordinates of the CGeom2DIPoint object are set to zero i...
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:72
int nGetY(void) const
Returns the CGeom2DIPoint object's integer Y coordinate.
Definition 2di_point.cpp:48
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:78
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:66
void 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:60
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:92
int * pnGetX()
Returns a reference to the CGeom2DIPoint object's integer X coordinate.
Definition 2di_point.cpp:54
int nGetX(void) const
Returns the CGeom2DIPoint object's integer X coordinate.
Definition 2di_point.cpp:42
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.