MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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.
20#include "mlLinearAlgebraDefs.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.
29
30//--------------------------------------------------------------------
32// This is necessar,y because we do not know whether vector or
33// matrix header is included first and we cannot move template
34// code into the C++ file.
35//--------------------------------------------------------------------
36template <class DT> class Tvec2;
37template <class DT> class Tvec3;
38template <class DT> class Tvec4;
39template <class DT> class Tmat5;
41
42//--------------------------------------------------------------------
44//--------------------------------------------------------------------
46template <class DT> class Tvec5 : public FloatingPointVector<DT, 5>
47{
48public:
51
53 typedef DT ComponentType;
54
55 //--------------------------------------------------------------------
58 //--------------------------------------------------------------------
61 inline explicit Tvec5(const DT value = 0)
62 : Superclass(value)
63 {}
64
66 inline Tvec5(const Superclass& v)
67 : Superclass(v)
68 {}
69
72 inline Tvec5(const DT x, const DT y, const DT z, const DT c, const DT t)
73 {
74 Superclass::_buffer[0] = x;
75 Superclass::_buffer[1] = y;
76 Superclass::_buffer[2] = z;
77 Superclass::_buffer[3] = c;
78 Superclass::_buffer[4] = t;
79 }
80
82 inline Tvec5(const Tvec2<DT>& v, const DT z, const DT c, const DT t)
83 {
84 Superclass::_buffer[0] = v[0];
85 Superclass::_buffer[1] = v[1];
86 Superclass::_buffer[2] = z;
87 Superclass::_buffer[3] = c;
88 Superclass::_buffer[4] = t;
89 }
90
92 inline Tvec5(const Tvec3<DT>& v, const DT c, const DT t)
93 {
94 Superclass::_buffer[0] = v[0];
95 Superclass::_buffer[1] = v[1];
96 Superclass::_buffer[2] = v[2];
97 Superclass::_buffer[3] = c;
98 Superclass::_buffer[4] = t;
99 }
100
102 inline Tvec5(const Tvec4<DT>& v, const DT t)
103 {
104 Superclass::_buffer[0] = v[0];
105 Superclass::_buffer[1] = v[1];
106 Superclass::_buffer[2] = v[2];
107 Superclass::_buffer[3] = v[3];
108 Superclass::_buffer[4] = t;
109 }
111
112 //--------------------------------------------------------------------
115 //--------------------------------------------------------------------
117 inline void assign(const DT x, const DT y, const DT z, const DT c, const DT t)
118 {
119 Superclass::_buffer[0] = x;
120 Superclass::_buffer[1] = y;
121 Superclass::_buffer[2] = z;
122 Superclass::_buffer[3] = c;
123 Superclass::_buffer[4] = t;
124 }
125
128 {
129 Superclass::_buffer[0] += v[0];
130 Superclass::_buffer[1] += v[1];
131 return *this;
132 }
133
136 {
137 Superclass::_buffer[0] += v[0];
138 Superclass::_buffer[1] += v[1];
139 Superclass::_buffer[2] += v[2];
140 return *this;
141 }
142
145 {
146 Superclass::_buffer[0] += v[0];
147 Superclass::_buffer[1] += v[1];
148 Superclass::_buffer[2] += v[2];
149 Superclass::_buffer[3] += v[3];
150 return *this;
151 }
152
154 inline const Tvec3<DT> getVec3() const
155 {
156 return Tvec3<DT>(Superclass::_buffer[0], Superclass::_buffer[1], Superclass::_buffer[2]);
157 }
158
160 inline const Tvec4<DT> getVec4() const
161 {
162 return Tvec4<DT>(Superclass::_buffer[0], Superclass::_buffer[1], Superclass::_buffer[2], Superclass::_buffer[3]);
163 }
165};
166
168#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]
169//-----------------------------------------------------------------------------------
171//-----------------------------------------------------------------------------------
172template <class DT> inline Tvec5<DT> operator*(const Tmat5<DT>& a, const Tvec5<DT>& v)
173{
175}
176#undef _ML_VEC5_RC
177
178//-----------------------------------------------------------------------------------
180//-----------------------------------------------------------------------------------
181template <class DT> inline Tvec5<DT> operator*(const Tvec5<DT>& v, const Tmat5<DT>& a)
182{
183 return a.transpose() * v;
184}
185
186
187//-----------------------------------------------------------------------------------
190//-----------------------------------------------------------------------------------
200
201
203
204#endif // of __mlVector5_H
Template class for vector arithmetic with floating point datatypes.
A 5x5 matrix class of five row vectors.
Definition mlMatrix5.h:48
Tmat5 transpose() const
Returns the transposed of this matrix.
Definition mlMatrix5.h:616
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:49
Forward declarations to resolve header file dependencies.
Definition mlVector5.h:47
Tvec5< DT > & operator+=(const Tvec2< DT > &v)
Incrementation by a Tvec2.
Definition mlVector5.h:127
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:117
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:92
Tvec5(const DT value=0)
Default and value constructor.
Definition mlVector5.h:61
Tvec5< DT > & operator+=(const Tvec4< DT > &v)
Incrementation by a Tvec4.
Definition mlVector5.h:144
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:72
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:82
FloatingPointVector< DT, 5 > Superclass
A typedef as a shorthand for the base class.
Definition mlVector5.h:50
Tvec5< DT > & operator+=(const Tvec3< DT > &v)
Incrementation by a Tvec3.
Definition mlVector5.h:135
Tvec5(const Tvec4< DT > &v, const DT t)
Casts Tvec4 to Tvec5. Last component is set to t.
Definition mlVector5.h:102
const Tvec4< DT > getVec4() const
Returns a Tvec4 from components 0, 1, 2, and 3.
Definition mlVector5.h:160
DT ComponentType
A typedef to 'export' the type of components.
Definition mlVector5.h:53
const Tvec3< DT > getVec3() const
Returns a Tvec3 from components 0, 1, and 2.
Definition mlVector5.h:154
Tvec5(const Superclass &v)
Copy constructor from FloatingPointVector.
Definition mlVector5.h:66
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
#define _ML_VEC5_RC(i)
Internal helper macro for tMat5 with Tvec5 multiplications. Do not use.
Definition mlVector5.h:168
T operator*(const FloatingPointVector< T, size, DataContainer > &a, const FloatingPointVector< T, size, DataContainer > &b)
Dot product, returns a.dot(b).