ITK  6.0.0
Insight Toolkit
itkVersor.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkVersor_h
19#define itkVersor_h
20
21#include "itkMatrix.h"
22#include "vnl/vnl_quaternion.h"
23#include "vnl/vnl_vector_fixed.h"
24
25namespace itk
26{
51template <typename T>
52class ITK_TEMPLATE_EXPORT Versor
53{
54public:
56 using Self = Versor;
57
60 using ValueType = T;
61
64
67
70
73
75 using VnlVectorType = vnl_vector_fixed<T, 3>;
76
78 using VnlQuaternionType = vnl_quaternion<T>;
79
82
84 vnl_quaternion<T>
86
90 void
92
110 void
111 Set(T x, T y, T z, T w);
117 const Self &
118 operator*=(const Self & v);
119
124 const Self &
125 operator/=(const Self & v);
126
131 GetTensor() const;
132
137 void
139
142 Self
144
148 Self
150
153 Self
154 operator*(const Self & v) const;
155
157 Self
158 operator/(const Self & v) const;
159
162 bool
163 operator==(const Self & v) const;
164
166
169 GetScalar() const;
170
173 GetX() const
174 {
175 return m_X;
176 }
177
179 ValueType
180 GetY() const
181 {
182 return m_Y;
183 }
184
186 ValueType
187 GetZ() const
188 {
189 return m_Z;
190 }
191
193 ValueType
194 GetW() const
195 {
196 return m_W;
197 }
198
200 ValueType
201 GetAngle() const;
202
206 GetAxis() const;
207
213 GetRight() const;
214
219 void
220 Set(const VectorType & axis, ValueType angle);
221
227 void
228 Set(const MatrixType & mat);
229
235 void
236 Set(const VectorType & axis);
237
244 void
246
253 void
255
262 void
264
267 void
269
272 Transform(const VectorType & v) const;
273
280
283 Transform(const PointType & v) const;
284
287 Transform(const VnlVectorType & v) const;
288
291 GetMatrix() const;
292
294 Self
295 SquareRoot() const;
296
300 Self
301 Exponential(ValueType exponent) const;
302
303private:
305 static inline ValueType
306 Epsilon(double *)
307 {
308 return 1e-10;
309 }
310 static inline ValueType
311 Epsilon(float *)
312 {
313 return 1e-7;
314 }
315 static inline ValueType
317 {
318 return Epsilon((ValueType *)nullptr);
319 }
324
327
330
333};
334
335template <typename T>
336std::ostream &
337operator<<(std::ostream & os, const Versor<T> & v)
338{
339 os << "[ ";
340 os << v.GetX() << ", " << v.GetY() << ", ";
341 os << v.GetZ() << ", " << v.GetW() << " ]";
342 return os;
343}
344
345template <typename T>
346std::istream &
347operator>>(std::istream & is, Versor<T> & v);
348} // end namespace itk
349
350#ifndef ITK_MANUAL_INSTANTIATION
351# include "itkVersor.hxx"
352#endif
353
354#endif
A templated class holding a n-Dimensional covariant vector.
A templated class holding a M x N size Matrix.
Definition: itkMatrix.h:53
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:54
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:63
A templated class holding a unit quaternion.
Definition: itkVersor.h:53
static ValueType Epsilon(double *)
Definition: itkVersor.h:306
Self Exponential(ValueType exponent) const
bool operator==(const Self &v) const
Self operator*(const Self &v) const
void Normalize()
CovariantVectorType Transform(const CovariantVectorType &v) const
Self operator/(const Self &v) const
static ValueType Epsilon(float *)
Definition: itkVersor.h:311
ValueType GetZ() const
Definition: itkVersor.h:187
void SetIdentity()
void Set(const VectorType &axis, ValueType angle)
VectorType GetAxis() const
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Self)
void Set(T x, T y, T z, T w)
ValueType GetScalar() const
typename NumericTraits< ValueType >::RealType RealType
Definition: itkVersor.h:63
VnlVectorType Transform(const VnlVectorType &v) const
void Set(const VectorType &axis)
ValueType GetAngle() const
MatrixType GetMatrix() const
void SetRotationAroundZ(ValueType angle)
ValueType GetY() const
Definition: itkVersor.h:180
PointType Transform(const PointType &v) const
void Set(const VnlQuaternionType &)
vnl_quaternion< T > VnlQuaternionType
Definition: itkVersor.h:78
VectorType Transform(const VectorType &v) const
vnl_vector_fixed< T, 3 > VnlVectorType
Definition: itkVersor.h:75
ValueType GetTensor() const
static ValueType Epsilon()
Definition: itkVersor.h:316
Self GetConjugate() const
void SetRotationAroundY(ValueType angle)
Self SquareRoot() const
const Self & operator/=(const Self &v)
Self GetReciprocal() const
void Set(const MatrixType &mat)
ValueType GetW() const
Definition: itkVersor.h:194
void SetRotationAroundX(ValueType angle)
const Self & operator*=(const Self &v)
ValueType GetX() const
Definition: itkVersor.h:173
VectorType GetRight() const
vnl_quaternion< T > GetVnlQuaternion() const
static constexpr double e
Definition: itkMath.h:56
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
std::istream & operator>>(std::istream &is, Point< T, VPointDimension > &vct)
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)