]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/kernel/include/marVector.h
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / lib / maracasVisuLib / src / kernel / include / marVector.h
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 // marVector.h: interface for the marVector class.
27 //
28 //////////////////////////////////////////////////////////////////////
29
30 #include <iostream>
31 #include <stddef.h>
32 class marVector  
33 {
34 public:
35 /*
36 Remarque : les (double*) sont organis�s ligne par ligne
37 */
38 /*==Constructeurs========================================*/
39         marVector(size_t s=3);
40         marVector(double* v,size_t s);
41         marVector(const marVector & v);
42 /*==Destructeur========================================*/
43         virtual ~marVector();
44
45 /*==Op�rateurs========================================*/
46         /* Affectation */
47         marVector& operator=(const marVector& o);
48     marVector& operator=(double o);
49     marVector& operator=(double* o);
50
51         /* Affichage */
52     friend std::ostream& operator<<(std::ostream& os, const marVector& v);
53
54         /* Casting */
55     operator double*() const ;
56
57         /* Indexation */
58         double& operator()(size_t i);
59     const double& operator()(size_t i) const;
60
61         /* Comparaison */
62     bool operator==(const marVector& o) const;
63     bool operator!=(const marVector& o) const;
64
65         /* Addition */
66     marVector operator+(const marVector& o);
67     marVector operator+(double o);
68     marVector operator+(double* o);
69         /* Addition + Affectation */
70     marVector& operator+=(const marVector& o);
71     marVector& operator+=(double o);
72     marVector& operator+=(double* o);
73
74         /* Soustraction */
75     marVector operator-(const marVector& o);
76     marVector operator-(double o);
77     marVector operator-(double* o);
78         /* Soustraction + Affectation */
79     marVector& operator-=(const marVector& o);
80     marVector& operator-=(double o);
81     marVector& operator-=(double* o);
82
83         /* Multiplication (produit scalaire) */
84     marVector operator*(double o);
85         /* Multiplication (produit scalaire) + Affectation */
86     marVector& operator*=(double o);
87
88         /* Division (division scalaire) */
89     marVector operator/(double o);
90         /* Division (division scalaire) + Affectation */
91     marVector& operator/=(double o);
92
93 /*==Op�rations========================================*/
94         /* produit scalaire */
95     double dot( const marVector& o );
96     double dot( double* o );
97         
98         /* produit vectoriel (3D uniquement): le resultat est renvoye */
99     marVector cross( const marVector& o );
100     marVector cross( double* o );
101         /* produit vectoriel (3D uniquement): le resultat est stock� dans this*/
102     int scross( const marVector& o ); // renvoie 0 si OK, 1 sinon
103     int scross( double* o ); // renvoie 0 si OK, 1 sinon
104
105         /* norme euclidienne */
106     double norm2( );
107
108         /* normalisation */
109     marVector normalize( ); // resultat renvoy�
110     int snormalize( ); // resultat stock� dans this, renvoie 0 si OK, 1 sinon
111
112 /*==M�thodes========================================*/
113         size_t size() const;
114
115 /*==Attributs========================================*/
116 private:
117         bool shallowCopy; // true if _data is a shallow copy of original data (pointer copy)
118         size_t _size;
119         double* _data;
120 };
121
122