Three-dimensional vector, whose coordinates are floating-point values (Real). More...
#include <CeylanVector2.h>
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. |
Three-dimensional vector, whose coordinates are floating-point values (Real).
Definition at line 72 of file CeylanVector2.h.
enum Ceylan::TextDisplayable::TextOutputFormat [inherited] |
Defines what text output formats for TextDisplayable instances are available.
Definition at line 124 of file CeylanTextDisplayable.h.
Constructs a new vector with specified coordinates.
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.
Real Vector2::getElementAt | ( | MatrixIndex | index | ) | const [virtual] |
Returns indexed element.
Index ranges from 0 to Dimensions-1.
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] |
Returns the current overall text format to be used by TextDisplayable instances.
Definition at line 63 of file CeylanTextDisplayable.cc.
References Ceylan::TextDisplayable::_OutputFormat.
Referenced by Ceylan::formatStringList(), Ceylan::formatStringMap(), Ceylan::XML::XMLMarkup::toString(), Ceylan::Maths::Linear::Vector3::toString(), toString(), Ceylan::Maths::Linear::Tripoint::toString(), Ceylan::Module::toString(), Ceylan::Maths::Linear::Matrix3::toString(), Ceylan::Maths::Linear::Matrix2::toString(), Ceylan::Maths::Linear::HomogeneousMatrix3::toString(), and Ceylan::Maths::Linear::Bipoint::toString().
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.
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.
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.
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.
newOutputFormat | the new output format. |
Definition at line 72 of file CeylanTextDisplayable.cc.
References Ceylan::TextDisplayable::_OutputFormat.
Referenced by Ceylan::Log::LogHolder::LogHolder().
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.
displayables | a list of pointers to TextDisplayable instances/ | |
level | the requested verbosity level. |
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.
level | the requested verbosity level. |
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.
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.
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.
Applies vector v to matrix m: result = m.v.
Multiplies v by coefficient lambda: result = lamba.v.
Adds two vectors: result = v1 + v2.
Translates a 2D point of specified 2D vector: result = t + v.
Substracts two vectors: result = v1 - v2.
Translates a 2D point of specified opposite 2D vector: result = t - v.
Tells whether the two vectors have the same elements.
Computes the dot product of v1 and v2: result = v1 (dotproduct) v2.
Returns the magnitude of specified vector.
Constructs a 2D vector from two 2D points: result = t1 - t2.
Transforms a 2D point into a 2D vector, which will have the same coordinates.
TextDisplayable::TextOutputFormat TextDisplayable::_OutputFormat = rawText [static, protected, inherited] |
The text format to be used currently by TextDisplayable instances.
Definition at line 158 of file CeylanTextDisplayable.h.
Referenced by Ceylan::TextDisplayable::GetOutputFormat(), and Ceylan::TextDisplayable::SetOutputFormat().
Real Ceylan::Maths::Linear::Vector2::_vec[Dimensions] [protected] |
The three coordinates of this vector.
Definition at line 351 of file CeylanVector2.h.
Referenced by getElementAt(), getX(), getY(), magnitude(), normalize(), setAllElementsTo(), Ceylan::Maths::Linear::Matrix2::setColumn(), setElementAt(), setTo(), toString(), and Vector2().
const MatrixIndex Ceylan::Maths::Linear::Vector2::Dimensions = 2 [static] |
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().