MeVisLab Toolbox Reference
mlVector6.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_VECTOR6_H
14#define ML_VECTOR6_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
26// All declarations of this header will be in the ML_LA_NAMESPACE namespace.
28
29//--------------------------------------------------------------------
31// This is necessary because we do not known whether vector or
32// matrix header is included first and we cannot move template
33// code into C++ file.
34//--------------------------------------------------------------------
35template <class DT> class Tvec2;
36template <class DT> class Tvec3;
37template <class DT> class Tvec4;
39
40//--------------------------------------------------------------------
42//--------------------------------------------------------------------
44template <class DT>
45class Tvec6 : public FloatingPointVector<DT,6>
46{
47public:
48
51
53 typedef DT ComponentType;
54
55 //--------------------------------------------------------------------
58 //--------------------------------------------------------------------
61 inline explicit Tvec6(const DT value=0) : Superclass(value)
62 {
63 }
64
68 inline Tvec6(const Superclass &v) : Superclass(v)
69 {
70 }
71
74 inline Tvec6(const DT x, const DT y, const DT z, const DT c, const DT t, const DT u)
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 Superclass::_buffer[5] = u;
82 }
83
85 inline Tvec6(const Tvec2<DT>& v, const DT z, const DT c, const DT t, const DT u)
86 {
87 Superclass::_buffer[0] = v[0];
88 Superclass::_buffer[1] = v[1];
89 Superclass::_buffer[2] = z;
90 Superclass::_buffer[3] = c;
91 Superclass::_buffer[4] = t;
92 Superclass::_buffer[5] = u;
93 }
94
96 inline Tvec6(const Tvec3<DT>& v, const DT c, const DT t, const DT u)
97 {
98 Superclass::_buffer[0] = v[0];
99 Superclass::_buffer[1] = v[1];
100 Superclass::_buffer[2] = v[2];
101 Superclass::_buffer[3] = c;
102 Superclass::_buffer[4] = t;
103 Superclass::_buffer[5] = u;
104 }
105
107 inline Tvec6(const Tvec4<DT>& v, const DT t, const DT u)
108 {
109 Superclass::_buffer[0] = v[0];
110 Superclass::_buffer[1] = v[1];
111 Superclass::_buffer[2] = v[2];
112 Superclass::_buffer[3] = v[3];
113 Superclass::_buffer[4] = t;
114 Superclass::_buffer[5] = u;
115 }
117
118 //--------------------------------------------------------------------
121 //--------------------------------------------------------------------
123 inline void assign(const DT x, const DT y, const DT z, const DT c, const DT t, const DT u)
124 {
125 Superclass::_buffer[0] = x;
126 Superclass::_buffer[1] = y;
127 Superclass::_buffer[2] = z;
128 Superclass::_buffer[3] = c;
129 Superclass::_buffer[4] = t;
130 Superclass::_buffer[5] = u;
131 }
132
135 {
136 Superclass::_buffer[0] += v[0];
137 Superclass::_buffer[1] += v[1];
138 return *this;
139 }
140
143 {
144 Superclass::_buffer[0] += v[0];
145 Superclass::_buffer[1] += v[1];
146 Superclass::_buffer[2] += v[2];
147 return *this;
148 }
149
152 {
153 Superclass::_buffer[0] += v[0];
154 Superclass::_buffer[1] += v[1];
155 Superclass::_buffer[2] += v[2];
156 Superclass::_buffer[3] += v[3];
157 return *this;
158 }
159
161 inline const Tvec3<DT> getVec3() const
162 {
163 return Tvec3<DT>(Superclass::_buffer[0],
164 Superclass::_buffer[1],
165 Superclass::_buffer[2]);
166 }
167
169 inline const Tvec4<DT> getVec4() const
170 {
171 return Tvec4<DT>(Superclass::_buffer[0],
172 Superclass::_buffer[1],
173 Superclass::_buffer[2],
174 Superclass::_buffer[3]);
175 }
177
178 // Note: Multiplications with Matrix6 are implemented with/in class Tmat6.
179
180};
181
182
183//-----------------------------------------------------------------------------------
186//-----------------------------------------------------------------------------------
196
198
199#endif //of __mlVector6_H
200
201
202
Template class for vector arithmetic with floating point data types.
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
A six dimensional vector class for floating point types.
Definition mlVector6.h:46
Tvec6(const DT x, const DT y, const DT z, const DT c, const DT t, const DT u)
Builds the vector from the scalars x, y, z, c, t and u to the components 0 to 5, respectively.
Definition mlVector6.h:74
Tvec6< DT > & operator+=(const Tvec2< DT > &v)
Incrementation by a Tvec2.
Definition mlVector6.h:134
FloatingPointVector< DT, 6 > Superclass
A typedef as a shorthand for the base class.
Definition mlVector6.h:50
Tvec6(const Superclass &v)
Copy constructor from FloatingPointVector.
Definition mlVector6.h:68
Tvec6(const DT value=0)
Default and value constructor.
Definition mlVector6.h:61
const Tvec3< DT > getVec3() const
Returns a Tvec3 from components 0,1, and 2.
Definition mlVector6.h:161
Tvec6(const Tvec3< DT > &v, const DT c, const DT t, const DT u)
Casts Tvec3 to Tvec6. Last components are set to c, t and u whose defaults are 0.
Definition mlVector6.h:96
const Tvec4< DT > getVec4() const
Returns a Tvec4 from components 0, 1, 2, and 3.
Definition mlVector6.h:169
void assign(const DT x, const DT y, const DT z, const DT c, const DT t, const DT u)
Sets all components to the passed values.
Definition mlVector6.h:123
Tvec6< DT > & operator+=(const Tvec3< DT > &v)
Incrementation by a Tvec3.
Definition mlVector6.h:142
DT ComponentType
A typedef to "export" the type of components.
Definition mlVector6.h:53
Tvec6(const Tvec2< DT > &v, const DT z, const DT c, const DT t, const DT u)
Casts Tvec2 to Tvec6. Last components are set to z, c, t and u whose defaults are 0.
Definition mlVector6.h:85
Tvec6(const Tvec4< DT > &v, const DT t, const DT u)
Casts Tvec4 to Tvec6. Last components are set to t and u whose defaults are 0.
Definition mlVector6.h:107
Tvec6< DT > & operator+=(const Tvec4< DT > &v)
Incrementation by a Tvec4.
Definition mlVector6.h:151
Target mlrange_cast(Source arg)
Generic version of checked ML casts.