GVectors::GVector Class Reference

Class representing a 3D vector. More...

#include <gvector.h>

Inheritance diagram for GVectors::GVector:

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

Public Member Functions

 GVector ()
 Constructor.
 GVector (double x, double y, double z)
 Constructor.
virtual ~GVector ()
 Destructor.
 GVector (const GVector &v)
 Copy constructor.
void setZ (double z)
 Set the value of the z component.
void Z (double z)
 Set the value of the z component.
void set (double x, double y, double z)
 Set all components.
double getZ () const
 Get the value of the z component.
double Z () const
 Get the value of the z component.
void get (double &x, double &y, double &z) const
 Get all components.
bool iszero () const
 Indicates whether or not the vector is a zero vector.
double abs () const
 The absolute value of the vector (norm).
const GVector cross (const GVector &v) const
 Cross product of two vectors.
const double angle (const GVector &v, Angle_Type at) const
 Angle between two vectors.
const GVector connecting (const GVector &v) const
 Vector connecting two vectors.
const GVector middle (const GVector &v) const
 The middle of two vectors.
void invert ()
 Invert the vector.
virtual void print () const
 Print the vector to stdout.
const GVectoroperator= (const GVector &v)
 Assignment operator.
GVector operator+ (const GVector &v) const
 Add two vectors.
GVector operator- (const GVector &v) const
 Subtract two vectors.
double operator * (const GVector &v) const
 Multiply two vectors (scalar product; dot operator).
GVector operator * (const double &d) const
 Multiply by a scalar value.
GVector operator/ (const double &d) const
 Divide by a scalar value.
const GVectoroperator+= (const GVector &v)
 Assignment addition.
const GVectoroperator-= (const GVector &v)
 Assignment subtraction.
const GVectoroperator *= (double d)
 Assignment multiplication by a scalar value.

Protected Attributes

double z_ord
 The z component representing the third dimension.

Detailed Description

GVector is a class representing a 3D vector. It is a descendant of Coordinates and utilizes three components (x, y, and z) to represent the three dimensions.


Constructor & Destructor Documentation

GVector::GVector (  ) 

Initializes all components to zero.

GVector::GVector ( double  x,
double  y,
double  z 
)

Initializes all components with the given values.

Parameters:
x Value of the x component.
y Value of the y component.
z Value of the z component.

GVector::~GVector (  )  [virtual]

Does nothing. Just for completeness.

GVector::GVector ( const GVector v  ) 

Copy constructor.

Parameters:
v A const reference to a GVector.


Member Function Documentation

void GVector::setZ ( double  z  ) 

Sets the z component to the given value.

Parameters:
z New value of the z component.

void GVector::Z ( double  z  ) 

Sets the z component to the given value.

Parameters:
z New value of the z component.

void GVector::set ( double  x,
double  y,
double  z 
)

Sets all component to the given values.

Parameters:
x New value of the x component.
y New value of the y component.
z New value of the z component.

double GVector::getZ (  )  const

Returns the value of the z component.

Returns:
The value of the z component.

double GVector::Z (  )  const

Returns the value of the z component.

Returns:
The value of the z component.

void GVector::get ( double &  x,
double &  y,
double &  z 
) const

Retrieves all values of the components.

Parameters:
x Reference to the variable taking the x component.
y Reference to the variable taking the y component.
z Reference to the variable taking the z component.

bool GVector::iszero (  )  const

Indicates whether or not the vector is a zero vector, thus all components are equal zero.

Returns:
A boolean value indicating whether or not the vector is a zero vector.
Return values:
true The vector is a zero vector.
false The vector is not a zero vector.

double GVector::abs (  )  const

Calculates the absolute value (norm) of the vector.

|v| = sqrt(x^2+y^2+z^2)

Returns:
The absolute value of the vector.

const GVector GVector::cross ( const GVector v  )  const

Calculates the cross product of two vectors.

v = a x b

Parameters:
v A const reference to a GVector.
Returns:
A GVector representing the cross product of this and v.

const double GVector::angle ( const GVector v,
Angle_Type  at 
) const

Calculates the angle between two vectors.

Parameters:
v A const reference to a GVector.
at The unit of the angle to be returned. See Angle_Type.
Returns:
The angle between this and v measured in terms of Angle_Type.

const GVector GVector::connecting ( const GVector v  )  const

Calculates the connecting vector between two vectors.

v = a - b

Parameters:
v A const reference to a GVector.
Returns:
A GVector representing the connecting vector of this and v.

const GVector GVector::middle ( const GVector v  )  const

Calculates the middle of two vectors.

v = ( a + b ) / 2

Parameters:
v A const reference to a GVector.
Returns:
A GVector representing the middle of this and v.

void GVector::invert (  ) 

Inverts the vector by multiplying it by -1 ('minus one').

void GVector::print (  )  const [virtual]

Prints the vector to stdout using the format [x,y,z].

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

Assigns one vector to another.

Parameters:
v A const reference to the GVector to be assigned.
Returns:
A const reference to this.

Reimplemented in GVectors::VisualVector.

GVector GVector::operator+ ( const GVector v  )  const

Adds two vectors.

Parameters:
v A const reference to the addend.
Returns:
A GVector representing the sum of this and v.

GVector GVector::operator- ( const GVector v  )  const

Subtracts two vectors.

Parameters:
v A const reference to the subtrahend.
Returns:
A GVector representing the difference of this and v.

double GVector::operator * ( const GVector v  )  const

Calculates the scalar product of two vectors.

s = x1 * x2 + y1 * y2 + z1 * z2

Parameters:
v A const reference to a GVector.
Returns:
The result of the scalar product of this and v.

GVector GVector::operator * ( const double &  d  )  const

Multiplies a vector by a scalar value.

Parameters:
d A double representing the scalar value.
Returns:
A GVector representing the product of this and d.

GVector GVector::operator/ ( const double &  d  )  const

Divides a vector by a scalar value.

Parameters:
d A double representing the scalar value.
Returns:
A GVector representing the ratio of this and d.

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

Shorthand operator for addition and assignment.

Parameters:
v A const reference to the addend GVector.
Returns:
A const reference to this.

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

Shorthand operator for subtraction and assignment.

Parameters:
v A const reference to the subtrahend GVector.
Returns:
A const reference to this.

const GVector & GVector::operator *= ( double  d  ) 

Shorthand operator for multiplication by a scalar value and assignment.

Parameters:
d A double representing the scalar value.
Returns:
A const reference to this.


Member Data Documentation

double GVectors::GVector::z_ord [protected]

The z component representing the third dimension.


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