ScummVM API documentation
te_vector2s32.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef TETRAEDGE_TE_TE_VECTOR2S32_H
23 #define TETRAEDGE_TE_TE_VECTOR2S32_H
24 
25 #include "common/rect.h"
26 #include "common/stream.h"
27 #include "math/vector2d.h"
28 
29 namespace Tetraedge {
30 
31 class TeVector2s32 {
32 public:
33  TeVector2s32();
34  TeVector2s32(int x_, int y_) : _x(x_), _y(y_) {};
35  TeVector2s32(const Common::Point &pt) : _x(pt.x), _y(pt.y) {};
36  explicit TeVector2s32(const Math::Vector2d &pt) : _x(pt.getX()), _y(pt.getY()) {};
37 
38  bool operator!=(const TeVector2s32 &other) const {
39  return _x != other._x || _y != other._y;
40  }
41  bool operator==(const TeVector2s32 &other) const {
42  return _x == other._x && _y == other._y;
43  }
44 
45  TeVector2s32 &operator+=(const TeVector2s32 &other) {
46  _x += other._x;
47  _y += other._y;
48  return *this;
49  }
50 
51  TeVector2s32 operator-(const TeVector2s32 &other) {
52  return TeVector2s32(_x - other._x, _y - other._y);
53  }
54 
55  int64 squaredLength() const {
56  return (int64)_x * _x + (int64)_y * _y;
57  }
58 
59  static void deserialize(Common::ReadStream &stream, TeVector2s32 &dest);
60 
61 public:
62  int _x;
63  int _y;
64 
65 };
66 
67 TeVector2s32 operator+(const TeVector2s32 &left, const TeVector2s32 &right);
68 
69 } // end namespace Tetraedge
70 
71 #endif // TETRAEDGE_TE_TE_VECTOR2S32_H
Definition: detection.h:27
Definition: rect.h:45
int16 x
Definition: rect.h:46
Definition: te_vector2s32.h:31
int16 y
Definition: rect.h:47
Definition: stream.h:385