31 #ifndef CRAB_VECTORS_H 32 #define CRAB_VECTORS_H 34 #include "common/debug.h" 35 #include "crab/loaders.h" 47 Vector2D(T X = 0, T Y = 0) { Set(X, Y); }
48 void Set(T X = 0, T Y = 0) {
53 bool load(rapidxml::xml_node<char> *node,
const bool &echo =
true) {
54 return loadNum(x,
"x", node, echo) && loadNum(y,
"y", node, echo);
57 void saveState(rapidxml::xml_document<> &doc, rapidxml::xml_node<char> *root,
const char *name) {
58 warning(
"STUB: Vector2D::saveState()");
60 rapidxml::xml_node<char> *child = doc.allocate_node(rapidxml::node_element, name);
61 child->append_attribute(doc.allocate_attribute(
"x",
g_engine->_stringPool->Get((
int)x)));
62 child->append_attribute(doc.allocate_attribute(
"y",
g_engine->_stringPool->Get((
int)y)));
63 root->append_node(child);
68 return sqrt(x * x + y * y);
72 return (x * x + y * y);
76 double m = magnitude();
82 return x * v.x + y * v.y;
94 bool operator==(
const Vector2D &v)
const {
return x == v.x && y == v.y; }
95 bool operator!=(
const Vector2D &v)
const {
return x != v.x || y != v.y; }
97 return Vector2D(v1.x - v2.x, v1.y - v2.y);
112 Vector3D(T X = 0, T Y = 0, T Z = 0) {
116 Vector3D(rapidxml::xml_node<char> *node) {
120 void set(T X = 0, T Y = 0, T Z = 0) {
126 bool load(rapidxml::xml_node<char> *node) {
127 return loadXYZ<T>(x, y, z, node);
131 void operator+=(
const Vector3D &v) {
136 void operator-=(
const Vector3D &v) {
141 bool operator==(
const Vector3D &v) {
return x == v.x && y == v.y && z == v.z; }
149 #endif // CRAB_VECTORS_H void warning(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: moveeffect.h:37
Definition: vectors.h:108