Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

TPoint Class Reference

3d vector and some standard operations. More...

#include <point.h>

List of all members.

Public Types

enum  { X_AXIS = 1, Y_AXIS = 2, Z_AXIS = 3 }

Public Methods

 TPoint (double x=0, double y=0, double z=0)
 TPoint (const TPoint &point)
double getLength () const
double GetX () const
double GetY () const
double GetZ () const
bool isNull () const
bool LinearDependence (const TPoint &two, double dAccuracy=dEps) const
bool load (TDataPackageList *in, const string &sIdentifier, bool bUnique=true)
double Magnitude () const
TPoint & Normalize ()
bool operator== (const TPoint &point) const
TPoint & operator+= (const TPoint &point)
TPoint & operator-= (const TPoint &point)
TPoint operator+ (const TPoint &point) const
TPoint operator- (const TPoint &point) const
TPoint & operator *= (const double dScale)
TPoint operator * (const double dScale) const
double operator * (const TPoint &point) const
void Rescale (double dScale)
bool save (TDataPackageList *out, const string &sIdentifier, bool bUnique=true, bool bAutoDelete=false) const
void setNull ()
void SetPoint (double x=0, double y=0, double z=0)
void SetX (double x)
void SetY (double y)
void SetZ (double z)
ostream & Write (ostream &stream) const

Protected Attributes

double dX
double dY
double dZ

Static Protected Attributes

const double dEps


Detailed Description

3d vector and some standard operations.

Author:
Marco Krohn <marco.krohn@gmx.de>
Version:
Id:
point.h,v 1.16 2002/06/07 00:33:00 mkrohn5 Exp
See also:
TRectangle
A simple class representing a point in a 3 dimensional space. Operations like +, - and multiplication with scalar values are available.


Constructor & Destructor Documentation

TPoint::TPoint double    x = 0,
double    y = 0,
double    z = 0
 

The standard constructor for defining a 3d point.

Parameters:
x  the x coordinate.
y  the y coordinate.
z  the z coordinate.

TPoint::TPoint const TPoint &    point
 

The TPoint copy constructor.

Parameters:
point  use the coordinates of this point.


Member Function Documentation

double TPoint::getLength   const
 

Calculates the euclidean length of the distance from the point to (0,0,0).

Returns:
The distance to the origin.
See also:
Magnitude

double TPoint::GetX   const
 

Returns:
The x coordinate of the point.

double TPoint::GetY   const
 

Returns:
The y coordinate of the point.

double TPoint::GetZ   const
 

Returns:
The z coordinate of the point.

bool TPoint::isNull   const
 

Returns:
true if all coordinates are 0, otherwise false.

bool TPoint::LinearDependence const TPoint &    two,
double    dAccuracy = dEps
const
 

Analyses if two points (or better "vectors") are linear dependent or not.

Parameters:
two  The second "vector".
dAccuracy  See dEps.
Returns:
true if the "vectors" are linear dependent, otherwise false.

bool TPoint::load TDataPackageList   in,
const string &    sIdentifier,
bool    bUnique = true
 

Loads a TPoint object from a list of data packages. Note that a successful load will delete the datapackage from the data package list as well as the datapackage itself.

Parameters:
in  The input stream of data packages.
sIdentifier  The identifier to look for.
bUnique  Loads the data only if the identifier is unique.
Returns:
true means that everything was loaded correctly, otherwise this method will return false.

double TPoint::Magnitude   const
 

Calculates the euclidean length of the distance from the point to (0,0,0).

Returns:
The distance to the origin.
See also:
getLength

TPoint& TPoint::Normalize  
 

Sets the length of the vector to 1. Note that the vector (0,0,0) can not be normalized.

Returns:
The newly normalized vector (or (0,0,0) for the case mentioned above).

double TPoint::operator * const TPoint &    point const
 

Multiplies two objects with type TPoint, using the "dot product".

Parameters:
point  The second point needed for the product.
Returns:
The return value is the dot product, a real number.

TPoint TPoint::operator * const double    dScale const
 

Multiplies the point with a scalar quantity.

Parameters:
dScale  The scalar quantity.
Returns:
The scaled point.

TPoint& TPoint::operator *= const double    dScale
 

Multiplies this point with a scalar quantity.

Parameters:
dScale  The scalar quantity.
Returns:
The modified point.

TPoint TPoint::operator+ const TPoint &    point const
 

Calculates the sum of two points.

Parameters:
point  The second term of the sum.
Returns:
The sum of the two points.

TPoint& TPoint::operator+= const TPoint &    point
 

Incrementing the point by point.

Parameters:
point  The point that is added.
Returns:
The modified point.

TPoint TPoint::operator- const TPoint &    point const
 

The difference of two points (vectors) = a-b

Parameters:
point  the second term.
Returns:
the result of the operation a-b (note: a will not change its value)

TPoint& TPoint::operator-= const TPoint &    point
 

Subtracting point from this point.

Parameters:
point  The point that is substracted.
Returns:
The modified point.

bool TPoint::operator== const TPoint &    point const
 

Comparison operator.

Parameters:
point  The point to compare to.
Returns:
true if the two points are identical.

void TPoint::Rescale double    dScale
 

Multiplies the point with a scalar quantity.

Parameters:
dScale  The scalar quantity.
Returns:
The scaled point.
See also:
operator *=

bool TPoint::save TDataPackageList   out,
const string &    sIdentifier,
bool    bUnique = true,
bool    bAutoDelete = false
const
 

Creates the data package for a TPoint object and adds it to the data package list.

Parameters:
out  The list of data packages.
sIdentifier  The identifier which is used to store and find the data.
bUnique  If set to true the method will check if the identifier was already used in the data package list.
bAutoDelete  Setting this flag to true means that _this_ object will automatically be deleted by the TDataPackageList.
Returns:
true if everything worked fine, otherwise false (e.g. if the identifier was already used in the data package list).

void TPoint::setNull  
 

Sets all coordinates to 0.

void TPoint::SetPoint double    x = 0,
double    y = 0,
double    z = 0
 

Sets all three coordinates of the point.

void TPoint::SetX double    x
 

Sets the x coordinate of the point.

void TPoint::SetY double    y
 

Sets the y coordinate of the point.

void TPoint::SetZ double    z
 

Sets the z coordinate of the point.

ostream& TPoint::Write ostream &    stream const
 

Writes the current position to a stream, using the following output format: (x, y, z).

Parameters:
stream  The output stream.
Returns:
The output stream after adding the output for the point.


Member Data Documentation

const double TPoint::dEps [static, protected]
 

Since the double arithmetic is not exact we use this constant and say that two double values are "equal" if their difference is smaller than dEps;

double TPoint::dX [protected]
 

The x-component of the point

double TPoint::dY [protected]
 

The y-component of the point

double TPoint::dZ [protected]
 

The z-component of the point


The documentation for this class was generated from the following file:
Generated on Thu Jun 20 18:13:29 2002 for Stellar Legacy by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001