ScummVM API documentation
te_vector2f32.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_VECTOR2F32_H
23 #define TETRAEDGE_TE_TE_VECTOR2F32_H
24 
25 #include "math/vector2d.h"
26 
27 namespace Tetraedge {
28 
29 class TeVector2s32;
30 class TeVector3f32;
31 
32 class TeVector2f32 : public Math::Vector2d {
33 public:
34  TeVector2f32() : Math::Vector2d() {};
35 
36  TeVector2f32(const TeVector2s32 &other);
37 
38  TeVector2f32(const Math::Vector2d &other) : Math::Vector2d(other) {};
39 
40  TeVector2f32(float x_, float y_) : Math::Vector2d(x_, y_) {};
41 
42  Common::String dump() const {
43  return Common::String::format("TeVector2f32(%.02f %.02f)", getX(), getY());
44  }
45 
46  static void deserialize(Common::ReadStream &stream, TeVector2f32 &dest) {
47  dest.setX(stream.readFloatLE());
48  dest.setY(stream.readFloatLE());
49  }
50 
51  static void serialize(Common::WriteStream &stream, const TeVector2f32 &src) {
52  stream.writeFloatLE(src.getX());
53  stream.writeFloatLE(src.getY());
54  }
55 
56  float crossProduct(const TeVector2f32 &other) const {
57  return getX() * other.getX() - getY() * other.getY();
58  }
59 
60  float length() const {
61  return sqrt(getX() * getX() + getY() * getY());
62  }
63 
64  bool parse(const Common::String &val);
65 
66  /*
67  TODO: do we need anything that isn't already in Vector2d here?
68  TeVector2f32(const TeVector2f32 &other);
69  TeVector2f32(const TeVector3f32 &other);
70  TeVector2f32(float *vals);
71 
72  float dotProduct(const TeVector2f32 &other) const;
73  float squaredLength() const;
74 
75  void normalize();
76 
77  TeVector2f32 operator+(const TeVector2f32 &other) const;
78  TeVector2f32 operator-(const TeVector2f32 &other) const;
79  bool operator==(const TeVector2f32 &other) const;
80 
81  bool deserialize(Common::ReadStream &stream);
82  bool serialize(Common::WriteStream &stream);
83 
84 public:
85  float x;
86  float y;
87  */
88 };
89 
90 } // end namespace Tetraedge
91 
92 #endif // TETRAEDGE_TE_TE_VECTOR2F32_H
Definition: str.h:59
Definition: detection.h:27
static String format(MSVC_PRINTF const char *fmt,...) GCC_PRINTF(1
Definition: stream.h:77
FORCEINLINE void writeFloatLE(float value)
Definition: stream.h:233
FORCEINLINE float readFloatLE()
Definition: stream.h:615
Definition: te_vector2s32.h:31
Definition: stream.h:385
Definition: te_vector2f32.h:32