MeVisLab Toolbox Reference
mlVector5.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef ML_VECTOR5_H
14 #define ML_VECTOR5_H
15 
17 
18 // Include system independent file and project settings.
19 #include "mlLinearAlgebraSystem.h"
20 #include "mlLinearAlgebraDefs.h"
21 #include "mlFloatingPointVector.h"
22 #include "mlVector2.h"
23 #include "mlVector3.h"
24 #include "mlVector4.h"
25 #include "mlMatrix5.h"
26 
27 // All declarations of this header will be in the ML_LINEAR_ALGEBRA namespace.
28 ML_LA_START_NAMESPACE
29 
30 //--------------------------------------------------------------------
32 // This is necessary because we do not known whether vector or
33 // matrix header is included first and we cannot move template
34 // code into C++ file.
35 //--------------------------------------------------------------------
36 template <class DT> class Tvec2;
37 template <class DT> class Tvec3;
38 template <class DT> class Tvec4;
39 template <class DT> class Tmat5;
41 
42 //--------------------------------------------------------------------
44 //--------------------------------------------------------------------
46 template <class DT>
47 class Tvec5 : public FloatingPointVector<DT,5>
48 {
49 public:
50 
53 
55  typedef DT ComponentType;
56 
57  //--------------------------------------------------------------------
60  //--------------------------------------------------------------------
63  inline explicit Tvec5(const DT value=0) : Superclass(value)
64  {
65  }
66 
68  inline Tvec5(const Superclass &v) : Superclass(v)
69  {
70  }
71 
74  inline Tvec5(const DT x, const DT y, const DT z, const DT c, const DT t)
75  {
76  Superclass::_buffer[0] = x;
77  Superclass::_buffer[1] = y;
78  Superclass::_buffer[2] = z;
79  Superclass::_buffer[3] = c;
80  Superclass::_buffer[4] = t;
81  }
82 
84  inline Tvec5(const Tvec2<DT>& v, const DT z, const DT c, const DT t)
85  {
86  Superclass::_buffer[0] = v[0];
87  Superclass::_buffer[1] = v[1];
88  Superclass::_buffer[2] = z;
89  Superclass::_buffer[3] = c;
90  Superclass::_buffer[4] = t;
91  }
92 
94  inline Tvec5(const Tvec3<DT>& v, const DT c, const DT t)
95  {
96  Superclass::_buffer[0] = v[0];
97  Superclass::_buffer[1] = v[1];
98  Superclass::_buffer[2] = v[2];
99  Superclass::_buffer[3] = c;
100  Superclass::_buffer[4] = t;
101  }
102 
104  inline Tvec5(const Tvec4<DT>& v, const DT t)
105  {
106  Superclass::_buffer[0] = v[0];
107  Superclass::_buffer[1] = v[1];
108  Superclass::_buffer[2] = v[2];
109  Superclass::_buffer[3] = v[3];
110  Superclass::_buffer[4] = t;
111  }
113 
114  //--------------------------------------------------------------------
117  //--------------------------------------------------------------------
119  inline void assign(const DT x, const DT y, const DT z, const DT c, const DT t)
120  {
121  Superclass::_buffer[0] = x;
122  Superclass::_buffer[1] = y;
123  Superclass::_buffer[2] = z;
124  Superclass::_buffer[3] = c;
125  Superclass::_buffer[4] = t;
126  }
127 
129  inline Tvec5<DT>& operator+=(const Tvec2<DT>& v)
130  {
131  Superclass::_buffer[0] += v[0];
132  Superclass::_buffer[1] += v[1];
133  return *this;
134  }
135 
137  inline Tvec5<DT>& operator+=(const Tvec3<DT>& v)
138  {
139  Superclass::_buffer[0] += v[0];
140  Superclass::_buffer[1] += v[1];
141  Superclass::_buffer[2] += v[2];
142  return *this;
143  }
144 
146  inline Tvec5<DT>& operator+=(const Tvec4<DT>& v)
147  {
148  Superclass::_buffer[0] += v[0];
149  Superclass::_buffer[1] += v[1];
150  Superclass::_buffer[2] += v[2];
151  Superclass::_buffer[3] += v[3];
152  return *this;
153  }
154 
156  inline const Tvec3<DT> getVec3() const
157  {
158  return Tvec3<DT>(Superclass::_buffer[0],
159  Superclass::_buffer[1],
160  Superclass::_buffer[2]);
161  }
162 
164  inline const Tvec4<DT> getVec4() const
165  {
166  return Tvec4<DT>(Superclass::_buffer[0],
167  Superclass::_buffer[1],
168  Superclass::_buffer[2],
169  Superclass::_buffer[3]);
170  }
172 };
173 
175 #define _ML_VEC5_RC(i) a[i][0]*v[0] + a[i][1]*v[1] + a[i][2]*v[2] + a[i][3]*v[3] + a[i][4]*v[4]
176 //-----------------------------------------------------------------------------------
178 //-----------------------------------------------------------------------------------
179 template <class DT>
180 inline Tvec5<DT> operator*(const Tmat5<DT>& a, const Tvec5<DT>& v)
181 {
183 }
184 #undef _ML_VEC5_RC
185 
186 //-----------------------------------------------------------------------------------
188 //-----------------------------------------------------------------------------------
189 template <class DT>
190 inline Tvec5<DT> operator*(const Tvec5<DT>& v, const Tmat5<DT>& a)
191 {
192  return a.transpose() * v;
193 }
194 
195 
196 //-----------------------------------------------------------------------------------
199 //-----------------------------------------------------------------------------------
209 
210 
211 #if ML_DEPRECATED_SINCE(3,5,0)
216 ML_DEPRECATED typedef Tvec5<MLfloat> vecf5;
219 ML_DEPRECATED typedef Tvec5<MLdouble> vecd5;
222 ML_DEPRECATED typedef Tvec5<MLldouble> vecld5;
225 ML_DEPRECATED typedef Tvec5<MLdouble> vec5;
227 
228 #endif
229 
230 
231 ML_LA_END_NAMESPACE
232 
233 #endif //of __mlVector5_H
234 
#define ML_DEPRECATED
Definition: CSOGroup.h:371
Template class for vector arithmetic with floating point data types.
T operator*(const FloatingPointVector< T, size, DataContainer > &a, const FloatingPointVector< T, size, DataContainer > &b)
Dot product, returns a.dot(b).
A five by five matrix class of five row vectors.
Definition: mlMatrix5.h:49
Tmat5 transpose() const
Returns the transposed of this matrix.
Definition: mlMatrix5.h:611
Declaration of float vector type traits:
Definition: mlVector2.h:57
Forward declarations to resolve header file dependencies.
Definition: mlVector3.h:66
Forward declarations to resolve header file dependencies.
Definition: mlVector4.h:50
Forward declarations to resolve header file dependencies.
Definition: mlVector5.h:48
FloatingPointVector< DT, 5 > Superclass
A typedef as a shorthand for the base class.
Definition: mlVector5.h:52
Tvec5< DT > & operator+=(const Tvec4< DT > &v)
Incrementation by a Tvec4.
Definition: mlVector5.h:146
const Tvec3< DT > getVec3() const
Returns a Tvec3 from components 0,1, and 2.
Definition: mlVector5.h:156
void assign(const DT x, const DT y, const DT z, const DT c, const DT t)
Sets all components to the passed values.
Definition: mlVector5.h:119
Tvec5(const Tvec3< DT > &v, const DT c, const DT t)
Casts Tvec3 to Tvec5. Last components are set to c and t.
Definition: mlVector5.h:94
Tvec5(const DT value=0)
Default and value constructor.
Definition: mlVector5.h:63
Tvec5(const DT x, const DT y, const DT z, const DT c, const DT t)
Builds the vector from the scalars x, y, z, c and t to the components 0 to 4, respectively.
Definition: mlVector5.h:74
Tvec5(const Tvec2< DT > &v, const DT z, const DT c, const DT t)
Casts Tvec2 to Tvec5. Last components are set to z, c and t.
Definition: mlVector5.h:84
Tvec5< DT > & operator+=(const Tvec3< DT > &v)
Incrementation by a Tvec3.
Definition: mlVector5.h:137
Tvec5< DT > & operator+=(const Tvec2< DT > &v)
Incrementation by a Tvec2.
Definition: mlVector5.h:129
const Tvec4< DT > getVec4() const
Returns a Tvec4 from components 0, 1, 2, and 3.
Definition: mlVector5.h:164
Tvec5(const Tvec4< DT > &v, const DT t)
Casts Tvec4 to Tvec5. Last component is set to t and u.
Definition: mlVector5.h:104
DT ComponentType
A typedef to "export" the type of components.
Definition: mlVector5.h:55
Tvec5(const Superclass &v)
Copy constructor from FloatingPointVector.
Definition: mlVector5.h:68
#define _ML_VEC5_RC(i)
Internal helper macro for tMat5 with Tvec5 multiplications. Do not use.
Definition: mlVector5.h:175
Tvec5< MLdouble > Vector5
A vector with 5 components of type double.
Definition: mlVector5.h:207
Tvec5< MLfloat > Vector5f
A vector with 5 components of type float.
Definition: mlVector5.h:201
Tvec5< MLdouble > Vector5d
A vector with 5 components of type double.
Definition: mlVector5.h:203
Tvec5< MLldouble > Vector5ld
A vector with 5 components of type long double.
Definition: mlVector5.h:205