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 (  ) 

00027 {
00028     x = 0.0;
00029     y = 0.0;
00030 }


Member Function Documentation

void Vector::normalize (  ) 

00033 {
00034     double temp;
00035     temp = sqrt((x*x + y*y));
00036     if(temp != 0.0) {
00037         x /= temp;
00038         y /= temp;
00039     }
00040 }

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

00043 {
00044     this->x = x;
00045     this->y = y;
00046 }

double Vector::distsqr ( const Vector v  ) 

00049 {
00050     Vector temp;
00051     temp.setValue(x - v.x, y - v.y);
00052     return temp.x*temp.x + temp.y*temp.y;
00053 }

double Vector::getX (  )  [inline]

00042 { return x; }

double Vector::getY (  )  [inline]

00043 { return y; }

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

00044 { this->x = x; }

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

00045 { this->y = y; }

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

00056 {
00057     x = v.x;
00058     y = v.y;
00059     return *this;
00060 }

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

00063 {
00064     x += v.x;
00065     y += v.y;
00066     return *this;
00067 }

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

00070 {
00071     x -= v.x;
00072     y -= v.y;
00073     return *this;
00074 }

Vector Vector::operator+ ( const Vector v  ) 

00077 {
00078     Vector temp;
00079     temp.setValue(x + v.x, y + v.y);
00080     return temp;
00081 }

Vector Vector::operator- ( const Vector v  ) 

00084 {
00085     Vector temp;
00086     temp.setValue(x - v.x, y - v.y);
00087     return temp;
00088 }

Vector Vector::operator * ( const double  s  ) 

00091 {
00092     Vector temp;
00093     temp.setValue(x*s, y*s);
00094     return temp;
00095 }

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

00098 {
00099     if(this->x == v.x && this->y == v.y) return true;
00100     return false;
00101 }

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

00104 {
00105     if(this->x == v.x && this->y == v.y) return false;
00106     return true;
00107 }


Friends And Related Function Documentation

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

00110 {
00111     return Stream << "[" << v.x << ", " << v.y << "]";
00112 }


Member Data Documentation

double Vector::x [protected]

double Vector::y [protected]


The documentation for this class was generated from the following files:
Generated on Tue Jul 24 16:51:19 2007 for ITM OverSim by  doxygen 1.5.1