Ceylan::Maths::Linear::Vector2 Class Reference

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

#include <CeylanVector2.h>

Inheritance diagram for Ceylan::Maths::Linear::Vector2:
Inheritance graph
[legend]
Collaboration diagram for Ceylan::Maths::Linear::Vector2:
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

 Vector2 (Real x0=0, Real x1=0)
 Constructs a new vector with specified coordinates.
 Vector2 (const Real(&array)[2])
 Constructs a new vector from specified array of two floating-point coordinates.
virtual ~Vector2 () throw ()
 Basic virtual destructor.
virtual void setTo (Real x0, Real x1)
 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 getX () const
 Returns the abscissa of this vector.
virtual Real getY () const
 Returns the ordinate of this vector.
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 = 2
 Tells what is the dimension for this point.

Protected Attributes

Real _vec [Dimensions]
 The three coordinates of this vector.

Static Protected Attributes

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

Friends

class Bipoint
 Must access to each other's coordinates.
class Matrix2
 Must access to each other's coordinates.
CEYLAN_DLL friend bool operator== (const Vector2 &v1, const Vector2 &v2)
 Tells whether the two vectors have the same elements.
CEYLAN_DLL friend bool operator!= (const Vector2 &v1, const Vector2 &v2)
 Tells whether the two vectors have exactly the same elements.
CEYLAN_DLL friend Bipoint operator+ (const Bipoint &t, const Vector2 &v)
 Translates a 2D point of specified 2D vector: result = t + v.
CEYLAN_DLL friend Bipoint operator- (const Bipoint &t, const Vector2 &v)
 Translates a 2D point of specified opposite 2D vector: result = t - v.
CEYLAN_DLL friend Vector2 vectorize (const Bipoint &t)
 Transforms a 2D point into a 2D vector, which will have the same coordinates.
CEYLAN_DLL friend Vector2 vectorize (const Bipoint &t1, const Bipoint &t2)
 Constructs a 2D vector from two 2D points: result = t1 - t2.
CEYLAN_DLL friend Vector2 operator+ (const Vector2 &v1, const Vector2 &v2)
 Adds two vectors: result = v1 + v2.
CEYLAN_DLL friend Vector2 operator- (const Vector2 &v1, const Vector2 &v2)
 Substracts two vectors: result = v1 - v2.
CEYLAN_DLL friend Vector2 operator* (Real lambda, const Vector2 &v)
 Multiplies v by coefficient lambda: result = lamba.v.
CEYLAN_DLL friend Vector2 operator* (const Matrix2 &m, const Vector2 &v)
 Applies vector v to matrix m: result = m.v.
CEYLAN_DLL friend Vector2 operator* (const HomogeneousMatrix3 &m, const Vector2 &v)
 Applies vector v to homogeneous matrix hm: result = hm.v.
CEYLAN_DLL friend Real operator| (const Vector2 &v1, const Vector2 &v2)
 Computes the dot product of v1 and v2: result = v1 (dotproduct) v2.
CEYLAN_DLL friend Real operator~ (const Vector2 &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 72 of file CeylanVector2.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

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

Constructs a new vector with specified coordinates.

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

Definition at line 63 of file CeylanVector2.cc.

References _vec.

Vector2::Vector2 ( const Real(&)  array[2]  )  [explicit]

Constructs a new vector from specified array of two floating-point coordinates.

Definition at line 73 of file CeylanVector2.cc.

References _vec.

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

Basic virtual destructor.

Definition at line 83 of file CeylanVector2.cc.


Member Function Documentation

Real Vector2::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 139 of file CeylanVector2.cc.

References _vec, and Dimensions.

Referenced by Ceylan::Maths::Linear::Rotation2DFunctor::operator()(), and Ceylan::Maths::Linear::HomogeneousMatrix3::setTranslationVector().

TextDisplayable::TextOutputFormat TextDisplayable::GetOutputFormat (  )  [static, inherited]
Real Vector2::getX (  )  const [virtual]

Returns the abscissa of this vector.

Definition at line 121 of file CeylanVector2.cc.

References _vec.

Real Vector2::getY (  )  const [virtual]

Returns the ordinate of this vector.

Definition at line 130 of file CeylanVector2.cc.

References _vec.

Real Vector2::magnitude (  )  const [virtual]

Returns this vector's magnitude.

See also:
operator ~

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

Definition at line 193 of file CeylanVector2.cc.

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

Referenced by normalize().

void Vector2::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 173 of file CeylanVector2.cc.

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

void Vector2::nullify (  )  [virtual]

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

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

Definition at line 100 of file CeylanVector2.cc.

References setAllElementsTo().

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

Sets this vector so that all its elements equal commonValue.

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

Definition at line 109 of file CeylanVector2.cc.

References _vec, and Dimensions.

Referenced by nullify().

void Vector2::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 156 of file CeylanVector2.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 Vector2::setTo ( Real  x0,
Real  x1 
) [virtual]

Reassigns this vector's coordinates.

Definition at line 90 of file CeylanVector2.cc.

References _vec.

Referenced by Ceylan::Maths::Linear::Matrix2::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 Vector2::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 211 of file CeylanVector2.cc.

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


Friends And Related Function Documentation

friend class Bipoint [friend]

Must access to each other's coordinates.

Definition at line 80 of file CeylanVector2.h.

friend class Matrix2 [friend]

Must access to each other's coordinates.

Definition at line 84 of file CeylanVector2.h.

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

Tells whether the two vectors have exactly the same elements.

CEYLAN_DLL friend Vector2 operator* ( const HomogeneousMatrix3 m,
const Vector2 v 
) [friend]

Applies vector v to homogeneous matrix hm: result = hm.v.

CEYLAN_DLL friend Vector2 operator* ( const Matrix2 m,
const Vector2 v 
) [friend]

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

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

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

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

Adds two vectors: result = v1 + v2.

CEYLAN_DLL friend Bipoint operator+ ( const Bipoint t,
const Vector2 v 
) [friend]

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

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

Substracts two vectors: result = v1 - v2.

CEYLAN_DLL friend Bipoint operator- ( const Bipoint t,
const Vector2 v 
) [friend]

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

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

Tells whether the two vectors have the same elements.

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

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

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

Returns the magnitude of specified vector.

CEYLAN_DLL friend Vector2 vectorize ( const Bipoint t1,
const Bipoint t2 
) [friend]

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

CEYLAN_DLL friend Vector2 vectorize ( const Bipoint t  )  [friend]

Transforms a 2D point into a 2D 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 point.

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

Definition at line 343 of file CeylanVector2.h.

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


The documentation for this class was generated from the following files:
Generated on Mon Nov 29 13:41:24 2010 for Ceylan by  doxygen 1.6.3