]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/kernel/include/marVector.h
3e7f420232416730fa8d34a6d279c5487e7c8427
[creaMaracasVisu.git] / lib / maracasVisuLib / src / kernel / include / marVector.h
1 // marVector.h: interface for the marVector class.
2 //
3 //////////////////////////////////////////////////////////////////////
4
5 #include <iostream>
6 #include <stddef.h>
7 class marVector  
8 {
9 public:
10 /*
11 Remarque : les (double*) sont organisés ligne par ligne
12 */
13 /*==Constructeurs========================================*/
14         marVector(size_t s=3);
15         marVector(double* v,size_t s);
16         marVector(const marVector & v);
17 /*==Destructeur========================================*/
18         virtual ~marVector();
19
20 /*==Opérateurs========================================*/
21         /* Affectation */
22         marVector& operator=(const marVector& o);
23     marVector& operator=(double o);
24     marVector& operator=(double* o);
25
26         /* Affichage */
27     friend std::ostream& operator<<(std::ostream& os, const marVector& v);
28
29         /* Casting */
30     operator double*() const ;
31
32         /* Indexation */
33         double& operator()(size_t i);
34     const double& operator()(size_t i) const;
35
36         /* Comparaison */
37     bool operator==(const marVector& o) const;
38     bool operator!=(const marVector& o) const;
39
40         /* Addition */
41     marVector operator+(const marVector& o);
42     marVector operator+(double o);
43     marVector operator+(double* o);
44         /* Addition + Affectation */
45     marVector& operator+=(const marVector& o);
46     marVector& operator+=(double o);
47     marVector& operator+=(double* o);
48
49         /* Soustraction */
50     marVector operator-(const marVector& o);
51     marVector operator-(double o);
52     marVector operator-(double* o);
53         /* Soustraction + Affectation */
54     marVector& operator-=(const marVector& o);
55     marVector& operator-=(double o);
56     marVector& operator-=(double* o);
57
58         /* Multiplication (produit scalaire) */
59     marVector operator*(double o);
60         /* Multiplication (produit scalaire) + Affectation */
61     marVector& operator*=(double o);
62
63         /* Division (division scalaire) */
64     marVector operator/(double o);
65         /* Division (division scalaire) + Affectation */
66     marVector& operator/=(double o);
67
68 /*==Opérations========================================*/
69         /* produit scalaire */
70     double dot( const marVector& o );
71     double dot( double* o );
72         
73         /* produit vectoriel (3D uniquement): le resultat est renvoye */
74     marVector cross( const marVector& o );
75     marVector cross( double* o );
76         /* produit vectoriel (3D uniquement): le resultat est stocké dans this*/
77     int scross( const marVector& o ); // renvoie 0 si OK, 1 sinon
78     int scross( double* o ); // renvoie 0 si OK, 1 sinon
79
80         /* norme euclidienne */
81     double norm2( );
82
83         /* normalisation */
84     marVector normalize( ); // resultat renvoyé
85     int snormalize( ); // resultat stocké dans this, renvoie 0 si OK, 1 sinon
86
87 /*==Méthodes========================================*/
88         size_t size() const;
89
90 /*==Attributs========================================*/
91 private:
92         bool shallowCopy; // true if _data is a shallow copy of original data (pointer copy)
93         size_t _size;
94         double* _data;
95 };
96
97