forked from forefireAPI/firefront
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFFVector.h
122 lines (101 loc) · 3.9 KB
/
FFVector.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
Copyright (C) 2012 ForeFire Team, SPE, UniversitŽ de Corse.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 US
*/
#ifndef FFVECTOR_H_
#define FFVECTOR_H_
#include "Futils.h"
#include "FFPoint.h"
using namespace std;
namespace libforefire{
/*! \class FFVector
* \brief 3d vectors for LibForeFire
*
* FFPoint defines 3d vectors and methods associated with it.
*/
class FFVector {
double vx; /*!< component along x axis */
double vy; /*!< component along y axis */
double vz; /*!< component along z axis */
static const double epsilonv;
static const double Pi;
public:
/*! \brief Default constructor */
FFVector();
/*! \brief 2d Constructor (vz=0.) */
FFVector(double, double);
/*! \brief 3d Constructor */
FFVector(double, double, double);
/*! \brief Constructor from two FFPoints */
FFVector(FFPoint, FFPoint);
/*! \brief Destructor */
virtual ~FFVector();
/*! \brief Copy-constructor */
FFVector(const FFVector&);
/*! \brief overloaded operator + */
friend const FFVector operator+(const FFVector&, const FFVector&);
/*! \brief overloaded operator - */
friend const FFVector operator-(const FFVector&, const FFVector&);
/*! \brief overloaded operator *, multiplication by a double */
friend const FFVector operator*(const double&, const FFVector&);
/*! \brief overloaded operator += */
friend FFVector& operator+=(FFVector&, const FFVector&);
/*! \brief overloaded operator -= */
friend FFVector& operator-=(FFVector&, const FFVector&);
/*! \brief overloaded operator *=, multiplication by a double */
friend FFVector& operator*=(FFVector&, const double&);
/*! \brief overloaded operator == */
friend int operator==(const FFVector&, const FFVector&);
/*! \brief overloaded operator != */
friend int operator!=(const FFVector&, const FFVector&);
/*! \brief accessor to 'vx' */
double getVx();
/*! \brief accessor to 'vy' */
double getVy();
/*! \brief accessor to 'vz' */
double getVz();
/*! \brief accessor to vector itself */
FFVector& getVec();
/*! \brief mutator of the variable 'vx' */
void setVx(const double&);
/*! \brief mutator of the variable 'vy' */
void setVy(const double&);
/*! \brief mutator of the variable 'vz' */
void setVz(const double&);
/*! \brief mutator of the vector itself */
void setVec(const double&, const double&, const double&);
/*! \brief Cast into a 'FFpoint' */
FFPoint toPoint();
/*! \brief computing the angle in a spherical representation */
double toAngle();
/*! \brief norm of the vector
* \return norm of the vector */
const double norm();
/*! \brief normalization of the vector */
void normalize();
/*! \brief normalized version of the vector
* \return a normalized vector with the same direction */
FFVector normed();
/*! \brief scalar product with another vector
* \param[in] 'vec' : other vector
* \return scalar product between the two vectors */
double scalarProduct(const FFVector& vec);
/*! \brief vector product with another vector
* \param[in] 'vec' : other vector
* \return vector product between the two vectors */
FFVector crossProduct(const FFVector& vec);
/*! \brief printing function */
string print();
};
}
#endif /* FFVECTOR_H_ */