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

Coord Class Reference

Defines a 3D coordinate. More...

List of all members.

Public Methods

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

Public Attributes

double x
double y
double z

Friends

double dot (const Coord &c1, const Coord &c2)
Coord cross (const Coord &c1, const Coord &c2)


Detailed Description

Defines a 3D coordinate.

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


Constructor & Destructor Documentation

Coord::Coord (    ) 
 

Default constructor.

Initializes the coordinate to (0, 0, 0).

Coord::Coord (  double    x,
double    y = 0.0,
double    z = 0.0
) 
 

Constructor.

Initializes the coordinate to (x, y, z).

Parameters:
x The x coordinate
y The y coordinate
z The z coordinate

Coord::Coord (  VRSFVec3f    coord ) 
 

Set the coordinate.

Parameters:
coord A 3D coordinate


Member Function Documentation

double Coord::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 Coord::normalize (    ) 
 

Normalizes the vector to be of length=1.

Coord Coord::operator * (  double    d )  const
 

Multiplies coordinate by d.

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

Coord& Coord::operator *= (  double    d ) 
 

Multiplies coordinate by d.

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

Coord Coord::operator+ (  const Coord &    coord )  const
 

Adds coord to current coordinate.

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

Coord& Coord::operator+= (  const Coord &    coord ) 
 

Adds coord to current coordinate.

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

Coord Coord::operator- (    )  const
 

Returns the current coordinate multiplied by -1.

Returns:
A new Coord object with the result

Coord Coord::operator- (  const Coord &    coord )  const
 

Subtract coord from current coordinate.

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

Coord& Coord::operator-= (  const Coord &    coord ) 
 

Subtract coord from current coordinate.

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

Coord Coord::operator/ (  double    d )  const
 

Divides coordinate by d.

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

Coord& Coord::operator/= (  double    d ) 
 

Divides coordinate by d.

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

Coord& Coord::operator= (  const Coord &    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 Coord::operator== (  const Coord &    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 Coord::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, 2 for z)
Returns:
The current x/y/z coordinate

double& Coord::operator[] (  int    i ) 
 

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

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

void Coord::setCoords (  double    x = 0.0,
double    y = 0.0,
double    z = 0.0
) 
 

Set the coordinate.

Parameters:
x The x coordinate
y The y coordinate
z The z coordinate

double Coord::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

Coord Coord::unit (    )  const
 

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

Returns:
Normalized vector


Friends And Related Function Documentation

Coord cross (  const Coord &    c1,
const Coord &    c2
)  [friend]
 

Returns the cross product between the 2 coordinates.

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

double dot (  const Coord &    c1,
const Coord &    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 Coord::x
 

The x coordinate.

double Coord::y
 

The y coordinate.

double Coord::z
 

The z 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.