fix configure scritp
[supertux.git] / lib / math / vector.h
index b933454..31b171d 100644 (file)
@@ -1,7 +1,7 @@
 //  $Id$
 //
 //  SuperTux -  A Jump'n Run
-//  Copyright (C) 2004 Matthias Braun <matze@braunis.de
+//  Copyright (C) 2004 Matthias Braun <matze@braunis.de>
 //
 //  This program is free software; you can redistribute it and/or
 //  modify it under the terms of the GNU General Public License
 #ifndef SUPERTUX_VECTOR_H
 #define SUPERTUX_VECTOR_H
 
-class Vector
-{
-public:
-  Vector(float nx, float ny)
-    : x(nx), y(ny)
-  { }
-  Vector(const Vector& other)
-    : x(other.x), y(other.y)
-  { }
-  Vector()
-    : x(0), y(0)
-  { }
-
-  bool operator ==(const Vector& other) const
+namespace SuperTux
   {
-    return x == other.x && y == other.y;
-  }
 
-  const Vector& operator=(const Vector& other)
-  {
-    x = other.x;
-    y = other.y;
-    return *this;
-  }
-
-  Vector operator+(const Vector& other) const
-  {
-    return Vector(x + other.x, y + other.y);
-  }
-
-  Vector operator-(const Vector& other) const
-  {
-    return Vector(x - other.x, y - other.y);
-  }
-
-  Vector operator*(float s) const
-  {
-    return Vector(x * s, y * s);
-  }
-
-  Vector operator/(float s) const
-  {
-    return Vector(x / s, y / s);
-  }
-
-  Vector operator-() const
-  {
-    return Vector(-x, -y);
-  }
-
-  const Vector& operator +=(const Vector& other)
-  {
-    x += other.x;
-    y += other.y;
-    return *this;
-  }
-
-  // scalar product of 2 vectors
-  float operator*(const Vector& other) const
-  {
-    return x*other.x + y*other.y;
-  }
-
-  float norm() const;
-  Vector unit() const;
-
-  // ... add the other operators as needed, I'm too lazy now ...
-
-  float x, y; // leave this public, get/set methods just give me headaches
-              // for such simple stuff :)
-};
+  /// 2D Vector.
+  /** Simple two dimensional vector. */
+  class Vector
+    {
+    public:
+      Vector(float nx, float ny)
+          : x(nx), y(ny)
+      { }
+      Vector(const Vector& other)
+          : x(other.x), y(other.y)
+      { }
+      Vector()
+          : x(0), y(0)
+      { }
+
+      bool operator ==(const Vector& other) const
+        {
+          return x == other.x && y == other.y;
+        }
+
+      bool operator !=(const Vector& other) const
+        {
+          return !(x == other.x && y == other.y);
+        }
+
+      const Vector& operator=(const Vector& other)
+      {
+        x = other.x;
+        y = other.y;
+        return *this;
+      }
+
+      Vector operator+(const Vector& other) const
+        {
+          return Vector(x + other.x, y + other.y);
+        }
+
+      Vector operator-(const Vector& other) const
+        {
+          return Vector(x - other.x, y - other.y);
+        }
+
+      Vector operator*(float s) const
+        {
+          return Vector(x * s, y * s);
+        }
+
+      Vector operator/(float s) const
+        {
+          return Vector(x / s, y / s);
+        }
+
+      Vector operator-() const
+        {
+          return Vector(-x, -y);
+        }
+
+      const Vector& operator +=(const Vector& other)
+      {
+        x += other.x;
+        y += other.y;
+        return *this;
+      }
+
+      const Vector& operator *=(float val)
+      {
+        x *= val;
+        y *= val;
+        return *this;
+      }
+
+      const Vector& operator /=(float val)
+      {
+        x /= val;
+        y /= val;
+        return *this;
+      }
+
+      /// Scalar product of 2 vectors
+      float operator*(const Vector& other) const
+        {
+          return x*other.x + y*other.y;
+        }
+
+      float norm() const;
+      Vector unit() const;
+
+      // ... add the other operators as needed, I'm too lazy now ...
+
+      float x, y; // leave this public, get/set methods just give me headaches
+      // for such simple stuff :)
+    };
+
+} //namespace SuperTux
 
 #endif /*SUPERTUX_VECTOR_H*/