8 #pragma warn -8022 // to remove some stupid warnings 12 #ifndef ISEEML_GEOM_VECTOR_HH 13 #define ISEEML_GEOM_VECTOR_HH 17 #include <iSeeML/geom/BasicObject.hpp> 67 XCoord( cos(theta) ), YCoord( sin(theta) ) {}
77 Vector(
const double& x,
const double& y) :
78 XCoord(x), YCoord(y) {}
111 const double&
xCoord()
const {
return XCoord; }
118 const double&
yCoord()
const {
return YCoord; }
140 (
isPositive(XCoord) ? atan(YCoord / XCoord) :
144 atan(YCoord / XCoord) - M_PI :
145 atan(YCoord / XCoord) + M_PI ) :
147 sign(YCoord) * M_PI_2 ); }
169 double sqrLength()
const {
return( (*
this) * (*
this) ); }
197 switch (i) {
case 1 :
return xCoord();
198 case 2 :
return yCoord();
default:
199 #ifdef ISEEML_CHECK_GEOM_VECT_PRECOND 200 cerr << ClassName <<
"::coord: parameter " << i << endl
201 <<
" outside allowed values (1 or 2), returning zero..." 221 { XCoord = x; YCoord = y;
return *
this; }
246 const double x = XCoord, y = YCoord,
247 ct = cos(theta), st = sin(theta);
248 XCoord = x * ct - y * st; YCoord = x * st + y * ct;
262 { XCoord += v.
xCoord(); YCoord += v.
yCoord();
return *
this; }
275 { XCoord *= f; YCoord *= f;
return *
this; }
293 #ifdef ISEEML_CHECK_GEOM_VECT_PRECOND 295 cerr << ClassName <<
"::divide: zero factor!!!" << endl;
341 {
Vector res(*
this);
return res.
add(v); }
353 {
return( *
this + (-v) ); }
507 #endif // end of definition Vector operator*(const double &f) const
Multiplication operator between a vector and a real.
Definition: Vector.hpp:376
This class defines 2D geometric vectors, which can be defined by their Polar or Cartesian coordinates...
Definition: Vector.hpp:34
This class is the base class of ISeeML: every class of ISeeML inherits this one.
Definition: Object.hpp:47
Vector(const double &theta)
A simple constructor, creating the unit vector of given orientation.
Definition: Vector.hpp:66
double sqrLength() const
Description method, giving the square of the vector's length.
Definition: Vector.hpp:169
double operator^(const Vector &v) const
Vectorial product operator between two vectors.
Definition: Vector.hpp:437
static int sign(const double &x)
Method giving the sign of a double.
Definition: Object.hpp:301
Vector & rotate(const double &theta)
Modification method, rotating the vector of a given angle.
Definition: Vector.hpp:245
bool operator==(const Vector &other) const
Equality operator between vectors (differences between both Cartesian coordinates should be zero)...
Definition: Vector.hpp:326
This class defines basic 2D geometric objects, from which compound geometric objects are built...
Definition: BasicObject.hpp:21
Vector()
The default constructor, creating the zero vector with Cartesian coordinates (0,0).
Definition: Vector.hpp:53
Vector & moveTo(const double &x, const double &y)
Modification method, moving the point to a given position.
Definition: Vector.hpp:220
Vector & translate(const Vector &v)
Modification method, translating the vector along an other.
Definition: Vector.hpp:234
static Vector FresnelInt(const double &s)
Various method, computing the Fresnel integrals in a vector.
iSeeML::Object & clone() const
Description method, giving a copy of the current vector.
Definition: Vector.hpp:92
virtual void algWriteTo(ostream &O) const
Description method for algebraic vectors, writing this vector in a given output stream: coordinates f...
Definition: Object.hpp:161
void writeTo(ostream &O) const
Description method, writing a description of the vector into a stream: Cartesian coordinate in each d...
Definition: Vector.hpp:103
int algDimension() const
Description method, giving the dimension of the containing space (2) when this vector is considered a...
Definition: Vector.hpp:180
Vector & multiply(const double &f)
Modification method, multiplying a vector by a real factor.
Definition: Vector.hpp:274
friend Vector operator*(const double &f, const Vector &v)
Multiplication operator between a real and a vector.
Definition: Vector.hpp:388
static bool isPositive(const double &x)
Method telling whether a double is strictly positive.
Definition: Object.hpp:264
Vector operator/(const double &f) const
Division operator between a vector and a real.
Definition: Vector.hpp:402
static const string ClassName
The class name is public, as this class can be instanced.
Definition: Vector.hpp:45
static bool isNegative(const double &x)
Method telling whether a double is strictly negative.
Definition: Object.hpp:278
Vector & add(const Vector &v)
Modification method, adding a vector to the current one.
Definition: Vector.hpp:261
const double & xCoord() const
Description method, giving the vector's first Cartesian coordinate.
Definition: Vector.hpp:111
friend Vector operator/(const double &f, const Vector &v)
Division operator between a real and a vector.
Definition: Vector.hpp:416
double length() const
Description method, giving the vector's length.
Definition: Vector.hpp:159
Vector operator+(const Vector &v) const
Sum operator between two vectors, giving the translation of the first one by the other.
Definition: Vector.hpp:340
static double FresnelCos(const double &s)
Various method, computing the Fresnel Cosine integral.
Definition: Vector.hpp:457
Vector(const double &x, const double &y)
The main constructor, creating a vector from its Cartesian coordinates.
Definition: Vector.hpp:77
double orientation() const
Description method, giving the vector's orientation.
Definition: Vector.hpp:137
Vector & divide(const double &f)
Division method, dividing a vector by a real factor.
Definition: Vector.hpp:292
Vector operator-(const Vector &v) const
Difference operator between two vectors, giving the sum of the first vector and of the second one's o...
Definition: Vector.hpp:352
double algCoord(const int i) const
Description method, giving Cartesian coordinate of given index for the vector.
Definition: Vector.hpp:196
static double FresnelSin(const double &s)
Various method, computing the Fresnel Sine integral.
Definition: Vector.hpp:474
const double & yCoord() const
Description method, giving the vector's second Cartesian coordinate.
Definition: Vector.hpp:118
static bool isZero(const double &x)
Method comparing a double to zero.
Definition: Object.hpp:288
double operator*(const Vector &v) const
Scalar product operator between two vectors.
Definition: Vector.hpp:427
Vector & symmetryOx()
Modification method, transforming a vector into its symmetric with respect to the X axis...
Definition: Vector.hpp:305
Vector & symmetryOy()
Modification method, transforming a vector into its symmetric with respect to the Y axis...
Definition: Vector.hpp:312
Vector operator-() const
Opposite operator for a vector, such that the sum of the vector and of its opposite is the zero vecto...
Definition: Vector.hpp:363