Ceylan::Maths::Linear::Vector3 Class Reference

Three-dimensional vector, whose coordinates are floating-point values (Real). More...

#include <CeylanVector3.h>

Inheritance diagram for Ceylan::Maths::Linear::Vector3:

Inheritance graph
[legend]
Collaboration diagram for Ceylan::Maths::Linear::Vector3:

Collaboration graph
[legend]

List of all members.

Public Types

enum  TextOutputFormat { rawText, html }
 Defines what text output formats for TextDisplayable instances are available. More...

Public Member Functions

 Vector3 (Real x0=0, Real x1=0, Real x2=0)
 Constructs a new vector with specified coordinates.
virtual ~Vector3 () throw ()
 Basic virtual destructor.
virtual void setTo (Real x0, Real x1, Real x2)
 Reassigns this vector's coordinates.
virtual void nullify ()
 Sets this vector to the null vector (all coordinates zeroed).
virtual void setAllElementsTo (Real commonValue)
 Sets this vector so that all its elements equal commonValue.
virtual Real getElementAt (MatrixIndex index) const
 Returns indexed element.
virtual void setElementAt (MatrixIndex index, Real newValue)
 Sets indexed element to specified value.
virtual void normalize ()
 Normalizes this vector, so that its norm equals one.
virtual Real magnitude () const
 Returns this vector's magnitude.
virtual const std::string toString (VerbosityLevels level=high) const
 Returns a user-friendly description of the state of this object.

Static Public Member Functions

static const std::string ToString (std::list< TextDisplayable * > displayables, Ceylan::VerbosityLevels level=Ceylan::high)
 Returns a user-friendly description of this list of pointers to text displayable instances.
static TextOutputFormat GetOutputFormat ()
 Returns the current overall text format to be used by TextDisplayable instances.
static void SetOutputFormat (TextOutputFormat newOutputFormat)
 Sets the current overall text format to be used by TextDisplayable instances.

Static Public Attributes

static const MatrixIndex Dimensions = 3
 Tells what is the dimension for this vector.

Protected Attributes

Real _vec [Dimensions]
 The coordinates of this vector.

Static Protected Attributes

static TextOutputFormat _OutputFormat = rawText
 The text format to be used currently by TextDisplayable instances.

Friends

class Tripoint
 Must access to each other's coordinates.
class Matrix3
 Must access to each other's coordinates.
CEYLAN_DLL friend bool operator== (const Vector3 &v1, const Vector3 &v2)
 Tells whether the two vectors have the same elements.
CEYLAN_DLL friend bool operator!= (const Vector3 &v1, const Vector3 &v2)
 Tells whether the two vectors have the same elements.
CEYLAN_DLL friend Tripoint operator+ (const Tripoint &t, const Vector3 &v)
 Translates a 3D point of specified 3D vector: result = t + v.
CEYLAN_DLL friend Tripoint operator- (const Tripoint &t, const Vector3 &v)
 Translates a 3D point of specified opposite 3D vector: result = t - v.
CEYLAN_DLL friend Vector3 vectorize (const Tripoint &t)
 Transforms a 3D point into a 3D vector, which will have the same coordinates.
CEYLAN_DLL friend Vector3 vectorize (const Tripoint &t1, const Tripoint &t2)
 Constructs a 3D vector from two 3D points: result = t1 - t2.
CEYLAN_DLL friend Vector3 operator+ (const Vector3 &v1, const Vector3 &v2)
 Adds two vectors: result = v1 + v2.
CEYLAN_DLL friend Vector3 operator- (const Vector3 &v1, const Vector3 &v2)
 Substracts two vectors: result = v1 - v2.
CEYLAN_DLL friend Vector3 operator* (Real lambda, const Vector3 &v)
 Multiplies v by coefficient lambda: result = lamba.v.
CEYLAN_DLL friend Vector3 operator* (const Matrix3 &m, const Vector3 &v)
 Applies vector v to matrix m: result = m.v.
CEYLAN_DLL friend Real operator| (const Vector3 &v1, const Vector3 &v2)
 Computes the dot product of v1 and v2: result = v1 (dotproduct) v2.
CEYLAN_DLL friend Vector3 operator^ (const Vector3 &v1, const Vector3 &v2)
 Returns the cross product of v1 and v2: result = v1 (crossproduct) v2.
CEYLAN_DLL friend Real operator~ (const Vector3 &v)
 Returns the magnitude of specified vector.


Detailed Description

Three-dimensional vector, whose coordinates are floating-point values (Real).

Note:
Beware of counter-intuitive operator priorities.

Definition at line 66 of file CeylanVector3.h.


Member Enumeration Documentation

Defines what text output formats for TextDisplayable instances are available.

Enumerator:
rawText 
html 

Definition at line 124 of file CeylanTextDisplayable.h.


Constructor & Destructor Documentation

Vector3::Vector3 ( Real  x0 = 0,
Real  x1 = 0,
Real  x2 = 0 
) [explicit]

Constructs a new vector with specified coordinates.

Note:
If no argument is specified, constructs the null vector.

Definition at line 62 of file CeylanVector3.cc.

References _vec.

Vector3::~Vector3 (  )  throw () [virtual]

Basic virtual destructor.

Definition at line 73 of file CeylanVector3.cc.


Member Function Documentation

Real Vector3::getElementAt ( MatrixIndex  index  )  const [virtual]

Returns indexed element.

Index ranges from 0 to Dimensions-1.

Exceptions:
MathsException if index is out of bounds and if in debug mode.

Definition at line 114 of file CeylanVector3.cc.

References _vec, and Dimensions.

TextDisplayable::TextOutputFormat TextDisplayable::GetOutputFormat (  )  [static, inherited]

Real Vector3::magnitude (  )  const [virtual]

Returns this vector's magnitude.

See also:
operator ~

Implements Ceylan::Maths::Linear::Vector.

Definition at line 168 of file CeylanVector3.cc.

References _vec, Dimensions, and Ceylan::Maths::Sqrt().

Referenced by normalize().

void Vector3::normalize (  )  [virtual]

Normalizes this vector, so that its norm equals one.

Exceptions:
LinearException if the null vector is passed, since it is the only one that cannot be normalized.

Implements Ceylan::Maths::Linear::Vector.

Definition at line 148 of file CeylanVector3.cc.

References _vec, Dimensions, Ceylan::Maths::IsNull(), and magnitude().

Referenced by Ceylan::Maths::Linear::LineProjection3DFunctor::LineProjection3DFunctor(), and Ceylan::Maths::Linear::Rotation3DFunctor::Rotation3DFunctor().

void Vector3::nullify (  )  [virtual]

Sets this vector to the null vector (all coordinates zeroed).

Reimplemented from Ceylan::Maths::Linear::Vector.

Definition at line 91 of file CeylanVector3.cc.

References setAllElementsTo().

void Vector3::setAllElementsTo ( Real  commonValue  )  [virtual]

Sets this vector so that all its elements equal commonValue.

Implements Ceylan::Maths::Linear::Vector.

Definition at line 100 of file CeylanVector3.cc.

References _vec, and Dimensions.

Referenced by nullify().

void Vector3::setElementAt ( MatrixIndex  index,
Real  newValue 
) [virtual]

Sets indexed element to specified value.

Index ranges from 0 to Dimensions-1.

Exceptions:
MathsException if index is out of bounds and if in debug mode.

Definition at line 131 of file CeylanVector3.cc.

References _vec, and Dimensions.

void TextDisplayable::SetOutputFormat ( TextOutputFormat  newOutputFormat  )  [static, inherited]

Sets the current overall text format to be used by TextDisplayable instances.

Parameters:
newOutputFormat the new output format.

Definition at line 72 of file CeylanTextDisplayable.cc.

References Ceylan::TextDisplayable::_OutputFormat.

Referenced by Ceylan::Log::LogHolder::LogHolder().

void Vector3::setTo ( Real  x0,
Real  x1,
Real  x2 
) [virtual]

Reassigns this vector's coordinates.

Definition at line 80 of file CeylanVector3.cc.

References _vec.

Referenced by Ceylan::Maths::Linear::Matrix3::CreateFrom().

const std::string TextDisplayable::ToString ( std::list< TextDisplayable * >  displayables,
Ceylan::VerbosityLevels  level = Ceylan::high 
) [static, inherited]

Returns a user-friendly description of this list of pointers to text displayable instances.

Parameters:
displayables a list of pointers to TextDisplayable instances/
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
toString, Ceylan::VerbosityLevels

Definition at line 45 of file CeylanTextDisplayable.cc.

References Ceylan::formatStringList().

const string Vector3::toString ( VerbosityLevels  level = high  )  const [virtual]

Returns a user-friendly description of the state of this object.

Parameters:
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
TextDisplayable

Reimplemented from Ceylan::Maths::Linear::Vector.

Definition at line 186 of file CeylanVector3.cc.

References _vec, Ceylan::DigitOutputPrecision, Dimensions, Ceylan::Log::LogPlug::error(), Ceylan::TextDisplayable::GetOutputFormat(), Ceylan::high, and Ceylan::TextDisplayable::html.

Referenced by Ceylan::Maths::Linear::Rotation3DFunctor::toString(), and Ceylan::Maths::Linear::LineProjection3DFunctor::toString().


Friends And Related Function Documentation

friend class Matrix3 [friend]

Must access to each other's coordinates.

Definition at line 78 of file CeylanVector3.h.

CEYLAN_DLL friend bool operator!= ( const Vector3 v1,
const Vector3 v2 
) [friend]

Tells whether the two vectors have the same elements.

CEYLAN_DLL friend Vector3 operator* ( const Matrix3 m,
const Vector3 v 
) [friend]

Applies vector v to matrix m: result = m.v.

CEYLAN_DLL friend Vector3 operator* ( Real  lambda,
const Vector3 v 
) [friend]

Multiplies v by coefficient lambda: result = lamba.v.

CEYLAN_DLL friend Vector3 operator+ ( const Vector3 v1,
const Vector3 v2 
) [friend]

Adds two vectors: result = v1 + v2.

CEYLAN_DLL friend Tripoint operator+ ( const Tripoint t,
const Vector3 v 
) [friend]

Translates a 3D point of specified 3D vector: result = t + v.

CEYLAN_DLL friend Vector3 operator- ( const Vector3 v1,
const Vector3 v2 
) [friend]

Substracts two vectors: result = v1 - v2.

CEYLAN_DLL friend Tripoint operator- ( const Tripoint t,
const Vector3 v 
) [friend]

Translates a 3D point of specified opposite 3D vector: result = t - v.

CEYLAN_DLL friend bool operator== ( const Vector3 v1,
const Vector3 v2 
) [friend]

Tells whether the two vectors have the same elements.

CEYLAN_DLL friend Vector3 operator^ ( const Vector3 v1,
const Vector3 v2 
) [friend]

Returns the cross product of v1 and v2: result = v1 (crossproduct) v2.

CEYLAN_DLL friend Real operator| ( const Vector3 v1,
const Vector3 v2 
) [friend]

Computes the dot product of v1 and v2: result = v1 (dotproduct) v2.

CEYLAN_DLL friend Real operator~ ( const Vector3 v  )  [friend]

Returns the magnitude of specified vector.

friend class Tripoint [friend]

Must access to each other's coordinates.

Definition at line 74 of file CeylanVector3.h.

CEYLAN_DLL friend Vector3 vectorize ( const Tripoint t1,
const Tripoint t2 
) [friend]

Constructs a 3D vector from two 3D points: result = t1 - t2.

CEYLAN_DLL friend Vector3 vectorize ( const Tripoint t  )  [friend]

Transforms a 3D point into a 3D vector, which will have the same coordinates.


Member Data Documentation

TextDisplayable::TextOutputFormat TextDisplayable::_OutputFormat = rawText [static, protected, inherited]

The text format to be used currently by TextDisplayable instances.

Note:
Defaults to raw text.

Definition at line 158 of file CeylanTextDisplayable.h.

Referenced by Ceylan::TextDisplayable::GetOutputFormat(), and Ceylan::TextDisplayable::SetOutputFormat().

Tells what is the dimension for this vector.

Reimplemented from Ceylan::Maths::Linear::Vector.

Definition at line 312 of file CeylanVector3.h.

Referenced by getElementAt(), magnitude(), normalize(), setAllElementsTo(), setElementAt(), and toString().


The documentation for this class was generated from the following files:

Generated on Thu Jun 4 20:40:33 2009 for Ceylan by  doxygen 1.5.8