GVectors::Coordinates Class Reference

Class representing 2D coordinates. More...

#include <coordinates.h>

Inheritance diagram for GVectors::Coordinates:

GVectors::GVector GVectors::VisualVector List of all members.

Public Member Functions

 Coordinates ()
 Constructor.
 Coordinates (double x, double y)
 Constructor.
virtual ~Coordinates ()
 Destructor.
 Coordinates (const Coordinates &c)
 Copy constructor.
void X (double x)
 Set the x component.
void setX (double x)
 Set the x component.
void Y (double y)
 Set the y component.
void setY (double y)
 Set the y component.
void set (double x, double y)
 Set the x and y component.
double X () const
 Get the x component.
double getX () const
 Get the x component.
double Y () const
 Get the y component.
double getY () const
 Get the y component.
void get (double &x, double &y) const
 Get the x and y component.
const Coordinatesoperator= (const Coordinates &c)
 Assignment operator.
bool operator== (const Coordinates &c) const
 Equality operator.
bool operator!= (const Coordinates &c) const
 Inequality operator.
double operator[] (unsigned int i) const
 Index operator.
Coordinates operator+ (const Coordinates &c) const
 Addition operator.
Coordinates operator- (const Coordinates &c) const
 Subtraction operator.
Coordinates operator * (double d) const
 Multiplication operator.
double operator * (const Coordinates &c) const
 Dot operator.
Coordinates operator/ (double d) const
 Division operator.
const Coordinatesoperator+= (const Coordinates &c)
 Assignment addition operator.
const Coordinatesoperator-= (const Coordinates &c)
 Assignment addition operator.

Protected Attributes

double x_ord
 The x component.
double y_ord
 The x component.

Detailed Description

This class represents 2-dimensional coordinates. Well, it could be thought of as a point, as well.


Constructor & Destructor Documentation

Coordinates::Coordinates (  ) 

Initializes the x and y component to zero.

Coordinates::Coordinates ( double  x,
double  y 
)

Initializes the x and y component to the given values.

Parameters:
x The value of the x component.
y The value of the y component.

Coordinates::~Coordinates (  )  [virtual]

Does nothing. Just for completeness.

Coordinates::Coordinates ( const Coordinates c  ) 

Copy constructor.

Parameters:
c A const reference to a Coordinates class.


Member Function Documentation

void Coordinates::X ( double  x  ) 

Sets the x component to the given value.

Parameters:
x The new value of the x component.

void Coordinates::setX ( double  x  ) 

Sets the x component to the given value.

Parameters:
x The new value of the x component.

void Coordinates::Y ( double  y  ) 

Sets the y component to the given value.

Parameters:
y The new value of the y component.

void Coordinates::setY ( double  y  ) 

Sets the y component to the given value.

Parameters:
y The new value of the y component.

void Coordinates::set ( double  x,
double  y 
)

Sets the x and y component to the given values.

Parameters:
x The new value of the x component.
y The new value of the y component.

double Coordinates::X (  )  const

Gets the value of the x component.

Returns:
The value of the x component.

double Coordinates::getX (  )  const

Gets the value of the x component.

Returns:
The value of the x component.

double Coordinates::Y (  )  const

Gets the value of the y component.

Returns:
The value of the y component.

double Coordinates::getY (  )  const

Gets the value of the y component.

Returns:
The value of the y component.

void Coordinates::get ( double &  x,
double &  y 
) const

Gets the value of the x and y component.

Parameters:
x A reference to a double which will receive the value of the x component.
y A reference to a double which will receive the value of the y component.

const Coordinates & Coordinates::operator= ( const Coordinates c  ) 

Assigns one Coordinates to another.

Parameters:
c A const reference to the Coordinates to be assigned to this.
Returns:
A const reference to this.

bool Coordinates::operator== ( const Coordinates c  )  const

Compares two Coordinates classes for equality.

Parameters:
c A reference to a Coordinates class to be compared to this.
Returns:
Indicating whether or not the two classes have the same x and y components.
Return values:
true Both classes have identical x and y components.
false The classes differ in either the x or y components or in both components.

bool Coordinates::operator!= ( const Coordinates c  )  const

Compares two classes for inequality.

Parameters:
c A reference to a Coordinates class to be compared to this.
Returns:
Indicating whether or not the two classes have non-identical x and y components.
Return values:
true The classes differ in either the x or y components or in both components.
false Both classes have identical x and y components.

double Coordinates::operator[] ( unsigned int  i  )  const

Index operator.

Parameters:
i The index to retrieve. Pass 0 ('zero') for the x component or 1 ('one') for the y component.
Returns:
The value of the component.
Exceptions:
std::out_of_range if i not in {0,1}.

Coordinates Coordinates::operator+ ( const Coordinates c  )  const

Adds another Coordinates class component wise to this and returns the sum.

Parameters:
c A const reference to the Coordinates class to be added to this.
Returns:
A Coordinates class holding the sum.

Coordinates Coordinates::operator- ( const Coordinates c  )  const

Subtracts another Coordinates class component wise from this and returns the sum.

Parameters:
c A const reference to the Coordinates class to be subtracted from this.
Returns:
A Coordinates class holding the difference.

Coordinates Coordinates::operator * ( double  d  )  const

Multiplies the scalar value d with both components.

Parameters:
d A double value representing the factor.
Returns:
A Coordinates class holding the product.

double Coordinates::operator * ( const Coordinates c  )  const

Multiplies two Coordinates classes (dot operator).

Parameters:
c A const reference to the Coordinates class representing the factor.
Returns:
A scalar value as result of the operation.

Coordinates Coordinates::operator/ ( double  d  )  const

Divides this Coordinates by the value of d.

Parameters:
d A double representing the divisor.
Returns:
A Coordinates class representing the ratio.

const Coordinates & Coordinates::operator+= ( const Coordinates c  ) 

Adds and assigns a Coordinates class to this.

Parameters:
c A const reference to the addend.
Returns:
A const reference to this holding the sum.

const Coordinates & Coordinates::operator-= ( const Coordinates c  ) 

Subtracts and assigns a Coordinates class from this.

Parameters:
c A const reference to the subtrahend.
Returns:
A const reference to this holding the difference.


Member Data Documentation

double GVectors::Coordinates::x_ord [protected]

Holds the x component.

double GVectors::Coordinates::y_ord [protected]

Holds the x component.


The documentation for this class was generated from the following files:
Generated on Sat Sep 8 19:37:30 2007 for libgvectors by  doxygen 1.4.7