ScummVM API documentation
fvector.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 TITANIC_FVECTOR_H
23 #define TITANIC_FVECTOR_H
24 
25 #include "titanic/star_control/fpoint.h"
26 
27 namespace Titanic {
28 
29 enum Axis { X_AXIS, Y_AXIS, Z_AXIS };
30 
31 class FPose;
32 
36 class FVector {
37 public:
38  float _x, _y, _z;
39 public:
40  FVector() : _x(0), _y(0), _z(0) {}
41  FVector(float x, float y, float z) : _x(x), _y(y), _z(z) {}
42 
46  void clear() {
47  _x = _y = _z = 0.0;
48  }
49 
55  FVector swapComponents() const;
56 
60  FVector crossProduct(const FVector &src) const;
61 
65  void rotVectAxisY(float angleDeg);
66 
72  bool normalize(float &hyp);
73 
74  void normalize() {
75  float hyp;
76  bool result = normalize(hyp);
77  assert(result);
78  }
79 
83  FVector half(const FVector &v) const;
84 
91  FVector getPolarCoord() const;
92 
96  float getDistance(const FVector &src) const;
97 
102  FVector matProdRowVect(const FPose &pose) const;
103 
108  FPose getFrameTransform(const FVector &v);
109 
114  FPose formRotXY() const;
115 
119  bool operator==(const FVector &src) const {
120  return _x == src._x && _y == src._y && _z == src._z;
121  }
122 
126  bool operator!=(const FVector &src) const {
127  return _x != src._x || _y != src._y || _z != src._z;
128  }
129 
130  FVector operator+(const FVector &delta) const {
131  return FVector(_x + delta._x, _y + delta._y, _z + delta._z);
132  }
133 
134  FVector operator-(const FVector &delta) const {
135  return FVector(_x - delta._x, _y - delta._y, _z - delta._z);
136  }
137 
138  const FVector operator*(float right) const {
139  return FVector(_x * right, _y * right, _z * right);
140  }
141 
142  const FVector operator*(const FVector &right) const {
143  return FVector(_x * right._x, _y * right._y, _z * right._z);
144  }
145 
146  void operator+=(const FVector &delta) {
147  _x += delta._x;
148  _y += delta._y;
149  _z += delta._z;
150  }
151 
152  void operator-=(const FVector &delta) {
153  _x -= delta._x;
154  _y -= delta._y;
155  _z -= delta._z;
156  }
157 
158  void operator+=(const FPoint &delta) {
159  _x += delta._x;
160  _y += delta._y;
161  }
162 
163  void operator-=(const FPoint &delta) {
164  _x -= delta._x;
165  _y -= delta._y;
166  }
167 
171  Common::String toString() const;
172 };
173 
174 } // End of namespace Titanic
175 
176 #endif /* TITANIC_FVECTOR_H */
Definition: str.h:59
FVector swapComponents() const
bool operator!=(const FVector &src) const
Definition: fvector.h:126
FVector matProdRowVect(const FPose &pose) const
FVector getPolarCoord() const
void rotVectAxisY(float angleDeg)
bool operator==(const FVector &src) const
Definition: fvector.h:119
FVector crossProduct(const FVector &src) const
Definition: fpose.h:34
float getDistance(const FVector &src) const
FPose formRotXY() const
Definition: arm.h:30
FVector half(const FVector &v) const
FPose getFrameTransform(const FVector &v)
Common::String toString() const
bool normalize(float &hyp)
void clear()
Definition: fvector.h:46
Definition: fpoint.h:32
Definition: fvector.h:36