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
27namespace Titanic {
28
29enum Axis { X_AXIS, Y_AXIS, Z_AXIS };
30
31class FPose;
32
36class FVector {
37public:
38 float _x, _y, _z;
39public:
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
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
92
96 float getDistance(const FVector &src) const;
97
102 FVector matProdRowVect(const FPose &pose) const;
103
109
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
172};
173
174} // End of namespace Titanic
175
176#endif /* TITANIC_FVECTOR_H */
Definition: str.h:59
Definition: fpose.h:34
Definition: fvector.h:36
FVector matProdRowVect(const FPose &pose) const
FPose getFrameTransform(const FVector &v)
FVector half(const FVector &v) const
FPose formRotXY() const
void rotVectAxisY(float angleDeg)
FVector getPolarCoord() const
float getDistance(const FVector &src) const
void clear()
Definition: fvector.h:46
FVector swapComponents() const
Common::String toString() const
bool operator==(const FVector &src) const
Definition: fvector.h:119
bool normalize(float &hyp)
FVector crossProduct(const FVector &src) const
bool operator!=(const FVector &src) const
Definition: fvector.h:126