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 operator*(const Self & v) const;
154
156 Self
157 operator/(const Self & v) const;
158
161 bool
162 operator==(const Self & v) const;
163
165
168 GetScalar() const;
169
172 GetX() const
173 {
174 return m_X;
175 }
176
178 ValueType
179 GetY() const
180 {
181 return m_Y;
182 }
183
185 ValueType
186 GetZ() const
187 {
188 return m_Z;
189 }
190
192 ValueType
193 GetW() const
194 {
195 return m_W;
196 }
197
199 ValueType
200 GetAngle() const;
201
205 GetAxis() const;
206
212 GetRight() const;
213
218 void
219 Set(const VectorType & axis, ValueType angle);
220
226 void
227 Set(const MatrixType & mat);
228
234 void
235 Set(const VectorType & axis);
236
243 void
245
252 void
254
261 void
263
266 void
268
271 Transform(const VectorType & v) const;
272
279
282 Transform(const PointType & v) const;
283
286 Transform(const VnlVectorType & v) const;
287
290 GetMatrix() const;
291
293 Self
294 SquareRoot() const;
295
299 Self
300 Exponential(ValueType exponent) const;
301
302private:
304 static inline ValueType
305 Epsilon(double *)
306 {
307 return 1e-10;
308 }
309 static inline ValueType
310 Epsilon(float *)
311 {
312 return 1e-7;
313 }
314 static inline ValueType
316 {
317 return Epsilon((ValueType *)nullptr);
318 }
323
326
329
332};
333
334template <typename T>
335std::ostream &
336operator<<(std::ostream & os, const Versor<T> & v)
337{
338 os << "[ ";
339 os << v.GetX() << ", " << v.GetY() << ", ";
340 os << v.GetZ() << ", " << v.GetW() << " ]";
341 return os;
342}
343
344template <typename T>
345std::istream &
346operator>>(std::istream & is, Versor<T> & v);
347} // end namespace itk
348
349#ifndef ITK_MANUAL_INSTANTIATION
350# include "itkVersor.hxx"
351#endif
352
353#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:305
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:310
ValueType GetZ() const
Definition: itkVersor.h:186
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:179
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:315
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:193
void SetRotationAroundX(ValueType angle)
const Self & operator*=(const Self &v)
ValueType GetX() const
Definition: itkVersor.h:172
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)