ITK  5.4.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{
49template <typename T>
50class ITK_TEMPLATE_EXPORT Versor
51{
52public:
54 using Self = Versor;
55
58 using ValueType = T;
59
62
65
68
71
73 using VnlVectorType = vnl_vector_fixed<T, 3>;
74
76 using VnlQuaternionType = vnl_quaternion<T>;
77
80
82 vnl_quaternion<T>
84
88 void
90
108 void
109 Set(T x, T y, T z, T w);
114 Versor() = default;
115
117 Versor(const Self & v);
118
120 Self &
121 operator=(const Self & v);
122
126 const Self &
127 operator*=(const Self & v);
128
133 const Self &
134 operator/=(const Self & v);
135
140 GetTensor() const;
141
146 void
148
151 Self
153
157 Self
159
162 Self operator*(const Self & v) const;
163
165 Self
166 operator/(const Self & v) const;
167
170 bool
171 operator==(const Self & v) const;
172
174
177 GetScalar() const;
178
181 GetX() const
182 {
183 return m_X;
184 }
185
187 ValueType
188 GetY() const
189 {
190 return m_Y;
191 }
192
194 ValueType
195 GetZ() const
196 {
197 return m_Z;
198 }
199
201 ValueType
202 GetW() const
203 {
204 return m_W;
205 }
206
208 ValueType
209 GetAngle() const;
210
214 GetAxis() const;
215
221 GetRight() const;
222
227 void
228 Set(const VectorType & axis, ValueType angle);
229
235 void
236 Set(const MatrixType & mat);
237
243 void
244 Set(const VectorType & axis);
245
252 void
254
261 void
263
270 void
272
275 void
277
280 Transform(const VectorType & v) const;
281
288
291 Transform(const PointType & v) const;
292
295 Transform(const VnlVectorType & v) const;
296
299 GetMatrix() const;
300
302 Self
303 SquareRoot() const;
304
308 Self
309 Exponential(ValueType exponent) const;
310
311private:
313 static inline ValueType
314 Epsilon(double *)
315 {
316 return 1e-10;
317 }
318 static inline ValueType
319 Epsilon(float *)
320 {
321 return 1e-7;
322 }
323 static inline ValueType
325 {
326 return Epsilon((ValueType *)nullptr);
327 }
332
335
338
341};
342
343template <typename T>
344std::ostream &
345operator<<(std::ostream & os, const Versor<T> & v)
346{
347 os << "[ ";
348 os << v.GetX() << ", " << v.GetY() << ", ";
349 os << v.GetZ() << ", " << v.GetW() << " ]";
350 return os;
351}
352
353template <typename T>
354std::istream &
355operator>>(std::istream & is, Versor<T> & v);
356} // end namespace itk
357
358#ifndef ITK_MANUAL_INSTANTIATION
359# include "itkVersor.hxx"
360#endif
361
362#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:51
static ValueType Epsilon(double *)
Definition: itkVersor.h:314
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:319
Versor()=default
ValueType GetZ() const
Definition: itkVersor.h:195
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:61
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:188
PointType Transform(const PointType &v) const
void Set(const VnlQuaternionType &)
vnl_quaternion< T > VnlQuaternionType
Definition: itkVersor.h:76
VectorType Transform(const VectorType &v) const
vnl_vector_fixed< T, 3 > VnlVectorType
Definition: itkVersor.h:73
ValueType GetTensor() const
static ValueType Epsilon()
Definition: itkVersor.h:324
Self GetConjugate() const
void SetRotationAroundY(ValueType angle)
Self SquareRoot() const
const Self & operator/=(const Self &v)
Self GetReciprocal() const
Self & operator=(const Self &v)
void Set(const MatrixType &mat)
ValueType GetW() const
Definition: itkVersor.h:202
void SetRotationAroundX(ValueType angle)
Versor(const Self &v)
const Self & operator*=(const Self &v)
ValueType GetX() const
Definition: itkVersor.h:181
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)
std::ostream & operator<<(std::ostream &os, const Array< TValue > &arr)
Definition: itkArray.h:216