massive cleaning of file section headers
[physics.git] / src / Vector2.cpp
index 8028aa3..4d4b85a 100644 (file)
 #include "Vector2.h"
 #include "mathw.h"
 
+/// ***** Constructors/Destructors *****
+
 Vector2::Vector2()
   : x(0), y(0)
 {
+
 }
 Vector2::Vector2(float x, float y)
   : x(x), y(y)
 {
+
 }
 Vector2::Vector2(const Vector2& vec)
   : x(vec.x), y(vec.y)
 {
+
+}
+Vector2::~Vector2()
+{
+
 }
 
+/// ***** Public Class Methods *****
+
 void Vector2::zero()
 {
-  x = 0;
-  y = 0;
+    x = 0;
+    y = 0;
 }
 void Vector2::unit()
 {
-  float len = length();
+    float len = length();
 
-  x /= len;
-  y /= len;
+    x /= len;
+    y /= len;
 }
 
 float Vector2::angle() const
 {
-  //return atan2A(y,x);
-  return 0;
+    //TODO
+    //return atan2A(y,x);
+    return 0;
 }
 float Vector2::length() const
 {
-  return sqrt(x*x + y*y);
+    return sqrt(x*x + y*y);
 }
 
 
 string Vector2::toString() const
 {
-  char* strX = new char[50]; // long just to be safe
-  char* strY = new char[50]; // long just to be safe
-  sprintf(strX, "%f", x);
-  sprintf(strY, "%f", y);
+     // long just to be safe
+    char* strX = new char[50];
+    char* strY = new char[50];
+
+    sprintf(strX, "%f", x);
+    sprintf(strY, "%f", y);
+
+    string val = (string)"Vector2  x: " + strX + ", y: " + strY;
 
-  string val = (string)"Vector2  x: " + strX + ", y: " + strY;
-  delete []strX; // deletes the memory allocated, not just what is used by sprintf
-  delete []strY; // deletes the memory allocated, not just what is used by sprintf
+     // deletes the allocated memory, not just what is used by sprintf
+    delete []strX;
+    delete []strY;
 
-  return val;
+    return val;
 }
 void Vector2::print() const
 {
-  printf("%s\n",toString().c_str());
+    printf("%s\n",toString().c_str());
 }
 
 
 Vector2 Vector2::add(const Vector2& vec) const
 {
-  return Vector2(x+vec.x, y+vec.y);
+    return Vector2(x+vec.x, y+vec.y);
 }
 Vector2 Vector2::subtract(const Vector2& vec) const
 {
-  return Vector2(x-vec.x, y-vec.y);
+    return Vector2(x-vec.x, y-vec.y);
 }
 Vector2 Vector2::multiply(float c) const
 {
-  return Vector2(x*c, y*c);
+    return Vector2(x*c, y*c);
 }
 Vector2 Vector2::divide(float c) const
 {
-  return Vector2(x/c, y/c);
+    return Vector2(x/c, y/c);
 }
 
+/// ***** Public Methods *****
 
 Vector2 operator+(const Vector2& vec1, const Vector2& vec2)
 {
-  return vec1.add(vec2);
+    return vec1.add(vec2);
 }
 Vector2 operator-(const Vector2& vec1, const Vector2& vec2)
 {
-  return vec1.subtract(vec2);
+    return vec1.subtract(vec2);
 }
 Vector2 operator*(float c, const Vector2& vec)
 {
-  return vec.multiply(c);
+    return vec.multiply(c);
 }
 Vector2 operator*(const Vector2& vec, float c)
 {
-  return vec.multiply(c);
+    return vec.multiply(c);
 }
 Vector2 operator/(const Vector2& vec, float c)
 {
-  return vec.divide(c);
+    return vec.divide(c);
 }
 
 
 void operator+=(Vector2& vec1, const Vector2& vec2)
 {
-  vec1.x += vec2.x;
-  vec1.y += vec2.y;
+    vec1.x += vec2.x;
+    vec1.y += vec2.y;
 }
 void operator-=(Vector2& vec1, const Vector2& vec2)
 {
-  vec1.x -= vec2.x;
-  vec1.y -= vec2.y;
+    vec1.x -= vec2.x;
+    vec1.y -= vec2.y;
 }
 void operator*=(Vector2& vec, float c)
 {
-  vec.x *= c;
-  vec.y *= c;
+    vec.x *= c;
+    vec.y *= c;
 }
 void operator/=(Vector2& vec, float c)
 {
-  vec.x /= c;
-  vec.y /= c;
+    vec.x /= c;
+    vec.y /= c;
 }