We are working with signed long (made this explicit) so use fromLong instead of fromInt.
[UnsignedByte.git] / src / Resource / Coordinate.h
blobdc3506a257781d5ec84bb81d64be087c9f667136
1 /***************************************************************************
2 * Copyright (C) 2007 by Daniel Brody *
3 * erasnode@gmail.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #pragma once
23 /**
24 * @file Coordinate.h
25 * This file contains the Coordinate class.
27 * @see Coordinate
28 */
30 #include "Types.h"
32 /**
33 * This file is an 'enumeration' class with all the directions.
34 */
35 class Coordinate
37 public:
38 static Coordinate NORTH; /**< The 'north' coordinate. */
39 static Coordinate NUP; /**< The 'north up' coordinate. */
40 static Coordinate NDOWN; /**< The 'north down' coordinate. */
42 static Coordinate SOUTH; /**< The 'south' coordinate. */
43 static Coordinate SUP; /**< The 'south up' coordinate. */
44 static Coordinate SDOWN; /**< The 'south down' coordinate. */
46 static Coordinate EAST; /**< The 'east' coordinate. */
47 static Coordinate EUP; /**< The 'east up' coordinate. */
48 static Coordinate EDOWN; /**< The 'east down' coordinate. */
50 static Coordinate WEST; /**< The 'west' coordinate. */
51 static Coordinate WUP; /**< The 'west up' coordinate. */
52 static Coordinate WDOWN; /**< The 'west down' coordinate. */
54 static Coordinate NW; /**< The 'northwest' coordinate. */
55 static Coordinate NWUP; /**< The 'northwest up' coordinate. */
56 static Coordinate NWDOWN; /**< The 'northwest down' coordinate. */
58 static Coordinate NE; /**< The 'northeast' coordinate. */
59 static Coordinate NEUP; /**< The 'northeast up' coordinate. */
60 static Coordinate NEDOWN; /**< The 'northeast down' coordinate. */
62 static Coordinate SW; /**< The 'southwest' coordinate. */
63 static Coordinate SWUP; /**< The 'southwest up' coordinate. */
64 static Coordinate SWDOWN; /**< The 'southwest down' coordinate. */
66 static Coordinate SE; /**< The 'southeast' coordinate. */
67 static Coordinate SEUP; /**< The 'southeast up' coordinate. */
68 static Coordinate SEDOWN; /**< The 'southeast down' coordinate. */
70 static Coordinate UP; /**< The 'up' coordinate. */
71 static Coordinate DOWN; /**< The 'down' coordinate. */
73 /**
74 * Specialized constructor
76 * @param X initial X coordinate
77 * @param Y initial Y coordinate
78 * @param Z initial Z coordinate
80 Coordinate(signed long X, signed long Y, signed long Z);
82 /**
83 * Copy Constructor
85 * @param rhs Copy from
87 Coordinate(const Coordinate& rhs);
89 /**
90 * Default destructor
92 ~Coordinate();
94 /**
95 * Overloaded addition operator
97 * @param rhs Coordinate to be added
98 * @return this+rhs
100 Coordinate operator+= (const Coordinate& rhs);
103 * Overloaded addition operator
105 * @param rhs Coordinate to be added
106 * @return this+rhs
108 Coordinate operator+ (const Coordinate & rhs) const;
111 * Overloaded substraction operator
113 * @param rhs Coordinate to be substracted
114 * @return this-rhs
116 Coordinate operator-= (const Coordinate & rhs);
119 * Overloaded substraction operator
121 * @param rhs Coordinate to be substracted
122 * @return this-rhs
124 Coordinate operator- (const Coordinate & rhs) const;
127 * Getter
129 * @return X coordinate
131 signed long getXCoordinate() const;
134 * Getter
136 * @return Y Coordinate
138 signed long getYCoordinate() const;
141 * Getter
143 * @return Z coordinate
145 signed long getZCoordinate() const;
149 * Returns whether this coordinate represents a direction (abs(x,y,z) <= 1).
151 * @return Whether this coordinate satisfies "-1 <= i <= 1" for i={x,y,z}.
153 bool isDirection() const;
155 /** Returns a string representation of this coordinate, */
156 std::string toString() const;
158 /** Returns the direction name of this coordinate if it is one. */
159 std::string toDirectionString() const;
161 private:
163 * Hide default constructor
165 Coordinate() {};
167 signed long m_xcoordinate;
168 signed long m_ycoordinate;
169 signed long m_zcoordinate;
172 typedef std::vector<Coordinate> Coordinates; /**< The type of multiple Coordinates. */