ISeeML  1.0
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Friends | List of all members
iSeeML::geom::Vector Class Reference

This class defines 2D geometric vectors, which can be defined by their Polar or Cartesian coordinates. More...

#include <Vector.hpp>

Inheritance diagram for iSeeML::geom::Vector:
Inheritance graph
[legend]
Collaboration diagram for iSeeML::geom::Vector:
Collaboration graph
[legend]

Public Member Functions

 Vector ()
 The default constructor, creating the zero vector with Cartesian coordinates (0,0).
 
 Vector (const double &theta)
 A simple constructor, creating the unit vector of given orientation. More...
 
 Vector (const double &x, const double &y)
 The main constructor, creating a vector from its Cartesian coordinates. More...
 
iSeeML::Objectclone () const
 Description method, giving a copy of the current vector. More...
 
void writeTo (ostream &O) const
 Description method, writing a description of the vector into a stream: Cartesian coordinate in each dimension is written, between paranthesis and separated by commas. More...
 
const double & xCoord () const
 Description method, giving the vector's first Cartesian coordinate. More...
 
const double & yCoord () const
 Description method, giving the vector's second Cartesian coordinate. More...
 
double orientation () const
 Description method, giving the vector's orientation. More...
 
double length () const
 Description method, giving the vector's length. More...
 
double sqrLength () const
 Description method, giving the square of the vector's length. More...
 
VectormoveTo (const double &x, const double &y)
 Modification method, moving the point to a given position. More...
 
Vectortranslate (const Vector &v)
 Modification method, translating the vector along an other. More...
 
Vectorrotate (const double &theta)
 Modification method, rotating the vector of a given angle. More...
 
Vectoradd (const Vector &v)
 Modification method, adding a vector to the current one. More...
 
Vectormultiply (const double &f)
 Modification method, multiplying a vector by a real factor. More...
 
Vectordivide (const double &f)
 Division method, dividing a vector by a real factor. More...
 
VectorsymmetryOx ()
 Modification method, transforming a vector into its symmetric with respect to the X axis. More...
 
VectorsymmetryOy ()
 Modification method, transforming a vector into its symmetric with respect to the Y axis. More...
 
bool operator== (const Vector &other) const
 Equality operator between vectors (differences between both Cartesian coordinates should be zero). More...
 
Vector operator+ (const Vector &v) const
 Sum operator between two vectors, giving the translation of the first one by the other. More...
 
Vector operator- (const Vector &v) const
 Difference operator between two vectors, giving the sum of the first vector and of the second one's opposite. More...
 
Vector operator- () const
 Opposite operator for a vector, such that the sum of the vector and of its opposite is the zero vector. More...
 
Vector operator* (const double &f) const
 Multiplication operator between a vector and a real. More...
 
Vector operator/ (const double &f) const
 Division operator between a vector and a real. More...
 
double operator* (const Vector &v) const
 Scalar product operator between two vectors. More...
 
double operator^ (const Vector &v) const
 Vectorial product operator between two vectors. More...
 
- Public Member Functions inherited from iSeeML::geom::Object
virtual bool operator== (const iSeeML::geom::Object &other) const
 Equality operator between geometric objects. More...
 
- Public Member Functions inherited from iSeeML::Object
virtual ~Object ()
 This virtual class needs a virtual destructor.
 
virtual const string className () const
 Description method, giving the object's class name. More...
 
bool sameClass (const iSeeML::Object &other)
 Method verifying that a given object has the same type (same class name) than the current one. More...
 

Static Public Member Functions

static double FresnelCos (const double &s)
 Various method, computing the Fresnel Cosine integral. More...
 
static double FresnelSin (const double &s)
 Various method, computing the Fresnel Sine integral. More...
 
static Vector FresnelInt (const double &s)
 Various method, computing the Fresnel integrals in a vector. More...
 
- Static Public Member Functions inherited from iSeeML::Object
template<class T >
static const T & min (const T &a, const T &b)
 Method giving the minimum of two elements. More...
 
template<class T >
static const T & max (const T &a, const T &b)
 Method giving the maximum of two elements. More...
 
static double sqr (const double &x)
 Method giving the square of a double. More...
 
static double mod2pi (const double &theta)
 Method giving the angle between - $\pi$ (excluded) and $\pi$ (included), which is equal to a given angle modulo 2 $\pi$. More...
 
static double rad2deg (const double &theta)
 Method transforming an angle in radian, $x \pi$ with $x$ between -1 (excluded) and 1 (included), into its equivalent in degree, i.e. More...
 
static double deg2rad (const double &theta)
 Method transforming an angle in degree, $90 x$ with $x$ between -1 (excluded) and 1 (included), into its equivalent in radian, i.e. More...
 
static bool isPositive (const double &x)
 Method telling whether a double is strictly positive. More...
 
static bool isNegative (const double &x)
 Method telling whether a double is strictly negative. More...
 
static bool isZero (const double &x)
 Method comparing a double to zero. More...
 
static int sign (const double &x)
 Method giving the sign of a double. More...
 

Static Public Attributes

static const string ClassName
 The class name is public, as this class can be instanced. More...
 

Protected Member Functions

int algDimension () const
 Description method, giving the dimension of the containing space (2) when this vector is considered as an algebraic one. More...
 
double algCoord (const int i) const
 Description method, giving Cartesian coordinate of given index for the vector. More...
 
- Protected Member Functions inherited from iSeeML::Object
virtual void algWriteTo (ostream &O) const
 Description method for algebraic vectors, writing this vector in a given output stream: coordinates for each dimension are written, between paranthesis and separated by commas. More...
 

Friends

Vector operator* (const double &f, const Vector &v)
 Multiplication operator between a real and a vector. More...
 
Vector operator/ (const double &f, const Vector &v)
 Division operator between a real and a vector. More...
 

Additional Inherited Members

Detailed Description

This class defines 2D geometric vectors, which can be defined by their Polar or Cartesian coordinates.

This class contains description methods giving Polar and Cartesian coordinates as well as the writeTo method, modification methods giving translation, rotation, scaling and symmetry of a vector, the corresponding operators as well as the equality operator, and a last method computing Cartesian coordinates of a reference clothoid (which are Fresnel integrals).

Author
Alexis Scheuer.
Version
1.0
Examples:
wxGuiFwd.cpp.

Constructor & Destructor Documentation

iSeeML::geom::Vector::Vector ( const double &  theta)
inline

A simple constructor, creating the unit vector of given orientation.

The vector of Polar coordinates (rho, theta) can thus be obtained using iSeeML::geom::Vector(theta).multiply(rho).

Parameters
thetathe orientation of the vector.
See also
orientation, length, multiply.
iSeeML::geom::Vector::Vector ( const double &  x,
const double &  y 
)
inline

The main constructor, creating a vector from its Cartesian coordinates.

Parameters
xthe first Cartesian coordinate of the vector,
ythe second Cartesian coordinate of the vector.
See also
xCoord, yCoord.

Member Function Documentation

Vector& iSeeML::geom::Vector::add ( const Vector v)
inline

Modification method, adding a vector to the current one.

The original vector is changed, addition without modification is obtained using operator+(const Vector&) const.

Parameters
vthe vector of the translation.
Returns
the new vector, after translation / addition.
double iSeeML::geom::Vector::algCoord ( const int  i) const
inlineprotectedvirtual

Description method, giving Cartesian coordinate of given index for the vector.

Parameters
ithe index of the searched Cartesian coordinate.
Precondition
the parameter is an index, and should be equal to one or two. If not, and if ISEEML_CHECK_GEOM_VECT_PRECOND is defined (see CompilerFlags.h), an error is generated.
Returns
the Cartesian coordinate associated to the index if this one is between 1 and dimension, or 0.
See also
xCoord, yCoord, algDimension.

Reimplemented from iSeeML::Object.

int iSeeML::geom::Vector::algDimension ( ) const
inlineprotectedvirtual

Description method, giving the dimension of the containing space (2) when this vector is considered as an algebraic one.

This representation is mainly used to define a unified writeTo. Dimension cannot be static, as it is virtual.

Reimplemented from iSeeML::Object.

iSeeML::Object& iSeeML::geom::Vector::clone ( ) const
inlinevirtual

Description method, giving a copy of the current vector.

This clone is dynamically allocated (using default copy constructor), it has to be deleted later.

Returns
a copy/clone of the current vector.

Implements iSeeML::Object.

Vector& iSeeML::geom::Vector::divide ( const double &  f)
inline

Division method, dividing a vector by a real factor.

The original vector is changed, division without modification is obtained using operator/() const.

Parameters
fa real factor.
Precondition
the dividing factor should not be zero. If it is, and ISEEML_CHECK_GEOM_VECT_PRECOND is defined (see CompilerFlags.h), an error is generated.
Returns
the new vector, after division.
See also
multiply.
static double iSeeML::geom::Vector::FresnelCos ( const double &  s)
inlinestatic

Various method, computing the Fresnel Cosine integral.

Parameters
sthe integration length.
Precondition
Coordinates have only been computed for values of the arc length s smaller (in absolute value) then 2, which correspond to a deflection (change of the orientation) of $\pm$ 2 $\pi$.
Returns
the integral, from zero to s, of cos( $\pi$ u2 / 2).
See also
FresnelInt, xCoord.
static Vector iSeeML::geom::Vector::FresnelInt ( const double &  s)
static

Various method, computing the Fresnel integrals in a vector.

The returned vector correspond to the Cartesian coordinates of the point of given arc length along a reference clothoid (along which curvature is equal to $\pi$ times the arc length). These coordinates have been precomputed with a precision of 1E-5, and are stored in two static arrays.

Parameters
sthe arc length along the reference clothoid of the searched position, or the integration length of the Fresnel integrals.
Precondition
Coordinates have only been computed for values of the arc length s smaller (in absolute value) then 2, which correspond to a deflection (change of the orientation) of $\pm$ 2 $\pi$. An error message is generated if s is not correct and check flags ISEEML_CHECK_GEOM_VECT_PRECOND or ISEEML_CHECK_ARRAY_ELEMT (see CompilerFlags.h) are defined.
Returns
the vector whose Cartesian coordinates are the integral, from zero to s, of respectively cos( $\pi$ u2 / 2) and sin( $\pi$ u2 / 2).
static double iSeeML::geom::Vector::FresnelSin ( const double &  s)
inlinestatic

Various method, computing the Fresnel Sine integral.

Parameters
sthe integration length.
Precondition
Coordinates have only been computed for values of the arc length s smaller (in absolute value) then 2, which correspond to a deflection (change of the orientation) of $\pm$ 2 $\pi$.
Returns
the integral, from zero to s, of sin( $\pi$ u2 / 2).
See also
FresnelInt, yCoord.
double iSeeML::geom::Vector::length ( ) const
inline

Description method, giving the vector's length.

The couple (length, orientation) gives Polar coordinates of the vector, while the couple (xCoord, yCoord) gives Cartesian coordinates.

Returns
the vector's length.
See also
sqrLength.
Vector& iSeeML::geom::Vector::moveTo ( const double &  x,
const double &  y 
)
inline

Modification method, moving the point to a given position.

The original vector is changed.

Parameters
xthe first coordinate of the new position,
ythe second coordinate of the new position.
Returns
the vector, after tranformation.
See also
xCoord, yCoord.
Vector& iSeeML::geom::Vector::multiply ( const double &  f)
inline

Modification method, multiplying a vector by a real factor.

The original vector is changed, multiplication without modification is obtained using operator*() const.

Parameters
fa real factor.
Returns
the new vector, after multiplication.
Vector iSeeML::geom::Vector::operator* ( const double &  f) const
inline

Multiplication operator between a vector and a real.

Parameters
fa real factor.
Returns
the product of the current vector by the real factor.
See also
multiply.
double iSeeML::geom::Vector::operator* ( const Vector v) const
inline

Scalar product operator between two vectors.

Parameters
vthe second vector of the product.
Returns
the scalar product between the current vector and the given one.
Vector iSeeML::geom::Vector::operator+ ( const Vector v) const
inline

Sum operator between two vectors, giving the translation of the first one by the other.

Parameters
vthe vector of the translation.
Returns
the sum of the two vectors.
See also
add.
Vector iSeeML::geom::Vector::operator- ( const Vector v) const
inline

Difference operator between two vectors, giving the sum of the first vector and of the second one's opposite.

Parameters
va vector.
Returns
the current vector minus the given one.
See also
operator-(), operator+.
Vector iSeeML::geom::Vector::operator- ( ) const
inline

Opposite operator for a vector, such that the sum of the vector and of its opposite is the zero vector.

Returns
the opposite of the current vector.
See also
multiply.
Vector iSeeML::geom::Vector::operator/ ( const double &  f) const
inline

Division operator between a vector and a real.

Parameters
fa real factor.
Precondition
the dividing factor should not be zero.
Returns
the division of the current vector by the real factor.
See also
operator*(const double&), divide.
bool iSeeML::geom::Vector::operator== ( const Vector other) const
inline

Equality operator between vectors (differences between both Cartesian coordinates should be zero).

Parameters
otheranother vector.
Returns
whether the two vectors are equal.
See also
xCoord, yCoord, iSeeML::Object::isZero.
double iSeeML::geom::Vector::operator^ ( const Vector v) const
inline

Vectorial product operator between two vectors.

Parameters
vthe second vector of the product.
Returns
the vectorial product between the current vector and the given one.
double iSeeML::geom::Vector::orientation ( ) const
inline

Description method, giving the vector's orientation.

The couple (length, orientation) gives Polar coordinates of the vector, while the couple (xCoord, yCoord) gives Cartesian coordinates. Orientation is always uniquely defined, except for zero vector. In that case, we choose to return 0.

Returns
the vector's orientation, between - $\pi$ (excluded) and $\pi$ (included), if vector is not zero, or zero.
See also
iSeeML::Object::isPositive, iSeeML::Object::isNegative, iSeeML::Object::sign, atan.
Vector& iSeeML::geom::Vector::rotate ( const double &  theta)
inline

Modification method, rotating the vector of a given angle.

The original vector is changed.

Parameters
thetathe angle of the rotation.
Returns
the new vector, after rotation.
double iSeeML::geom::Vector::sqrLength ( ) const
inline

Description method, giving the square of the vector's length.

Uses the scalar product.

Returns
the square of the vector's length.
See also
operator*(const iSeeML::geom::Vector&).
Vector& iSeeML::geom::Vector::symmetryOx ( )
inline

Modification method, transforming a vector into its symmetric with respect to the X axis.

Returns
the new vector, after transformation.
Vector& iSeeML::geom::Vector::symmetryOy ( )
inline

Modification method, transforming a vector into its symmetric with respect to the Y axis.

Returns
the new vector, after transformation.
Vector& iSeeML::geom::Vector::translate ( const Vector v)
inlinevirtual

Modification method, translating the vector along an other.

The original vector is changed, addition without modification is obtained using operator+(const Vector&) const.

Parameters
vthe vector of the translation.
Returns
the new vector, after translation.
See also
add.

Implements iSeeML::geom::Object.

void iSeeML::geom::Vector::writeTo ( ostream &  O) const
inlinevirtual

Description method, writing a description of the vector into a stream: Cartesian coordinate in each dimension is written, between paranthesis and separated by commas.

Parameters
Othe output stream in which description is written.

Implements iSeeML::Object.

const double& iSeeML::geom::Vector::xCoord ( ) const
inline

Description method, giving the vector's first Cartesian coordinate.

Returns
the vector's first Cartesian coordinate.
const double& iSeeML::geom::Vector::yCoord ( ) const
inline

Description method, giving the vector's second Cartesian coordinate.

Returns
the vector's second Cartesian coordinate.

Friends And Related Function Documentation

Vector operator* ( const double &  f,
const Vector v 
)
friend

Multiplication operator between a real and a vector.

Parameters
fthe real factor,
vthe vector.
Returns
the product between the factor and the vector.
See also
const operator*(const double&).
Vector operator/ ( const double &  f,
const Vector v 
)
friend

Division operator between a real and a vector.

Parameters
fthe real factor,
vthe vector.
Precondition
the dividing factor should not be zero.
Returns
the division between the factor and the vector.
See also
const operator/(const double&).

Member Data Documentation

const string iSeeML::geom::Vector::ClassName
static

The class name is public, as this class can be instanced.

See also
className.

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