User manual:   Main Page   Overview   Installation   User Interface   Tutorial   Example   FAQ   Version Updates
Reference manual:   Class List   Class Members   Globals, enums and defines

Coord2D Class Reference

Defines a 2D coordinate. More...

List of all members.

Public Methods

 Coord2D ()
 Coord2D (double x, double y=0.0)
void setCoords (double x=0.0, double y=0.0)
Coord2D & operator+= (const Coord2D &coord)
Coord2D & operator-= (const Coord2D &coord)
Coord2D operator+ (const Coord2D &coord) const
Coord2D operator- (const Coord2D &coord) const
Coord2D operator- () const
bool operator== (const Coord2D &coord) const
Coord2D & operator= (const Coord2D &coord)
Coord2D & operator *= (double d)
Coord2D & operator/= (double d)
Coord2D operator * (double d) const
Coord2D operator/ (double d) const
double & operator[] (int i)
double operator[] (int i) const
double sqrabs () const
double abs () const
Coord2D unit () const
void normalize ()

Public Attributes

double x
double y

Friends

double dot (const Coord2D &c1, const Coord2D &c2)


Detailed Description

Defines a 2D coordinate.

Every component (x and y) is a double. The coordinate can also be used as a vector, starting at (0,0) and ending at (x,y).


Constructor & Destructor Documentation

Coord2D::Coord2D  
 

Default constructor.

Initializes the coordinate to (0, 0).

Coord2D::Coord2D double    x,
double    y = 0.0
 

Constructor.

Initializes the coordinate to (x, y).

Parameters:
x The x coordinate
y The y coordinate


Member Function Documentation

double Coord2D::abs   const
 

Returns the length of the vector.

It is also the square root of the dot product between the vector and itself

Returns:
The length of the vector

void Coord2D::normalize  
 

Normalizes the vector to be of length=1.

Coord2D Coord2D::operator * double    d const
 

Multiplies coordinate by d, returns a new Coord2D object.

Parameters:
d The parameter to multiply by
Returns:
A new Coord2D object with the result

Coord2D& Coord2D::operator *= double    d
 

Multiplies coordinate by d.

Parameters:
d The parameter to multiply by
Returns:
A reference to this object

Coord2D Coord2D::operator+ const Coord2D &    coord const
 

Adds coord to current coordinate.

Parameters:
coord The coordinate to add
Returns:
A new Coord2D object with the result

Coord2D& Coord2D::operator+= const Coord2D &    coord
 

Adds coord to current coordinate.

Parameters:
coord The coordinate to add
Returns:
A reference to this object

Coord2D Coord2D::operator-   const
 

Returns the current coordinate multiplied by -1.

Returns:
A new Coord2D object with the result

Coord2D Coord2D::operator- const Coord2D &    coord const
 

Subtract coord from current coordinate.

Parameters:
coord The coordinate to subtract
Returns:
A new Coord2D object with the result

Coord2D& Coord2D::operator-= const Coord2D &    coord
 

Subtract coord from current coordinate.

Parameters:
coord The coordinate to subtract
Returns:
A reference to this object

Coord2D Coord2D::operator/ double    d const
 

Divides coordinate by d, returns a new Coord2D object.

Parameters:
d The parameter to divide by
Returns:
A new Coord2D object with the result

Coord2D& Coord2D::operator/= double    d
 

Divides coordinate by d.

Parameters:
d The parameter to divide by
Returns:
A reference to this object

Coord2D& Coord2D::operator= const Coord2D &    coord
 

Compares 2 coordinates and returns true if they are the same.

Parameters:
coord The coordinate to compare to
Return values:
true The 2 coordinates are the same
false The coordinates are different

bool Coord2D::operator== const Coord2D &    coord const
 

Compares 2 coordinates and returns true if they are the same.

Parameters:
coord The coordinate to compare to
Return values:
true The 2 coordinates are the same
false The coordinates are different

double Coord2D::operator[] int    i const
 

Returns the x/y/z coordinate (depends on i).

Parameters:
i Specifies the x/y/z coordinate (0 for x, 1 for y)
Returns:
The current x/y coordinate

double& Coord2D::operator[] int    i
 

Returns the x/y coordinate (depends on i).

Parameters:
i Specifies the x/y coordinate (0 for x, 1 for y)
Returns:
The current x/y coordinate

void Coord2D::setCoords double    x = 0.0,
double    y = 0.0
 

Set the coordinate.

Parameters:
x The x coordinate
y The y coordinate

double Coord2D::sqrabs   const
 

Returns the norm of the vector.

It is also the dot product between the vector and itself

Returns:
The norm of the vector

Coord2D Coord2D::unit   const
 

Returns a normalized vector (same direction as original vector, but with length=1).

Returns:
Normalized vector


Friends And Related Function Documentation

double dot const Coord2D &    c1,
const Coord2D &    c2
[friend]
 

Returns the dot product between the 2 coordinates.

Parameters:
c1 First coordinate
c2 Second coordinate
Returns:
The dot product result


Member Data Documentation

double Coord2D::x
 

The x coordinate.

double Coord2D::y
 

The y coordinate.


The documentation for this class was generated from the following file:
MeshMaker 5.2 Manual
This software library was written by Roni Raab, ronir@cs.technion.ac.il.
Last updated on May 2003.
This software is for academic and research use only.