Vector Class Reference

#include <myVector.h>

List of all members.


Detailed Description

A 2d vector.


Public Member Functions

 Vector ()
void normalize ()
void setValue (double x, double y)
double distsqr (const Vector &v)
double getX ()
double getY ()
void setX (double x)
void setY (double y)
Vectoroperator= (const Vector &v)
Vectoroperator+= (const Vector &v)
Vectoroperator-= (const Vector &v)
Vector operator+ (const Vector &v)
Vector operator- (const Vector &v)
Vector operator * (const double s)
bool operator== (const Vector &v)
bool operator!= (const Vector &v)

Protected Attributes

double x
double y

Friends

std::ostream & operator<< (std::ostream &Stream, const Vector v)


Constructor & Destructor Documentation

Vector::Vector (  ) 

00004 {
00005     x = 0.0;
00006     y = 0.0;
00007 }


Member Function Documentation

double Vector::distsqr ( const Vector v  ) 

00026 {
00027     Vector temp;
00028     temp.setValue(x - v.x, y - v.y);
00029     return temp.x*temp.x + temp.y*temp.y;
00030 }

double Vector::getX (  )  [inline]

00019 { return x; }

double Vector::getY (  )  [inline]

00020 { return y; }

void Vector::normalize (  ) 

00010 {
00011     double temp;
00012     temp = sqrt((x*x + y*y));
00013     if(temp != 0.0) {
00014         x /= temp;
00015         y /= temp;
00016     }
00017 }

Vector Vector::operator * ( const double  s  ) 

00068 {
00069     Vector temp;
00070     temp.setValue(x*s, y*s);
00071     return temp;
00072 }

bool Vector::operator!= ( const Vector v  ) 

00081 {
00082     if(this->x == v.x && this->y == v.y) return false;
00083     return true;
00084 }

Vector Vector::operator+ ( const Vector v  ) 

00054 {
00055     Vector temp;
00056     temp.setValue(x + v.x, y + v.y);
00057     return temp;
00058 }

Vector & Vector::operator+= ( const Vector v  ) 

00040 {
00041     x += v.x;
00042     y += v.y;
00043     return *this;
00044 }

Vector Vector::operator- ( const Vector v  ) 

00061 {
00062     Vector temp;
00063     temp.setValue(x - v.x, y - v.y);
00064     return temp;
00065 }

Vector & Vector::operator-= ( const Vector v  ) 

00047 {
00048     x -= v.x;
00049     y -= v.y;
00050     return *this;
00051 }

Vector & Vector::operator= ( const Vector v  ) 

00033 {
00034     x = v.x;
00035     y = v.y;
00036     return *this;
00037 }

bool Vector::operator== ( const Vector v  ) 

00075 {
00076     if(this->x == v.x && this->y == v.y) return true;
00077     return false;
00078 }

void Vector::setValue ( double  x,
double  y 
)

00020 {
00021     this->x = x;
00022     this->y = y;
00023 }

void Vector::setX ( double  x  )  [inline]

00021 { this->x = x; }

void Vector::setY ( double  y  )  [inline]

00022 { this->y = y; }


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  Stream,
const Vector  v 
) [friend]

00087 {
00088     return Stream << "[" << v.x << ", " << v.y << "]";
00089 }


Member Data Documentation

double Vector::x [protected]

double Vector::y [protected]


The documentation for this class was generated from the following files:
Generated on Wed Apr 4 13:37:07 2007 for ITM OverSim by  doxygen 1.4.7