node-native-win-utils 1.3.4 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/README.md +30 -83
  2. package/binding.gyp +3 -0
  3. package/dist/dirnameLocal.cjs +4 -0
  4. package/dist/dirnameLocal.d.cts +1 -0
  5. package/dist/dirnameLocal.d.mts +1 -0
  6. package/dist/dirnameLocal.mjs +2 -0
  7. package/dist/{index.js → index.cjs} +49 -17
  8. package/dist/{index.d.ts → index.d.cts} +25 -12
  9. package/dist/index.d.mts +191 -0
  10. package/dist/index.mjs +177 -0
  11. package/dist/keyCodes.d.mts +101 -0
  12. package/dist/keyCodes.mjs +201 -0
  13. package/node22.json +16 -0
  14. package/package.json +22 -9
  15. package/prebuilds/win32-x64/node-native-win-utils.node +0 -0
  16. package/prebuilds/win32-x64/tesseract.dll +0 -0
  17. package/prebuilds/win32-x64/tiff.dll +0 -0
  18. package/src/cpp/keyboard.cpp +141 -140
  19. package/src/cpp/main.cpp +11 -3
  20. package/src/cpp/{capturewindow.cpp → screenshot.cpp} +174 -2
  21. package/src/cpp/tesseract.cpp +49 -0
  22. package/src/dirnameLocal.mts +3 -0
  23. package/src/index.mts +454 -0
  24. package/src/keyCodes.mts +203 -0
  25. package/include/opencv2/core/affine.hpp +0 -678
  26. package/include/opencv2/core/async.hpp +0 -105
  27. package/include/opencv2/core/base.hpp +0 -664
  28. package/include/opencv2/core/bindings_utils.hpp +0 -325
  29. package/include/opencv2/core/bufferpool.hpp +0 -40
  30. package/include/opencv2/core/check.hpp +0 -170
  31. package/include/opencv2/core/core.hpp +0 -48
  32. package/include/opencv2/core/core_c.h +0 -3128
  33. package/include/opencv2/core/cuda/block.hpp +0 -211
  34. package/include/opencv2/core/cuda/border_interpolate.hpp +0 -722
  35. package/include/opencv2/core/cuda/color.hpp +0 -309
  36. package/include/opencv2/core/cuda/common.hpp +0 -131
  37. package/include/opencv2/core/cuda/datamov_utils.hpp +0 -113
  38. package/include/opencv2/core/cuda/detail/color_detail.hpp +0 -2018
  39. package/include/opencv2/core/cuda/detail/reduce.hpp +0 -365
  40. package/include/opencv2/core/cuda/detail/reduce_key_val.hpp +0 -502
  41. package/include/opencv2/core/cuda/detail/transform_detail.hpp +0 -392
  42. package/include/opencv2/core/cuda/detail/type_traits_detail.hpp +0 -191
  43. package/include/opencv2/core/cuda/detail/vec_distance_detail.hpp +0 -121
  44. package/include/opencv2/core/cuda/dynamic_smem.hpp +0 -88
  45. package/include/opencv2/core/cuda/emulation.hpp +0 -269
  46. package/include/opencv2/core/cuda/filters.hpp +0 -293
  47. package/include/opencv2/core/cuda/funcattrib.hpp +0 -79
  48. package/include/opencv2/core/cuda/functional.hpp +0 -805
  49. package/include/opencv2/core/cuda/limits.hpp +0 -128
  50. package/include/opencv2/core/cuda/reduce.hpp +0 -209
  51. package/include/opencv2/core/cuda/saturate_cast.hpp +0 -292
  52. package/include/opencv2/core/cuda/scan.hpp +0 -258
  53. package/include/opencv2/core/cuda/simd_functions.hpp +0 -869
  54. package/include/opencv2/core/cuda/transform.hpp +0 -75
  55. package/include/opencv2/core/cuda/type_traits.hpp +0 -90
  56. package/include/opencv2/core/cuda/utility.hpp +0 -230
  57. package/include/opencv2/core/cuda/vec_distance.hpp +0 -232
  58. package/include/opencv2/core/cuda/vec_math.hpp +0 -923
  59. package/include/opencv2/core/cuda/vec_traits.hpp +0 -288
  60. package/include/opencv2/core/cuda/warp.hpp +0 -139
  61. package/include/opencv2/core/cuda/warp_reduce.hpp +0 -76
  62. package/include/opencv2/core/cuda/warp_shuffle.hpp +0 -162
  63. package/include/opencv2/core/cuda.hpp +0 -1279
  64. package/include/opencv2/core/cuda.inl.hpp +0 -763
  65. package/include/opencv2/core/cuda_stream_accessor.hpp +0 -86
  66. package/include/opencv2/core/cuda_types.hpp +0 -144
  67. package/include/opencv2/core/cv_cpu_dispatch.h +0 -381
  68. package/include/opencv2/core/cv_cpu_helper.h +0 -550
  69. package/include/opencv2/core/cvdef.h +0 -973
  70. package/include/opencv2/core/cvstd.hpp +0 -190
  71. package/include/opencv2/core/cvstd.inl.hpp +0 -197
  72. package/include/opencv2/core/cvstd_wrapper.hpp +0 -154
  73. package/include/opencv2/core/detail/async_promise.hpp +0 -71
  74. package/include/opencv2/core/detail/dispatch_helper.impl.hpp +0 -49
  75. package/include/opencv2/core/detail/exception_ptr.hpp +0 -27
  76. package/include/opencv2/core/directx.hpp +0 -184
  77. package/include/opencv2/core/dualquaternion.hpp +0 -979
  78. package/include/opencv2/core/dualquaternion.inl.hpp +0 -487
  79. package/include/opencv2/core/eigen.hpp +0 -402
  80. package/include/opencv2/core/fast_math.hpp +0 -433
  81. package/include/opencv2/core/hal/hal.hpp +0 -256
  82. package/include/opencv2/core/hal/interface.h +0 -190
  83. package/include/opencv2/core/hal/intrin.hpp +0 -939
  84. package/include/opencv2/core/hal/intrin_avx.hpp +0 -3177
  85. package/include/opencv2/core/hal/intrin_avx512.hpp +0 -3090
  86. package/include/opencv2/core/hal/intrin_cpp.hpp +0 -3321
  87. package/include/opencv2/core/hal/intrin_forward.hpp +0 -191
  88. package/include/opencv2/core/hal/intrin_lasx.hpp +0 -3236
  89. package/include/opencv2/core/hal/intrin_msa.hpp +0 -1887
  90. package/include/opencv2/core/hal/intrin_neon.hpp +0 -2610
  91. package/include/opencv2/core/hal/intrin_rvv.hpp +0 -3320
  92. package/include/opencv2/core/hal/intrin_rvv071.hpp +0 -2545
  93. package/include/opencv2/core/hal/intrin_rvv_scalable.hpp +0 -2080
  94. package/include/opencv2/core/hal/intrin_sse.hpp +0 -3467
  95. package/include/opencv2/core/hal/intrin_sse_em.hpp +0 -180
  96. package/include/opencv2/core/hal/intrin_vsx.hpp +0 -1608
  97. package/include/opencv2/core/hal/intrin_wasm.hpp +0 -2782
  98. package/include/opencv2/core/hal/msa_macros.h +0 -1558
  99. package/include/opencv2/core/hal/simd_utils.impl.hpp +0 -186
  100. package/include/opencv2/core/llapi/llapi.h +0 -102
  101. package/include/opencv2/core/mat.hpp +0 -3775
  102. package/include/opencv2/core/mat.inl.hpp +0 -3422
  103. package/include/opencv2/core/matx.hpp +0 -1536
  104. package/include/opencv2/core/neon_utils.hpp +0 -128
  105. package/include/opencv2/core/ocl.hpp +0 -917
  106. package/include/opencv2/core/ocl_genbase.hpp +0 -69
  107. package/include/opencv2/core/opencl/ocl_defs.hpp +0 -82
  108. package/include/opencv2/core/opencl/opencl_info.hpp +0 -212
  109. package/include/opencv2/core/opencl/opencl_svm.hpp +0 -81
  110. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_clblas.hpp +0 -602
  111. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_clfft.hpp +0 -146
  112. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_core.hpp +0 -371
  113. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_core_wrappers.hpp +0 -272
  114. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl.hpp +0 -62
  115. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl_wrappers.hpp +0 -42
  116. package/include/opencv2/core/opencl/runtime/opencl_clblas.hpp +0 -53
  117. package/include/opencv2/core/opencl/runtime/opencl_clfft.hpp +0 -53
  118. package/include/opencv2/core/opencl/runtime/opencl_core.hpp +0 -84
  119. package/include/opencv2/core/opencl/runtime/opencl_core_wrappers.hpp +0 -47
  120. package/include/opencv2/core/opencl/runtime/opencl_gl.hpp +0 -53
  121. package/include/opencv2/core/opencl/runtime/opencl_gl_wrappers.hpp +0 -47
  122. package/include/opencv2/core/opencl/runtime/opencl_svm_20.hpp +0 -48
  123. package/include/opencv2/core/opencl/runtime/opencl_svm_definitions.hpp +0 -42
  124. package/include/opencv2/core/opencl/runtime/opencl_svm_hsa_extension.hpp +0 -166
  125. package/include/opencv2/core/opengl.hpp +0 -733
  126. package/include/opencv2/core/openvx/ovx_defs.hpp +0 -48
  127. package/include/opencv2/core/operations.hpp +0 -610
  128. package/include/opencv2/core/optim.hpp +0 -302
  129. package/include/opencv2/core/ovx.hpp +0 -28
  130. package/include/opencv2/core/parallel/backend/parallel_for.openmp.hpp +0 -72
  131. package/include/opencv2/core/parallel/backend/parallel_for.tbb.hpp +0 -153
  132. package/include/opencv2/core/parallel/parallel_backend.hpp +0 -90
  133. package/include/opencv2/core/persistence.hpp +0 -1350
  134. package/include/opencv2/core/private/cv_cpu_include_simd_declarations.hpp +0 -30
  135. package/include/opencv2/core/private.cuda.hpp +0 -169
  136. package/include/opencv2/core/private.hpp +0 -896
  137. package/include/opencv2/core/quaternion.hpp +0 -1696
  138. package/include/opencv2/core/quaternion.inl.hpp +0 -1063
  139. package/include/opencv2/core/saturate.hpp +0 -180
  140. package/include/opencv2/core/simd_intrinsics.hpp +0 -87
  141. package/include/opencv2/core/softfloat.hpp +0 -514
  142. package/include/opencv2/core/sse_utils.hpp +0 -652
  143. package/include/opencv2/core/traits.hpp +0 -417
  144. package/include/opencv2/core/types.hpp +0 -2457
  145. package/include/opencv2/core/types_c.h +0 -2126
  146. package/include/opencv2/core/utility.hpp +0 -1229
  147. package/include/opencv2/core/utils/allocator_stats.hpp +0 -29
  148. package/include/opencv2/core/utils/allocator_stats.impl.hpp +0 -158
  149. package/include/opencv2/core/utils/buffer_area.private.hpp +0 -136
  150. package/include/opencv2/core/utils/configuration.private.hpp +0 -22
  151. package/include/opencv2/core/utils/filesystem.hpp +0 -82
  152. package/include/opencv2/core/utils/filesystem.private.hpp +0 -66
  153. package/include/opencv2/core/utils/fp_control.private.hpp +0 -29
  154. package/include/opencv2/core/utils/fp_control_utils.hpp +0 -69
  155. package/include/opencv2/core/utils/instrumentation.hpp +0 -125
  156. package/include/opencv2/core/utils/lock.private.hpp +0 -119
  157. package/include/opencv2/core/utils/logger.defines.hpp +0 -42
  158. package/include/opencv2/core/utils/logger.hpp +0 -218
  159. package/include/opencv2/core/utils/logtag.hpp +0 -28
  160. package/include/opencv2/core/utils/plugin_loader.private.hpp +0 -165
  161. package/include/opencv2/core/utils/tls.hpp +0 -235
  162. package/include/opencv2/core/utils/trace.hpp +0 -252
  163. package/include/opencv2/core/utils/trace.private.hpp +0 -421
  164. package/include/opencv2/core/va_intel.hpp +0 -75
  165. package/include/opencv2/core/version.hpp +0 -26
  166. package/include/opencv2/core/vsx_utils.hpp +0 -1047
  167. package/include/opencv2/core.hpp +0 -3365
  168. package/include/opencv2/imgcodecs/imgcodecs.hpp +0 -48
  169. package/include/opencv2/imgcodecs/imgcodecs_c.h +0 -1
  170. package/include/opencv2/imgcodecs/ios.h +0 -59
  171. package/include/opencv2/imgcodecs/legacy/constants_c.h +0 -54
  172. package/include/opencv2/imgcodecs/macosx.h +0 -20
  173. package/include/opencv2/imgcodecs.hpp +0 -407
  174. package/include/opencv2/imgproc/bindings.hpp +0 -34
  175. package/include/opencv2/imgproc/detail/gcgraph.hpp +0 -395
  176. package/include/opencv2/imgproc/hal/hal.hpp +0 -246
  177. package/include/opencv2/imgproc/hal/interface.h +0 -46
  178. package/include/opencv2/imgproc/imgproc.hpp +0 -48
  179. package/include/opencv2/imgproc/imgproc_c.h +0 -1177
  180. package/include/opencv2/imgproc/segmentation.hpp +0 -141
  181. package/include/opencv2/imgproc/types_c.h +0 -659
  182. package/include/opencv2/imgproc.hpp +0 -5035
  183. package/include/opencv2/opencv_modules.hpp +0 -17
  184. package/libs/libjpeg-turbo.lib +0 -0
  185. package/libs/libpng.lib +0 -0
  186. package/libs/opencv_core470.lib +0 -0
  187. package/libs/opencv_imgcodecs470.lib +0 -0
  188. package/libs/opencv_imgproc470.lib +0 -0
  189. package/libs/zlib.lib +0 -0
  190. /package/dist/{keyCodes.js → keyCodes.cjs} +0 -0
  191. /package/dist/{keyCodes.d.ts → keyCodes.d.cts} +0 -0
@@ -1,1696 +0,0 @@
1
- // This file is part of OpenCV project.
2
- // It is subject to the license terms in the LICENSE file found in the top-level directory
3
- // of this distribution and at http://opencv.org/license.html.
4
- //
5
- //
6
- // License Agreement
7
- // For Open Source Computer Vision Library
8
- //
9
- // Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved.
10
- // Third party copyrights are property of their respective owners.
11
- //
12
- // Licensed under the Apache License, Version 2.0 (the "License");
13
- // you may not use this file except in compliance with the License.
14
- // You may obtain a copy of the License at
15
- //
16
- // http://www.apache.org/licenses/LICENSE-2.0
17
- //
18
- // Unless required by applicable law or agreed to in writing, software
19
- // distributed under the License is distributed on an "AS IS" BASIS,
20
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
- // See the License for the specific language governing permissions and
22
- // limitations under the License.
23
- //
24
- // Author: Liangqian Kong <chargerKong@126.com>
25
- // Longbu Wang <riskiest@gmail.com>
26
- #ifndef OPENCV_CORE_QUATERNION_HPP
27
- #define OPENCV_CORE_QUATERNION_HPP
28
-
29
- #include <opencv2/core.hpp>
30
- #include <opencv2/core/utils/logger.hpp>
31
- #include <iostream>
32
- namespace cv
33
- {
34
- //! @addtogroup core
35
- //! @{
36
-
37
- //! Unit quaternion flag
38
- enum QuatAssumeType
39
- {
40
- /**
41
- * This flag is specified by default.
42
- * If this flag is specified, the input quaternions are assumed to be not unit quaternions.
43
- * It can guarantee the correctness of the calculations,
44
- * although the calculation speed will be slower than the flag QUAT_ASSUME_UNIT.
45
- */
46
- QUAT_ASSUME_NOT_UNIT,
47
- /**
48
- * If this flag is specified, the input quaternions are assumed to be unit quaternions which
49
- * will save some computations. However, if this flag is specified without unit quaternion,
50
- * the program correctness of the result will not be guaranteed.
51
- */
52
- QUAT_ASSUME_UNIT
53
- };
54
-
55
- class QuatEnum
56
- {
57
- public:
58
- /** @brief Enum of Euler angles type.
59
- *
60
- * Without considering the possibility of using two different convertions for the definition of the rotation axes ,
61
- * there exists twelve possible sequences of rotation axes, divided into two groups:
62
- * - Proper Euler angles (Z-X-Z, X-Y-X, Y-Z-Y, Z-Y-Z, X-Z-X, Y-X-Y)
63
- * - Tait–Bryan angles (X-Y-Z, Y-Z-X, Z-X-Y, X-Z-Y, Z-Y-X, Y-X-Z).
64
- *
65
- * The three elemental rotations may be [extrinsic](https://en.wikipedia.org/wiki/Euler_angles#Definition_by_extrinsic_rotations)
66
- * (rotations about the axes *xyz* of the original coordinate system, which is assumed to remain motionless),
67
- * or [intrinsic](https://en.wikipedia.org/wiki/Euler_angles#Definition_by_intrinsic_rotations)(rotations about the axes of the rotating coordinate system *XYZ*, solidary with the moving body, which changes its orientation after each elemental rotation).
68
- *
69
- *
70
- * Extrinsic and intrinsic rotations are relevant.
71
- *
72
- * The definition of the Euler angles is as following,
73
- * - \f$\theta_1 \f$ represents the first rotation angle,
74
- * - \f$\theta_2 \f$ represents the second rotation angle,
75
- * - \f$\theta_3 \f$ represents the third rotation angle.
76
- *
77
- * For intrinsic rotations in the order of X-Y-Z, the rotation matrix R can be calculated by:\f[R =X(\theta_1) Y(\theta_2) Z(\theta_3) \f]
78
- * For extrinsic rotations in the order of X-Y-Z, the rotation matrix R can be calculated by:\f[R =Z({\theta_3}) Y({\theta_2}) X({\theta_1})\f]
79
- * where
80
- * \f[X({\theta})={\begin{bmatrix}1&0&0\\0&\cos {\theta_1} &-\sin {\theta_1} \\0&\sin {\theta_1} &\cos {\theta_1} \\\end{bmatrix}},
81
- * Y({\theta})={\begin{bmatrix}\cos \theta_{2}&0&\sin \theta_{2}\\0&1 &0 \\\ -sin \theta_2& 0&\cos \theta_{2} \\\end{bmatrix}},
82
- * Z({\theta})={\begin{bmatrix}\cos\theta_{3} &-\sin \theta_3&0\\\sin \theta_3 &\cos \theta_3 &0\\0&0&1\\\end{bmatrix}}.
83
- * \f]
84
- *
85
- * The function is designed according to this set of conventions:
86
- * - [Right handed](https://en.wikipedia.org/wiki/Right_hand_rule) reference frames are adopted, and the [right hand rule](https://en.wikipedia.org/wiki/Right_hand_rule) is used to determine the sign of angles.
87
- * - Each matrix is meant to represent an [active rotation](https://en.wikipedia.org/wiki/Active_and_passive_transformation) (the composing and composed matrices
88
- * are supposed to act on the coordinates of vectors defined in the initial fixed reference frame and give as a result the coordinates of a rotated vector defined in the same reference frame).
89
- * - For \f$\theta_1\f$ and \f$\theta_3\f$, the valid range is (−π, π].
90
- *
91
- * For \f$\theta_2\f$, the valid range is [−π/2, π/2] or [0, π].
92
- *
93
- * For Tait–Bryan angles, the valid range of \f$\theta_2\f$ is [−π/2, π/2]. When transforming a quaternion to Euler angles, the solution of Euler angles is unique in condition of \f$ \theta_2 \in (−π/2, π/2)\f$ .
94
- * If \f$\theta_2 = −π/2 \f$ or \f$ \theta_2 = π/2\f$, there are infinite solutions. The common name for this situation is gimbal lock.
95
- * For Proper Euler angles,the valid range of \f$\theta_2\f$ is in [0, π]. The solutions of Euler angles are unique in condition of \f$ \theta_2 \in (0, π)\f$ . If \f$\theta_2 =0 \f$ or \f$\theta_2 =π \f$,
96
- * there are infinite solutions and gimbal lock will occur.
97
- */
98
- enum EulerAnglesType
99
- {
100
- INT_XYZ, ///< Intrinsic rotations with the Euler angles type X-Y-Z
101
- INT_XZY, ///< Intrinsic rotations with the Euler angles type X-Z-Y
102
- INT_YXZ, ///< Intrinsic rotations with the Euler angles type Y-X-Z
103
- INT_YZX, ///< Intrinsic rotations with the Euler angles type Y-Z-X
104
- INT_ZXY, ///< Intrinsic rotations with the Euler angles type Z-X-Y
105
- INT_ZYX, ///< Intrinsic rotations with the Euler angles type Z-Y-X
106
- INT_XYX, ///< Intrinsic rotations with the Euler angles type X-Y-X
107
- INT_XZX, ///< Intrinsic rotations with the Euler angles type X-Z-X
108
- INT_YXY, ///< Intrinsic rotations with the Euler angles type Y-X-Y
109
- INT_YZY, ///< Intrinsic rotations with the Euler angles type Y-Z-Y
110
- INT_ZXZ, ///< Intrinsic rotations with the Euler angles type Z-X-Z
111
- INT_ZYZ, ///< Intrinsic rotations with the Euler angles type Z-Y-Z
112
-
113
- EXT_XYZ, ///< Extrinsic rotations with the Euler angles type X-Y-Z
114
- EXT_XZY, ///< Extrinsic rotations with the Euler angles type X-Z-Y
115
- EXT_YXZ, ///< Extrinsic rotations with the Euler angles type Y-X-Z
116
- EXT_YZX, ///< Extrinsic rotations with the Euler angles type Y-Z-X
117
- EXT_ZXY, ///< Extrinsic rotations with the Euler angles type Z-X-Y
118
- EXT_ZYX, ///< Extrinsic rotations with the Euler angles type Z-Y-X
119
- EXT_XYX, ///< Extrinsic rotations with the Euler angles type X-Y-X
120
- EXT_XZX, ///< Extrinsic rotations with the Euler angles type X-Z-X
121
- EXT_YXY, ///< Extrinsic rotations with the Euler angles type Y-X-Y
122
- EXT_YZY, ///< Extrinsic rotations with the Euler angles type Y-Z-Y
123
- EXT_ZXZ, ///< Extrinsic rotations with the Euler angles type Z-X-Z
124
- EXT_ZYZ, ///< Extrinsic rotations with the Euler angles type Z-Y-Z
125
- #ifndef CV_DOXYGEN
126
- EULER_ANGLES_MAX_VALUE
127
- #endif
128
- };
129
-
130
- };
131
-
132
- template <typename _Tp> class Quat;
133
- template <typename _Tp> std::ostream& operator<<(std::ostream&, const Quat<_Tp>&);
134
-
135
- /**
136
- * Quaternion is a number system that extends the complex numbers. It can be expressed as a
137
- * rotation in three-dimensional space.
138
- * A quaternion is generally represented in the form:
139
- * \f[q = w + x\boldsymbol{i} + y\boldsymbol{j} + z\boldsymbol{k}\f]
140
- * \f[q = [w, x, y, z]\f]
141
- * \f[q = [w, \boldsymbol{v}] \f]
142
- * \f[q = ||q||[\cos\psi, u_x\sin\psi,u_y\sin\psi, u_z\sin\psi].\f]
143
- * \f[q = ||q||[\cos\psi, \boldsymbol{u}\sin\psi]\f]
144
- * where \f$\psi = \frac{\theta}{2}\f$, \f$\theta\f$ represents rotation angle,
145
- * \f$\boldsymbol{u} = [u_x, u_y, u_z]\f$ represents normalized rotation axis,
146
- * and \f$||q||\f$ represents the norm of \f$q\f$.
147
- *
148
- * A unit quaternion is usually represents rotation, which has the form:
149
- * \f[q = [\cos\psi, u_x\sin\psi,u_y\sin\psi, u_z\sin\psi].\f]
150
- *
151
- * To create a quaternion representing the rotation around the axis \f$\boldsymbol{u}\f$
152
- * with angle \f$\theta\f$, you can use
153
- * ```
154
- * using namespace cv;
155
- * double angle = CV_PI;
156
- * Vec3d axis = {0, 0, 1};
157
- * Quatd q = Quatd::createFromAngleAxis(angle, axis);
158
- * ```
159
- *
160
- * You can simply use four same type number to create a quaternion
161
- * ```
162
- * Quatd q(1, 2, 3, 4);
163
- * ```
164
- * Or use a Vec4d or Vec4f vector.
165
- * ```
166
- * Vec4d vec{1, 2, 3, 4};
167
- * Quatd q(vec);
168
- * ```
169
- *
170
- * ```
171
- * Vec4f vec{1, 2, 3, 4};
172
- * Quatf q(vec);
173
- * ```
174
- *
175
- * If you already have a 3x3 rotation matrix R, then you can use
176
- * ```
177
- * Quatd q = Quatd::createFromRotMat(R);
178
- * ```
179
- *
180
- * If you already have a rotation vector rvec which has the form of `angle * axis`, then you can use
181
- * ```
182
- * Quatd q = Quatd::createFromRvec(rvec);
183
- * ```
184
- *
185
- * To extract the rotation matrix from quaternion, see toRotMat3x3()
186
- *
187
- * To extract the Vec4d or Vec4f, see toVec()
188
- *
189
- * To extract the rotation vector, see toRotVec()
190
- *
191
- * If there are two quaternions \f$q_0, q_1\f$ are needed to interpolate, you can use nlerp(), slerp() or spline()
192
- * ```
193
- * Quatd::nlerp(q0, q1, t)
194
- *
195
- * Quatd::slerp(q0, q1, t)
196
- *
197
- * Quatd::spline(q0, q0, q1, q1, t)
198
- * ```
199
- * spline can smoothly connect rotations of multiple quaternions
200
- *
201
- * Three ways to get an element in Quaternion
202
- * ```
203
- * Quatf q(1,2,3,4);
204
- * std::cout << q.w << std::endl; // w=1, x=2, y=3, z=4
205
- * std::cout << q[0] << std::endl; // q[0]=1, q[1]=2, q[2]=3, q[3]=4
206
- * std::cout << q.at(0) << std::endl;
207
- * ```
208
- */
209
- template <typename _Tp>
210
- class Quat
211
- {
212
- static_assert(std::is_floating_point<_Tp>::value, "Quaternion only make sense with type of float or double");
213
- using value_type = _Tp;
214
- public:
215
- static constexpr _Tp CV_QUAT_EPS = (_Tp)1.e-6;
216
- static constexpr _Tp CV_QUAT_CONVERT_THRESHOLD = (_Tp)1.e-6;
217
-
218
- Quat();
219
-
220
- /**
221
- * @brief From Vec4d or Vec4f.
222
- */
223
- explicit Quat(const Vec<_Tp, 4> &coeff);
224
-
225
- /**
226
- * @brief from four numbers.
227
- */
228
- Quat(_Tp w, _Tp x, _Tp y, _Tp z);
229
-
230
- /**
231
- * @brief from an angle, axis. Axis will be normalized in this function. And
232
- * it generates
233
- * \f[q = [\cos\psi, u_x\sin\psi,u_y\sin\psi, u_z\sin\psi].\f]
234
- * where \f$\psi = \frac{\theta}{2}\f$, \f$\theta\f$ is the rotation angle.
235
- */
236
- static Quat<_Tp> createFromAngleAxis(const _Tp angle, const Vec<_Tp, 3> &axis);
237
-
238
- /**
239
- * @brief from a 3x3 rotation matrix.
240
- */
241
- static Quat<_Tp> createFromRotMat(InputArray R);
242
-
243
- /**
244
- * @brief from a rotation vector
245
- * \f$r\f$ has the form \f$\theta \cdot \boldsymbol{u}\f$, where \f$\theta\f$
246
- * represents rotation angle and \f$\boldsymbol{u}\f$ represents normalized rotation axis.
247
- *
248
- * Angle and axis could be easily derived as:
249
- * \f[
250
- * \begin{equation}
251
- * \begin{split}
252
- * \psi &= ||r||\\
253
- * \boldsymbol{u} &= \frac{r}{\theta}
254
- * \end{split}
255
- * \end{equation}
256
- * \f]
257
- * Then a quaternion can be calculated by
258
- * \f[q = [\cos\psi, \boldsymbol{u}\sin\psi]\f]
259
- * where \f$\psi = \theta / 2 \f$
260
- */
261
- static Quat<_Tp> createFromRvec(InputArray rvec);
262
-
263
- /**
264
- * @brief
265
- * from Euler angles
266
- *
267
- * A quaternion can be generated from Euler angles by combining the quaternion representations of the Euler rotations.
268
- *
269
- * For example, if we use intrinsic rotations in the order of X-Y-Z,\f$\theta_1 \f$ is rotation around the X-axis, \f$\theta_2 \f$ is rotation around the Y-axis,
270
- * \f$\theta_3 \f$ is rotation around the Z-axis. The final quaternion q can be calculated by
271
- *
272
- * \f[ {q} = q_{X, \theta_1} q_{Y, \theta_2} q_{Z, \theta_3}\f]
273
- * where \f$ q_{X, \theta_1} \f$ is created from @ref createFromXRot, \f$ q_{Y, \theta_2} \f$ is created from @ref createFromYRot,
274
- * \f$ q_{Z, \theta_3} \f$ is created from @ref createFromZRot.
275
- * @param angles the Euler angles in a vector of length 3
276
- * @param eulerAnglesType the convertion Euler angles type
277
- */
278
- static Quat<_Tp> createFromEulerAngles(const Vec<_Tp, 3> &angles, QuatEnum::EulerAnglesType eulerAnglesType);
279
-
280
- /**
281
- * @brief get a quaternion from a rotation about the Y-axis by \f$\theta\f$ .
282
- * \f[q = \cos(\theta/2)+0 i+ sin(\theta/2) j +0k \f]
283
- */
284
- static Quat<_Tp> createFromYRot(const _Tp theta);
285
-
286
- /**
287
- * @brief get a quaternion from a rotation about the X-axis by \f$\theta\f$ .
288
- * \f[q = \cos(\theta/2)+sin(\theta/2) i +0 j +0 k \f]
289
- */
290
- static Quat<_Tp> createFromXRot(const _Tp theta);
291
-
292
- /**
293
- * @brief get a quaternion from a rotation about the Z-axis by \f$\theta\f$.
294
- * \f[q = \cos(\theta/2)+0 i +0 j +sin(\theta/2) k \f]
295
- */
296
- static Quat<_Tp> createFromZRot(const _Tp theta);
297
-
298
- /**
299
- * @brief a way to get element.
300
- * @param index over a range [0, 3].
301
- *
302
- * A quaternion q
303
- *
304
- * q.at(0) is equivalent to q.w,
305
- *
306
- * q.at(1) is equivalent to q.x,
307
- *
308
- * q.at(2) is equivalent to q.y,
309
- *
310
- * q.at(3) is equivalent to q.z.
311
- */
312
- _Tp at(size_t index) const;
313
-
314
- /**
315
- * @brief return the conjugate of this quaternion.
316
- * \f[q.conjugate() = (w, -x, -y, -z).\f]
317
- */
318
- Quat<_Tp> conjugate() const;
319
-
320
- /**
321
- *
322
- * @brief return the value of exponential value.
323
- * \f[\exp(q) = e^w (\cos||\boldsymbol{v}||+ \frac{v}{||\boldsymbol{v}||})\sin||\boldsymbol{v}||\f]
324
- * where \f$\boldsymbol{v} = [x, y, z].\f$
325
- * @param q a quaternion.
326
- *
327
- * For example:
328
- * ```
329
- * Quatd q{1,2,3,4};
330
- * cout << exp(q) << endl;
331
- * ```
332
- */
333
- template <typename T>
334
- friend Quat<T> exp(const Quat<T> &q);
335
-
336
- /**
337
- * @brief return the value of exponential value.
338
- * \f[\exp(q) = e^w (\cos||\boldsymbol{v}||+ \frac{v}{||\boldsymbol{v}||}\sin||\boldsymbol{v}||)\f]
339
- * where \f$\boldsymbol{v} = [x, y, z].\f$
340
- *
341
- * For example
342
- * ```
343
- * Quatd q{1,2,3,4};
344
- * cout << q.exp() << endl;
345
- * ```
346
- */
347
- Quat<_Tp> exp() const;
348
-
349
- /**
350
- * @brief return the value of logarithm function.
351
- * \f[\ln(q) = \ln||q|| + \frac{\boldsymbol{v}}{||\boldsymbol{v}||}\arccos\frac{w}{||q||}.\f]
352
- * where \f$\boldsymbol{v} = [x, y, z].\f$
353
- * @param q a quaternion.
354
- * @param assumeUnit if QUAT_ASSUME_UNIT, q assume to be a unit quaternion and this function will save some computations.
355
- *
356
- * For example
357
- * ```
358
- * Quatd q1{1,2,3,4};
359
- * cout << log(q1) << endl;
360
- * ```
361
- */
362
- template <typename T>
363
- friend Quat<T> log(const Quat<T> &q, QuatAssumeType assumeUnit);
364
-
365
- /**
366
- * @brief return the value of logarithm function.
367
- * \f[\ln(q) = \ln||q|| + \frac{\boldsymbol{v}}{||\boldsymbol{v}||}\arccos\frac{w}{||q||}\f].
368
- * where \f$\boldsymbol{v} = [x, y, z].\f$
369
- * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and this function will save some computations.
370
- *
371
- * For example
372
- * ```
373
- * Quatd q(1,2,3,4);
374
- * q.log();
375
- *
376
- * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT;
377
- * Quatd q1(1,2,3,4);
378
- * q1.normalize().log(assumeUnit);
379
- * ```
380
- */
381
- Quat<_Tp> log(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const;
382
-
383
- /**
384
- * @brief return the value of power function with index \f$x\f$.
385
- * \f[q^x = ||q||(cos(x\theta) + \boldsymbol{u}sin(x\theta))).\f]
386
- * @param q a quaternion.
387
- * @param x index of exponentiation.
388
- * @param assumeUnit if QUAT_ASSUME_UNIT, quaternion q assume to be a unit quaternion and this function will save some computations.
389
- *
390
- * For example
391
- * ```
392
- * Quatd q(1,2,3,4);
393
- * power(q, 2.0);
394
- *
395
- * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT;
396
- * double angle = CV_PI;
397
- * Vec3d axis{0, 0, 1};
398
- * Quatd q1 = Quatd::createFromAngleAxis(angle, axis); //generate a unit quat by axis and angle
399
- * power(q1, 2.0, assumeUnit);//This assumeUnit means q1 is a unit quaternion.
400
- * ```
401
- * @note the type of the index should be the same as the quaternion.
402
- */
403
- template <typename T>
404
- friend Quat<T> power(const Quat<T> &q, const T x, QuatAssumeType assumeUnit);
405
-
406
- /**
407
- * @brief return the value of power function with index \f$x\f$.
408
- * \f[q^x = ||q||(\cos(x\theta) + \boldsymbol{u}\sin(x\theta))).\f]
409
- * @param x index of exponentiation.
410
- * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and this function will save some computations.
411
- *
412
- * For example
413
- * ```
414
- * Quatd q(1,2,3,4);
415
- * q.power(2.0);
416
- *
417
- * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT;
418
- * double angle = CV_PI;
419
- * Vec3d axis{0, 0, 1};
420
- * Quatd q1 = Quatd::createFromAngleAxis(angle, axis); //generate a unit quat by axis and angle
421
- * q1.power(2.0, assumeUnit); //This assumeUnt means q1 is a unit quaternion
422
- * ```
423
- */
424
- Quat<_Tp> power(const _Tp x, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const;
425
-
426
- /**
427
- * @brief return \f$\sqrt{q}\f$.
428
- * @param q a quaternion.
429
- * @param assumeUnit if QUAT_ASSUME_UNIT, quaternion q assume to be a unit quaternion and this function will save some computations.
430
- *
431
- * For example
432
- * ```
433
- * Quatf q(1,2,3,4);
434
- * sqrt(q);
435
- *
436
- * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT;
437
- * q = {1,0,0,0};
438
- * sqrt(q, assumeUnit); //This assumeUnit means q is a unit quaternion.
439
- * ```
440
- */
441
- template <typename T>
442
- friend Quat<T> sqrt(const Quat<T> &q, QuatAssumeType assumeUnit);
443
-
444
- /**
445
- * @brief return \f$\sqrt{q}\f$.
446
- * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and this function will save some computations.
447
- *
448
- * For example
449
- * ```
450
- * Quatf q(1,2,3,4);
451
- * q.sqrt();
452
- *
453
- * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT;
454
- * q = {1,0,0,0};
455
- * q.sqrt(assumeUnit); //This assumeUnit means q is a unit quaternion
456
- * ```
457
- */
458
- Quat<_Tp> sqrt(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const;
459
-
460
- /**
461
- * @brief return the value of power function with quaternion \f$q\f$.
462
- * \f[p^q = e^{q\ln(p)}.\f]
463
- * @param p base quaternion of power function.
464
- * @param q index quaternion of power function.
465
- * @param assumeUnit if QUAT_ASSUME_UNIT, quaternion \f$p\f$ assume to be a unit quaternion and this function will save some computations.
466
- *
467
- * For example
468
- * ```
469
- * Quatd p(1,2,3,4);
470
- * Quatd q(5,6,7,8);
471
- * power(p, q);
472
- *
473
- * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT;
474
- * p = p.normalize();
475
- * power(p, q, assumeUnit); //This assumeUnit means p is a unit quaternion
476
- * ```
477
- */
478
- template <typename T>
479
- friend Quat<T> power(const Quat<T> &p, const Quat<T> &q, QuatAssumeType assumeUnit);
480
-
481
- /**
482
- * @brief return the value of power function with quaternion \f$q\f$.
483
- * \f[p^q = e^{q\ln(p)}.\f]
484
- * @param q index quaternion of power function.
485
- * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and this function will save some computations.
486
- *
487
- * For example
488
- * ```
489
- * Quatd p(1,2,3,4);
490
- * Quatd q(5,6,7,8);
491
- * p.power(q);
492
- *
493
- * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT;
494
- * p = p.normalize();
495
- * p.power(q, assumeUnit); //This assumeUnit means p is a unit quaternion
496
- * ```
497
- */
498
- Quat<_Tp> power(const Quat<_Tp> &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const;
499
-
500
- /**
501
- * @brief return the crossProduct between \f$p = (a, b, c, d) = (a, \boldsymbol{u})\f$ and \f$q = (w, x, y, z) = (w, \boldsymbol{v})\f$.
502
- * \f[p \times q = \frac{pq- qp}{2}\f]
503
- * \f[p \times q = \boldsymbol{u} \times \boldsymbol{v}\f]
504
- * \f[p \times q = (cz-dy)i + (dx-bz)j + (by-xc)k \f]
505
- *
506
- * For example
507
- * ```
508
- * Quatd q{1,2,3,4};
509
- * Quatd p{5,6,7,8};
510
- * crossProduct(p, q);
511
- * ```
512
- */
513
- template <typename T>
514
- friend Quat<T> crossProduct(const Quat<T> &p, const Quat<T> &q);
515
-
516
- /**
517
- * @brief return the crossProduct between \f$p = (a, b, c, d) = (a, \boldsymbol{u})\f$ and \f$q = (w, x, y, z) = (w, \boldsymbol{v})\f$.
518
- * \f[p \times q = \frac{pq- qp}{2}.\f]
519
- * \f[p \times q = \boldsymbol{u} \times \boldsymbol{v}.\f]
520
- * \f[p \times q = (cz-dy)i + (dx-bz)j + (by-xc)k. \f]
521
- *
522
- * For example
523
- * ```
524
- * Quatd q{1,2,3,4};
525
- * Quatd p{5,6,7,8};
526
- * p.crossProduct(q)
527
- * ```
528
- */
529
- Quat<_Tp> crossProduct(const Quat<_Tp> &q) const;
530
-
531
- /**
532
- * @brief return the norm of quaternion.
533
- * \f[||q|| = \sqrt{w^2 + x^2 + y^2 + z^2}.\f]
534
- */
535
- _Tp norm() const;
536
-
537
- /**
538
- * @brief return a normalized \f$p\f$.
539
- * \f[p = \frac{q}{||q||}\f]
540
- * where \f$p\f$ satisfies \f$(p.x)^2 + (p.y)^2 + (p.z)^2 + (p.w)^2 = 1.\f$
541
- */
542
- Quat<_Tp> normalize() const;
543
-
544
- /**
545
- * @brief return \f$q^{-1}\f$ which is an inverse of \f$q\f$
546
- * which satisfies \f$q * q^{-1} = 1\f$.
547
- * @param q a quaternion.
548
- * @param assumeUnit if QUAT_ASSUME_UNIT, quaternion q assume to be a unit quaternion and this function will save some computations.
549
- *
550
- * For example
551
- * ```
552
- * Quatd q(1,2,3,4);
553
- * inv(q);
554
- *
555
- * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT;
556
- * q = q.normalize();
557
- * inv(q, assumeUnit);//This assumeUnit means p is a unit quaternion
558
- * ```
559
- */
560
- template <typename T>
561
- friend Quat<T> inv(const Quat<T> &q, QuatAssumeType assumeUnit);
562
-
563
- /**
564
- * @brief return \f$q^{-1}\f$ which is an inverse of \f$q\f$
565
- * satisfying \f$q * q^{-1} = 1\f$.
566
- * @param assumeUnit if QUAT_ASSUME_UNIT, quaternion q assume to be a unit quaternion and this function will save some computations.
567
- *
568
- * For example
569
- * ```
570
- * Quatd q(1,2,3,4);
571
- * q.inv();
572
- *
573
- * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT;
574
- * q = q.normalize();
575
- * q.inv(assumeUnit); //assumeUnit means p is a unit quaternion
576
- * ```
577
- */
578
- Quat<_Tp> inv(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const;
579
-
580
- /**
581
- * @brief return sinh value of quaternion q, sinh could be calculated as:
582
- * \f[\sinh(p) = \sin(w)\cos(||\boldsymbol{v}||) + \cosh(w)\frac{v}{||\boldsymbol{v}||}\sin||\boldsymbol{v}||\f]
583
- * where \f$\boldsymbol{v} = [x, y, z].\f$
584
- * @param q a quaternion.
585
- *
586
- * For example
587
- * ```
588
- * Quatd q(1,2,3,4);
589
- * sinh(q);
590
- * ```
591
- */
592
- template <typename T>
593
- friend Quat<T> sinh(const Quat<T> &q);
594
-
595
- /**
596
- * @brief return sinh value of this quaternion, sinh could be calculated as:
597
- * \f$\sinh(p) = \sin(w)\cos(||\boldsymbol{v}||) + \cosh(w)\frac{v}{||\boldsymbol{v}||}\sin||\boldsymbol{v}||\f$
598
- * where \f$\boldsymbol{v} = [x, y, z].\f$
599
- *
600
- * For example
601
- * ```
602
- * Quatd q(1,2,3,4);
603
- * q.sinh();
604
- * ```
605
- */
606
- Quat<_Tp> sinh() const;
607
-
608
- /**
609
- * @brief return cosh value of quaternion q, cosh could be calculated as:
610
- * \f[\cosh(p) = \cosh(w) * \cos(||\boldsymbol{v}||) + \sinh(w)\frac{\boldsymbol{v}}{||\boldsymbol{v}||}\sin(||\boldsymbol{v}||)\f]
611
- * where \f$\boldsymbol{v} = [x, y, z].\f$
612
- * @param q a quaternion.
613
- *
614
- * For example
615
- * ```
616
- * Quatd q(1,2,3,4);
617
- * cosh(q);
618
- * ```
619
- */
620
- template <typename T>
621
- friend Quat<T> cosh(const Quat<T> &q);
622
-
623
- /**
624
- * @brief return cosh value of this quaternion, cosh could be calculated as:
625
- * \f[\cosh(p) = \cosh(w) * \cos(||\boldsymbol{v}||) + \sinh(w)\frac{\boldsymbol{v}}{||\boldsymbol{v}||}sin(||\boldsymbol{v}||)\f]
626
- * where \f$\boldsymbol{v} = [x, y, z].\f$
627
- *
628
- * For example
629
- * ```
630
- * Quatd q(1,2,3,4);
631
- * q.cosh();
632
- * ```
633
- */
634
- Quat<_Tp> cosh() const;
635
-
636
- /**
637
- * @brief return tanh value of quaternion q, tanh could be calculated as:
638
- * \f[ \tanh(q) = \frac{\sinh(q)}{\cosh(q)}.\f]
639
- * @param q a quaternion.
640
- *
641
- * For example
642
- * ```
643
- * Quatd q(1,2,3,4);
644
- * tanh(q);
645
- * ```
646
- * @sa sinh, cosh
647
- */
648
- template <typename T>
649
- friend Quat<T> tanh(const Quat<T> &q);
650
-
651
- /**
652
- * @brief return tanh value of this quaternion, tanh could be calculated as:
653
- * \f[ \tanh(q) = \frac{\sinh(q)}{\cosh(q)}.\f]
654
- *
655
- * For example
656
- * ```
657
- * Quatd q(1,2,3,4);
658
- * q.tanh();
659
- * ```
660
- * @sa sinh, cosh
661
- */
662
- Quat<_Tp> tanh() const;
663
-
664
- /**
665
- * @brief return tanh value of quaternion q, sin could be calculated as:
666
- * \f[\sin(p) = \sin(w) * \cosh(||\boldsymbol{v}||) + \cos(w)\frac{\boldsymbol{v}}{||\boldsymbol{v}||}\sinh(||\boldsymbol{v}||)\f]
667
- * where \f$\boldsymbol{v} = [x, y, z].\f$
668
- * @param q a quaternion.
669
- *
670
- * For example
671
- * ```
672
- * Quatd q(1,2,3,4);
673
- * sin(q);
674
- * ```
675
- */
676
- template <typename T>
677
- friend Quat<T> sin(const Quat<T> &q);
678
-
679
- /**
680
- * @brief return sin value of this quaternion, sin could be calculated as:
681
- * \f[\sin(p) = \sin(w) * \cosh(||\boldsymbol{v}||) + \cos(w)\frac{\boldsymbol{v}}{||\boldsymbol{v}||}\sinh(||\boldsymbol{v}||)\f]
682
- * where \f$\boldsymbol{v} = [x, y, z].\f$
683
- *
684
- * For example
685
- * ```
686
- * Quatd q(1,2,3,4);
687
- * q.sin();
688
- * ```
689
- */
690
- Quat<_Tp> sin() const;
691
-
692
- /**
693
- * @brief return sin value of quaternion q, cos could be calculated as:
694
- * \f[\cos(p) = \cos(w) * \cosh(||\boldsymbol{v}||) - \sin(w)\frac{\boldsymbol{v}}{||\boldsymbol{v}||}\sinh(||\boldsymbol{v}||)\f]
695
- * where \f$\boldsymbol{v} = [x, y, z].\f$
696
- * @param q a quaternion.
697
- *
698
- * For example
699
- * ```
700
- * Quatd q(1,2,3,4);
701
- * cos(q);
702
- * ```
703
- */
704
- template <typename T>
705
- friend Quat<T> cos(const Quat<T> &q);
706
-
707
- /**
708
- * @brief return cos value of this quaternion, cos could be calculated as:
709
- * \f[\cos(p) = \cos(w) * \cosh(||\boldsymbol{v}||) - \sin(w)\frac{\boldsymbol{v}}{||\boldsymbol{v}||}\sinh(||\boldsymbol{v}||)\f]
710
- * where \f$\boldsymbol{v} = [x, y, z].\f$
711
- *
712
- * For example
713
- * ```
714
- * Quatd q(1,2,3,4);
715
- * q.cos();
716
- * ```
717
- */
718
- Quat<_Tp> cos() const;
719
-
720
- /**
721
- * @brief return tan value of quaternion q, tan could be calculated as:
722
- * \f[\tan(q) = \frac{\sin(q)}{\cos(q)}.\f]
723
- * @param q a quaternion.
724
- *
725
- * For example
726
- * ```
727
- * Quatd q(1,2,3,4);
728
- * tan(q);
729
- * ```
730
- */
731
- template <typename T>
732
- friend Quat<T> tan(const Quat<T> &q);
733
-
734
- /**
735
- * @brief return tan value of this quaternion, tan could be calculated as:
736
- * \f[\tan(q) = \frac{\sin(q)}{\cos(q)}.\f]
737
- *
738
- * For example
739
- * ```
740
- * Quatd q(1,2,3,4);
741
- * q.tan();
742
- * ```
743
- */
744
- Quat<_Tp> tan() const;
745
-
746
- /**
747
- * @brief return arcsin value of quaternion q, arcsin could be calculated as:
748
- * \f[\arcsin(q) = -\frac{\boldsymbol{v}}{||\boldsymbol{v}||}arcsinh(q\frac{\boldsymbol{v}}{||\boldsymbol{v}||})\f]
749
- * where \f$\boldsymbol{v} = [x, y, z].\f$
750
- * @param q a quaternion.
751
- *
752
- * For example
753
- * ```
754
- * Quatd q(1,2,3,4);
755
- * asin(q);
756
- * ```
757
- */
758
- template <typename T>
759
- friend Quat<T> asin(const Quat<T> &q);
760
-
761
- /**
762
- * @brief return arcsin value of this quaternion, arcsin could be calculated as:
763
- * \f[\arcsin(q) = -\frac{\boldsymbol{v}}{||\boldsymbol{v}||}arcsinh(q\frac{\boldsymbol{v}}{||\boldsymbol{v}||})\f]
764
- * where \f$\boldsymbol{v} = [x, y, z].\f$
765
- *
766
- * For example
767
- * ```
768
- * Quatd q(1,2,3,4);
769
- * q.asin();
770
- * ```
771
- */
772
- Quat<_Tp> asin() const;
773
-
774
- /**
775
- * @brief return arccos value of quaternion q, arccos could be calculated as:
776
- * \f[\arccos(q) = -\frac{\boldsymbol{v}}{||\boldsymbol{v}||}arccosh(q)\f]
777
- * where \f$\boldsymbol{v} = [x, y, z].\f$
778
- * @param q a quaternion.
779
- *
780
- * For example
781
- * ```
782
- * Quatd q(1,2,3,4);
783
- * acos(q);
784
- * ```
785
- */
786
- template <typename T>
787
- friend Quat<T> acos(const Quat<T> &q);
788
-
789
- /**
790
- * @brief return arccos value of this quaternion, arccos could be calculated as:
791
- * \f[\arccos(q) = -\frac{\boldsymbol{v}}{||\boldsymbol{v}||}arccosh(q)\f]
792
- * where \f$\boldsymbol{v} = [x, y, z].\f$
793
- *
794
- * For example
795
- * ```
796
- * Quatd q(1,2,3,4);
797
- * q.acos();
798
- * ```
799
- */
800
- Quat<_Tp> acos() const;
801
-
802
- /**
803
- * @brief return arctan value of quaternion q, arctan could be calculated as:
804
- * \f[\arctan(q) = -\frac{\boldsymbol{v}}{||\boldsymbol{v}||}arctanh(q\frac{\boldsymbol{v}}{||\boldsymbol{v}||})\f]
805
- * where \f$\boldsymbol{v} = [x, y, z].\f$
806
- * @param q a quaternion.
807
- *
808
- * For example
809
- * ```
810
- * Quatd q(1,2,3,4);
811
- * atan(q);
812
- * ```
813
- */
814
- template <typename T>
815
- friend Quat<T> atan(const Quat<T> &q);
816
-
817
- /**
818
- * @brief return arctan value of this quaternion, arctan could be calculated as:
819
- * \f[\arctan(q) = -\frac{\boldsymbol{v}}{||\boldsymbol{v}||}arctanh(q\frac{\boldsymbol{v}}{||\boldsymbol{v}||})\f]
820
- * where \f$\boldsymbol{v} = [x, y, z].\f$
821
- *
822
- * For example
823
- * ```
824
- * Quatd q(1,2,3,4);
825
- * q.atan();
826
- * ```
827
- */
828
- Quat<_Tp> atan() const;
829
-
830
- /**
831
- * @brief return arcsinh value of quaternion q, arcsinh could be calculated as:
832
- * \f[arcsinh(q) = \ln(q + \sqrt{q^2 + 1})\f].
833
- * @param q a quaternion.
834
- *
835
- * For example
836
- * ```
837
- * Quatd q(1,2,3,4);
838
- * asinh(q);
839
- * ```
840
- */
841
- template <typename T>
842
- friend Quat<T> asinh(const Quat<T> &q);
843
-
844
- /**
845
- * @brief return arcsinh value of this quaternion, arcsinh could be calculated as:
846
- * \f[arcsinh(q) = \ln(q + \sqrt{q^2 + 1})\f].
847
- *
848
- * For example
849
- * ```
850
- * Quatd q(1,2,3,4);
851
- * q.asinh();
852
- * ```
853
- */
854
- Quat<_Tp> asinh() const;
855
-
856
- /**
857
- * @brief return arccosh value of quaternion q, arccosh could be calculated as:
858
- * \f[arccosh(q) = \ln(q + \sqrt{q^2 - 1})\f].
859
- * @param q a quaternion.
860
- *
861
- * For example
862
- * ```
863
- * Quatd q(1,2,3,4);
864
- * acosh(q);
865
- * ```
866
- */
867
- template <typename T>
868
- friend Quat<T> acosh(const Quat<T> &q);
869
-
870
- /**
871
- * @brief return arccosh value of this quaternion, arccosh could be calculated as:
872
- * \f[arcosh(q) = \ln(q + \sqrt{q^2 - 1})\f].
873
- *
874
- * For example
875
- * ```
876
- * Quatd q(1,2,3,4);
877
- * q.acosh();
878
- * ```
879
- */
880
- Quat<_Tp> acosh() const;
881
-
882
- /**
883
- * @brief return arctanh value of quaternion q, arctanh could be calculated as:
884
- * \f[arctanh(q) = \frac{\ln(q + 1) - \ln(1 - q)}{2}\f].
885
- * @param q a quaternion.
886
- *
887
- * For example
888
- * ```
889
- * Quatd q(1,2,3,4);
890
- * atanh(q);
891
- * ```
892
- */
893
- template <typename T>
894
- friend Quat<T> atanh(const Quat<T> &q);
895
-
896
- /**
897
- * @brief return arctanh value of this quaternion, arctanh could be calculated as:
898
- * \f[arcsinh(q) = \frac{\ln(q + 1) - \ln(1 - q)}{2}\f].
899
- *
900
- * For example
901
- * ```
902
- * Quatd q(1,2,3,4);
903
- * q.atanh();
904
- * ```
905
- */
906
- Quat<_Tp> atanh() const;
907
-
908
- /**
909
- * @brief return true if this quaternion is a unit quaternion.
910
- * @param eps tolerance scope of normalization. The eps could be defined as
911
- *
912
- * \f[eps = |1 - dotValue|\f] where \f[dotValue = (this.w^2 + this.x^2 + this,y^2 + this.z^2).\f]
913
- * And this function will consider it is normalized when the dotValue over a range \f$[1-eps, 1+eps]\f$.
914
- */
915
- bool isNormal(_Tp eps=CV_QUAT_EPS) const;
916
-
917
- /**
918
- * @brief to throw an error if this quaternion is not a unit quaternion.
919
- * @param eps tolerance scope of normalization.
920
- * @sa isNormal
921
- */
922
- void assertNormal(_Tp eps=CV_QUAT_EPS) const;
923
-
924
- /**
925
- * @brief transform a quaternion to a 3x3 rotation matrix.
926
- * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and
927
- * this function will save some computations. Otherwise, this function will normalize this
928
- * quaternion at first then do the transformation.
929
- *
930
- * @note Matrix A which is to be rotated should have the form
931
- * \f[\begin{bmatrix}
932
- * x_0& x_1& x_2&...&x_n\\
933
- * y_0& y_1& y_2&...&y_n\\
934
- * z_0& z_1& z_2&...&z_n
935
- * \end{bmatrix}\f]
936
- * where the same subscript represents a point. The shape of A assume to be [3, n]
937
- * The points matrix A can be rotated by toRotMat3x3() * A.
938
- * The result has 3 rows and n columns too.
939
-
940
- * For example
941
- * ```
942
- * double angle = CV_PI;
943
- * Vec3d axis{0,0,1};
944
- * Quatd q_unit = Quatd::createFromAngleAxis(angle, axis); //quaternion could also be get by interpolation by two or more quaternions.
945
- *
946
- * //assume there is two points (1,0,0) and (1,0,1) to be rotated
947
- * Mat pointsA = (Mat_<double>(2, 3) << 1,0,0,1,0,1);
948
- * //change the shape
949
- * pointsA = pointsA.t();
950
- * // rotate 180 degrees around the z axis
951
- * Mat new_point = q_unit.toRotMat3x3() * pointsA;
952
- * // print two points
953
- * cout << new_point << endl;
954
- * ```
955
- */
956
- Matx<_Tp, 3, 3> toRotMat3x3(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const;
957
-
958
- /**
959
- * @brief transform a quaternion to a 4x4 rotation matrix.
960
- * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and
961
- * this function will save some computations. Otherwise, this function will normalize this
962
- * quaternion at first then do the transformation.
963
- *
964
- * The operations is similar as toRotMat3x3
965
- * except that the points matrix should have the form
966
- * \f[\begin{bmatrix}
967
- * x_0& x_1& x_2&...&x_n\\
968
- * y_0& y_1& y_2&...&y_n\\
969
- * z_0& z_1& z_2&...&z_n\\
970
- * 0&0&0&...&0
971
- * \end{bmatrix}\f]
972
- *
973
- * @sa toRotMat3x3
974
- */
975
-
976
- Matx<_Tp, 4, 4> toRotMat4x4(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const;
977
-
978
- /**
979
- * @brief transform the this quaternion to a Vec<T, 4>.
980
- *
981
- * For example
982
- * ```
983
- * Quatd q(1,2,3,4);
984
- * q.toVec();
985
- * ```
986
- */
987
- Vec<_Tp, 4> toVec() const;
988
-
989
- /**
990
- * @brief transform this quaternion to a Rotation vector.
991
- * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and
992
- * this function will save some computations.
993
- * Rotation vector rVec is defined as:
994
- * \f[ rVec = [\theta v_x, \theta v_y, \theta v_z]\f]
995
- * where \f$\theta\f$ represents rotation angle, and \f$\boldsymbol{v}\f$ represents the normalized rotation axis.
996
- *
997
- * For example
998
- * ```
999
- * Quatd q(1,2,3,4);
1000
- * q.toRotVec();
1001
- *
1002
- * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT;
1003
- * q.normalize().toRotVec(assumeUnit); //answer is same as q.toRotVec().
1004
- * ```
1005
- */
1006
- Vec<_Tp, 3> toRotVec(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const;
1007
-
1008
- /**
1009
- * @brief get the angle of quaternion, it returns the rotation angle.
1010
- * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and
1011
- * this function will save some computations.
1012
- * \f[\psi = 2 *arccos(\frac{w}{||q||})\f]
1013
- *
1014
- * For example
1015
- * ```
1016
- * Quatd q(1,2,3,4);
1017
- * q.getAngle();
1018
- *
1019
- * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT;
1020
- * q.normalize().getAngle(assumeUnit);//same as q.getAngle().
1021
- * ```
1022
- * @note It always return the value between \f$[0, 2\pi]\f$.
1023
- */
1024
- _Tp getAngle(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const;
1025
-
1026
- /**
1027
- * @brief get the axis of quaternion, it returns a vector of length 3.
1028
- * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and
1029
- * this function will save some computations.
1030
- *
1031
- * the unit axis \f$\boldsymbol{u}\f$ is defined by
1032
- * \f[\begin{equation}
1033
- * \begin{split}
1034
- * \boldsymbol{v}
1035
- * &= \boldsymbol{u} ||\boldsymbol{v}||\\
1036
- * &= \boldsymbol{u}||q||sin(\frac{\theta}{2})
1037
- * \end{split}
1038
- * \end{equation}\f]
1039
- * where \f$v=[x, y ,z]\f$ and \f$\theta\f$ represents rotation angle.
1040
- *
1041
- *
1042
- * For example
1043
- * ```
1044
- * Quatd q(1,2,3,4);
1045
- * q.getAxis();
1046
- *
1047
- * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT;
1048
- * q.normalize().getAxis(assumeUnit);//same as q.getAxis()
1049
- * ```
1050
- */
1051
- Vec<_Tp, 3> getAxis(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const;
1052
-
1053
- /**
1054
- * @brief return the dot between quaternion \f$q\f$ and this quaternion.
1055
- *
1056
- * dot(p, q) is a good metric of how close the quaternions are.
1057
- * Indeed, consider the unit quaternion difference \f$p^{-1} * q\f$, its real part is dot(p, q).
1058
- * At the same time its real part is equal to \f$\cos(\beta/2)\f$ where \f$\beta\f$ is
1059
- * an angle of rotation between p and q, i.e.,
1060
- * Therefore, the closer dot(p, q) to 1,
1061
- * the smaller rotation between them.
1062
- * \f[p \cdot q = p.w \cdot q.w + p.x \cdot q.x + p.y \cdot q.y + p.z \cdot q.z\f]
1063
- * @param q the other quaternion.
1064
- *
1065
- * For example
1066
- * ```
1067
- * Quatd q(1,2,3,4);
1068
- * Quatd p(5,6,7,8);
1069
- * p.dot(q);
1070
- * ```
1071
- */
1072
- _Tp dot(Quat<_Tp> q) const;
1073
-
1074
- /**
1075
- * @brief To calculate the interpolation from \f$q_0\f$ to \f$q_1\f$ by Linear Interpolation(Nlerp)
1076
- * For two quaternions, this interpolation curve can be displayed as:
1077
- * \f[Lerp(q_0, q_1, t) = (1 - t)q_0 + tq_1.\f]
1078
- * Obviously, the lerp will interpolate along a straight line if we think of \f$q_0\f$ and \f$q_1\f$ as a vector
1079
- * in a two-dimensional space. When \f$t = 0\f$, it returns \f$q_0\f$ and when \f$t= 1\f$, it returns \f$q_1\f$.
1080
- * \f$t\f$ should to be ranged in \f$[0, 1]\f$ normally.
1081
- * @param q0 a quaternion used in linear interpolation.
1082
- * @param q1 a quaternion used in linear interpolation.
1083
- * @param t percent of vector \f$\overrightarrow{q_0q_1}\f$ over a range [0, 1].
1084
- * @note it returns a non-unit quaternion.
1085
- */
1086
- static Quat<_Tp> lerp(const Quat<_Tp> &q0, const Quat &q1, const _Tp t);
1087
-
1088
- /**
1089
- * @brief To calculate the interpolation from \f$q_0\f$ to \f$q_1\f$ by Normalized Linear Interpolation(Nlerp).
1090
- * it returns a normalized quaternion of Linear Interpolation(Lerp).
1091
- * \f[ Nlerp(q_0, q_1, t) = \frac{(1 - t)q_0 + tq_1}{||(1 - t)q_0 + tq_1||}.\f]
1092
- * The interpolation will always choose the shortest path but the constant speed is not guaranteed.
1093
- * @param q0 a quaternion used in normalized linear interpolation.
1094
- * @param q1 a quaternion used in normalized linear interpolation.
1095
- * @param t percent of vector \f$\overrightarrow{q_0q_1}\f$ over a range [0, 1].
1096
- * @param assumeUnit if QUAT_ASSUME_UNIT, all input quaternions assume to be unit quaternion. Otherwise, all inputs
1097
- quaternion will be normalized inside the function.
1098
- * @sa lerp
1099
- */
1100
- static Quat<_Tp> nlerp(const Quat<_Tp> &q0, const Quat &q1, const _Tp t, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT);
1101
-
1102
- /**
1103
- @brief To calculate the interpolation between \f$q_0\f$ and \f$q_1\f$ by Spherical Linear
1104
- Interpolation(Slerp), which can be defined as:
1105
- \f[ Slerp(q_0, q_1, t) = \frac{\sin((1-t)\theta)}{\sin(\theta)}q_0 + \frac{\sin(t\theta)}{\sin(\theta)}q_1\f]
1106
- where \f$\theta\f$ can be calculated as:
1107
- \f[\theta=cos^{-1}(q_0\cdot q_1)\f]
1108
- resulting from the both of their norm is unit.
1109
- @param q0 a quaternion used in Slerp.
1110
- @param q1 a quaternion used in Slerp.
1111
- @param t percent of angle between \f$q_0\f$ and \f$q_1\f$ over a range [0, 1].
1112
- @param assumeUnit if QUAT_ASSUME_UNIT, all input quaternions assume to be unit quaternions. Otherwise, all input
1113
- quaternions will be normalized inside the function.
1114
- @param directChange if QUAT_ASSUME_UNIT, the interpolation will choose the nearest path.
1115
- @note If the interpolation angle is small, the error between Nlerp and Slerp is not so large. To improve efficiency and
1116
- avoid zero division error, we use Nlerp instead of Slerp.
1117
- */
1118
- static Quat<_Tp> slerp(const Quat<_Tp> &q0, const Quat &q1, const _Tp t, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT, bool directChange=true);
1119
-
1120
- /**
1121
- * @brief To calculate the interpolation between \f$q_0\f$,\f$q_1\f$,\f$q_2\f$,\f$q_3\f$ by Spherical and quadrangle(Squad). This could be defined as:
1122
- * \f[Squad(q_i, s_i, s_{i+1}, q_{i+1}, t) = Slerp(Slerp(q_i, q_{i+1}, t), Slerp(s_i, s_{i+1}, t), 2t(1-t))\f]
1123
- * where
1124
- * \f[s_i = q_i\exp(-\frac{\log(q^*_iq_{i+1}) + \log(q^*_iq_{i-1})}{4})\f]
1125
- *
1126
- * The Squad expression is analogous to the \f$B\acute{e}zier\f$ curve, but involves spherical linear
1127
- * interpolation instead of simple linear interpolation. Each \f$s_i\f$ needs to be calculated by three
1128
- * quaternions.
1129
- *
1130
- * @param q0 the first quaternion.
1131
- * @param s0 the second quaternion.
1132
- * @param s1 the third quaternion.
1133
- * @param q1 thr fourth quaternion.
1134
- * @param t interpolation parameter of quadratic and linear interpolation over a range \f$[0, 1]\f$.
1135
- * @param assumeUnit if QUAT_ASSUME_UNIT, all input quaternions assume to be unit quaternion. Otherwise, all input
1136
- * quaternions will be normalized inside the function.
1137
- * @param directChange if QUAT_ASSUME_UNIT, squad will find the nearest path to interpolate.
1138
- * @sa interPoint, spline
1139
- */
1140
- static Quat<_Tp> squad(const Quat<_Tp> &q0, const Quat<_Tp> &s0,
1141
- const Quat<_Tp> &s1, const Quat<_Tp> &q1,
1142
- const _Tp t, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT,
1143
- bool directChange=true);
1144
-
1145
- /**
1146
- * @brief This is the part calculation of squad.
1147
- * To calculate the intermedia quaternion \f$s_i\f$ between each three quaternion
1148
- * \f[s_i = q_i\exp(-\frac{\log(q^*_iq_{i+1}) + \log(q^*_iq_{i-1})}{4}).\f]
1149
- * @param q0 the first quaternion.
1150
- * @param q1 the second quaternion.
1151
- * @param q2 the third quaternion.
1152
- * @param assumeUnit if QUAT_ASSUME_UNIT, all input quaternions assume to be unit quaternion. Otherwise, all input
1153
- * quaternions will be normalized inside the function.
1154
- * @sa squad
1155
- */
1156
- static Quat<_Tp> interPoint(const Quat<_Tp> &q0, const Quat<_Tp> &q1,
1157
- const Quat<_Tp> &q2, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT);
1158
-
1159
- /**
1160
- * @brief to calculate a quaternion which is the result of a \f$C^1\f$ continuous
1161
- * spline curve constructed by squad at the ratio t. Here, the interpolation values are
1162
- * between \f$q_1\f$ and \f$q_2\f$. \f$q_0\f$ and \f$q_2\f$ are used to ensure the \f$C^1\f$
1163
- * continuity. if t = 0, it returns \f$q_1\f$, if t = 1, it returns \f$q_2\f$.
1164
- * @param q0 the first input quaternion to ensure \f$C^1\f$ continuity.
1165
- * @param q1 the second input quaternion.
1166
- * @param q2 the third input quaternion.
1167
- * @param q3 the fourth input quaternion the same use of \f$q1\f$.
1168
- * @param t ratio over a range [0, 1].
1169
- * @param assumeUnit if QUAT_ASSUME_UNIT, \f$q_0, q_1, q_2, q_3\f$ assume to be unit quaternion. Otherwise, all input
1170
- * quaternions will be normalized inside the function.
1171
- *
1172
- * For example:
1173
- *
1174
- * If there are three double quaternions \f$v_0, v_1, v_2\f$ waiting to be interpolated.
1175
- *
1176
- * Interpolation between \f$v_0\f$ and \f$v_1\f$ with a ratio \f$t_0\f$ could be calculated as
1177
- * ```
1178
- * Quatd::spline(v0, v0, v1, v2, t0);
1179
- * ```
1180
- * Interpolation between \f$v_1\f$ and \f$v_2\f$ with a ratio \f$t_0\f$ could be calculated as
1181
- * ```
1182
- * Quatd::spline(v0, v1, v2, v2, t0);
1183
- * ```
1184
- * @sa squad, slerp
1185
- */
1186
- static Quat<_Tp> spline(const Quat<_Tp> &q0, const Quat<_Tp> &q1,
1187
- const Quat<_Tp> &q2, const Quat<_Tp> &q3,
1188
- const _Tp t, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT);
1189
-
1190
- /**
1191
- * @brief Return opposite quaternion \f$-p\f$
1192
- * which satisfies \f$p + (-p) = 0.\f$
1193
- *
1194
- * For example
1195
- * ```
1196
- * Quatd q{1, 2, 3, 4};
1197
- * std::cout << -q << std::endl; // [-1, -2, -3, -4]
1198
- * ```
1199
- */
1200
- Quat<_Tp> operator-() const;
1201
-
1202
- /**
1203
- * @brief return true if two quaternions p and q are nearly equal, i.e. when the absolute
1204
- * value of each \f$p_i\f$ and \f$q_i\f$ is less than CV_QUAT_EPS.
1205
- */
1206
- bool operator==(const Quat<_Tp>&) const;
1207
-
1208
- /**
1209
- * @brief Addition operator of two quaternions p and q.
1210
- * It returns a new quaternion that each value is the sum of \f$p_i\f$ and \f$q_i\f$.
1211
- *
1212
- * For example
1213
- * ```
1214
- * Quatd p{1, 2, 3, 4};
1215
- * Quatd q{5, 6, 7, 8};
1216
- * std::cout << p + q << std::endl; //[6, 8, 10, 12]
1217
- * ```
1218
- */
1219
- Quat<_Tp> operator+(const Quat<_Tp>&) const;
1220
-
1221
- /**
1222
- * @brief Addition assignment operator of two quaternions p and q.
1223
- * It adds right operand to the left operand and assign the result to left operand.
1224
- *
1225
- * For example
1226
- * ```
1227
- * Quatd p{1, 2, 3, 4};
1228
- * Quatd q{5, 6, 7, 8};
1229
- * p += q; // equivalent to p = p + q
1230
- * std::cout << p << std::endl; //[6, 8, 10, 12]
1231
- *
1232
- * ```
1233
- */
1234
- Quat<_Tp>& operator+=(const Quat<_Tp>&);
1235
-
1236
- /**
1237
- * @brief Subtraction operator of two quaternions p and q.
1238
- * It returns a new quaternion that each value is the sum of \f$p_i\f$ and \f$-q_i\f$.
1239
- *
1240
- * For example
1241
- * ```
1242
- * Quatd p{1, 2, 3, 4};
1243
- * Quatd q{5, 6, 7, 8};
1244
- * std::cout << p - q << std::endl; //[-4, -4, -4, -4]
1245
- * ```
1246
- */
1247
- Quat<_Tp> operator-(const Quat<_Tp>&) const;
1248
-
1249
- /**
1250
- * @brief Subtraction assignment operator of two quaternions p and q.
1251
- * It subtracts right operand from the left operand and assign the result to left operand.
1252
- *
1253
- * For example
1254
- * ```
1255
- * Quatd p{1, 2, 3, 4};
1256
- * Quatd q{5, 6, 7, 8};
1257
- * p -= q; // equivalent to p = p - q
1258
- * std::cout << p << std::endl; //[-4, -4, -4, -4]
1259
- *
1260
- * ```
1261
- */
1262
- Quat<_Tp>& operator-=(const Quat<_Tp>&);
1263
-
1264
- /**
1265
- * @brief Multiplication assignment operator of two quaternions q and p.
1266
- * It multiplies right operand with the left operand and assign the result to left operand.
1267
- *
1268
- * Rule of quaternion multiplication:
1269
- * \f[
1270
- * \begin{equation}
1271
- * \begin{split}
1272
- * p * q &= [p_0, \boldsymbol{u}]*[q_0, \boldsymbol{v}]\\
1273
- * &=[p_0q_0 - \boldsymbol{u}\cdot \boldsymbol{v}, p_0\boldsymbol{v} + q_0\boldsymbol{u}+ \boldsymbol{u}\times \boldsymbol{v}].
1274
- * \end{split}
1275
- * \end{equation}
1276
- * \f]
1277
- * where \f$\cdot\f$ means dot product and \f$\times \f$ means cross product.
1278
- *
1279
- * For example
1280
- * ```
1281
- * Quatd p{1, 2, 3, 4};
1282
- * Quatd q{5, 6, 7, 8};
1283
- * p *= q; // equivalent to p = p * q
1284
- * std::cout << p << std::endl; //[-60, 12, 30, 24]
1285
- * ```
1286
- */
1287
- Quat<_Tp>& operator*=(const Quat<_Tp>&);
1288
-
1289
- /**
1290
- * @brief Multiplication assignment operator of a quaternions and a scalar.
1291
- * It multiplies right operand with the left operand and assign the result to left operand.
1292
- *
1293
- * Rule of quaternion multiplication with a scalar:
1294
- * \f[
1295
- * \begin{equation}
1296
- * \begin{split}
1297
- * p * s &= [w, x, y, z] * s\\
1298
- * &=[w * s, x * s, y * s, z * s].
1299
- * \end{split}
1300
- * \end{equation}
1301
- * \f]
1302
- *
1303
- * For example
1304
- * ```
1305
- * Quatd p{1, 2, 3, 4};
1306
- * double s = 2.0;
1307
- * p *= s; // equivalent to p = p * s
1308
- * std::cout << p << std::endl; //[2.0, 4.0, 6.0, 8.0]
1309
- * ```
1310
- * @note the type of scalar should be equal to the quaternion.
1311
- */
1312
- Quat<_Tp>& operator*=(const _Tp s);
1313
-
1314
- /**
1315
- * @brief Multiplication operator of two quaternions q and p.
1316
- * Multiplies values on either side of the operator.
1317
- *
1318
- * Rule of quaternion multiplication:
1319
- * \f[
1320
- * \begin{equation}
1321
- * \begin{split}
1322
- * p * q &= [p_0, \boldsymbol{u}]*[q_0, \boldsymbol{v}]\\
1323
- * &=[p_0q_0 - \boldsymbol{u}\cdot \boldsymbol{v}, p_0\boldsymbol{v} + q_0\boldsymbol{u}+ \boldsymbol{u}\times \boldsymbol{v}].
1324
- * \end{split}
1325
- * \end{equation}
1326
- * \f]
1327
- * where \f$\cdot\f$ means dot product and \f$\times \f$ means cross product.
1328
- *
1329
- * For example
1330
- * ```
1331
- * Quatd p{1, 2, 3, 4};
1332
- * Quatd q{5, 6, 7, 8};
1333
- * std::cout << p * q << std::endl; //[-60, 12, 30, 24]
1334
- * ```
1335
- */
1336
- Quat<_Tp> operator*(const Quat<_Tp>&) const;
1337
-
1338
- /**
1339
- * @brief Division operator of a quaternions and a scalar.
1340
- * It divides left operand with the right operand and assign the result to left operand.
1341
- *
1342
- * Rule of quaternion division with a scalar:
1343
- * \f[
1344
- * \begin{equation}
1345
- * \begin{split}
1346
- * p / s &= [w, x, y, z] / s\\
1347
- * &=[w/s, x/s, y/s, z/s].
1348
- * \end{split}
1349
- * \end{equation}
1350
- * \f]
1351
- *
1352
- * For example
1353
- * ```
1354
- * Quatd p{1, 2, 3, 4};
1355
- * double s = 2.0;
1356
- * p /= s; // equivalent to p = p / s
1357
- * std::cout << p << std::endl; //[0.5, 1, 1.5, 2]
1358
- * ```
1359
- * @note the type of scalar should be equal to this quaternion.
1360
- */
1361
- Quat<_Tp> operator/(const _Tp s) const;
1362
-
1363
- /**
1364
- * @brief Division operator of two quaternions p and q.
1365
- * Divides left hand operand by right hand operand.
1366
- *
1367
- * Rule of quaternion division with a scalar:
1368
- * \f[
1369
- * \begin{equation}
1370
- * \begin{split}
1371
- * p / q &= p * q.inv()\\
1372
- * \end{split}
1373
- * \end{equation}
1374
- * \f]
1375
- *
1376
- * For example
1377
- * ```
1378
- * Quatd p{1, 2, 3, 4};
1379
- * Quatd q{5, 6, 7, 8};
1380
- * std::cout << p / q << std::endl; // equivalent to p * q.inv()
1381
- * ```
1382
- */
1383
- Quat<_Tp> operator/(const Quat<_Tp>&) const;
1384
-
1385
- /**
1386
- * @brief Division assignment operator of a quaternions and a scalar.
1387
- * It divides left operand with the right operand and assign the result to left operand.
1388
- *
1389
- * Rule of quaternion division with a scalar:
1390
- * \f[
1391
- * \begin{equation}
1392
- * \begin{split}
1393
- * p / s &= [w, x, y, z] / s\\
1394
- * &=[w / s, x / s, y / s, z / s].
1395
- * \end{split}
1396
- * \end{equation}
1397
- * \f]
1398
- *
1399
- * For example
1400
- * ```
1401
- * Quatd p{1, 2, 3, 4};
1402
- * double s = 2.0;;
1403
- * p /= s; // equivalent to p = p / s
1404
- * std::cout << p << std::endl; //[0.5, 1.0, 1.5, 2.0]
1405
- * ```
1406
- * @note the type of scalar should be equal to the quaternion.
1407
- */
1408
- Quat<_Tp>& operator/=(const _Tp s);
1409
-
1410
- /**
1411
- * @brief Division assignment operator of two quaternions p and q;
1412
- * It divides left operand with the right operand and assign the result to left operand.
1413
- *
1414
- * Rule of quaternion division with a quaternion:
1415
- * \f[
1416
- * \begin{equation}
1417
- * \begin{split}
1418
- * p / q&= p * q.inv()\\
1419
- * \end{split}
1420
- * \end{equation}
1421
- * \f]
1422
- *
1423
- * For example
1424
- * ```
1425
- * Quatd p{1, 2, 3, 4};
1426
- * Quatd q{5, 6, 7, 8};
1427
- * p /= q; // equivalent to p = p * q.inv()
1428
- * std::cout << p << std::endl;
1429
- * ```
1430
- */
1431
- Quat<_Tp>& operator/=(const Quat<_Tp>&);
1432
-
1433
- _Tp& operator[](std::size_t n);
1434
-
1435
- const _Tp& operator[](std::size_t n) const;
1436
-
1437
- /**
1438
- * @brief Subtraction operator of a scalar and a quaternions.
1439
- * Subtracts right hand operand from left hand operand.
1440
- *
1441
- * For example
1442
- * ```
1443
- * Quatd p{1, 2, 3, 4};
1444
- * double scalar = 2.0;
1445
- * std::cout << scalar - p << std::endl; //[1.0, -2, -3, -4]
1446
- * ```
1447
- * @note the type of scalar should be equal to the quaternion.
1448
- */
1449
- template <typename T>
1450
- friend Quat<T> cv::operator-(const T s, const Quat<T>&);
1451
-
1452
- /**
1453
- * @brief Subtraction operator of a quaternions and a scalar.
1454
- * Subtracts right hand operand from left hand operand.
1455
- *
1456
- * For example
1457
- * ```
1458
- * Quatd p{1, 2, 3, 4};
1459
- * double scalar = 2.0;
1460
- * std::cout << p - scalar << std::endl; //[-1.0, 2, 3, 4]
1461
- * ```
1462
- * @note the type of scalar should be equal to the quaternion.
1463
- */
1464
- template <typename T>
1465
- friend Quat<T> cv::operator-(const Quat<T>&, const T s);
1466
-
1467
- /**
1468
- * @brief Addition operator of a quaternions and a scalar.
1469
- * Adds right hand operand from left hand operand.
1470
- *
1471
- * For example
1472
- * ```
1473
- * Quatd p{1, 2, 3, 4};
1474
- * double scalar = 2.0;
1475
- * std::cout << scalar + p << std::endl; //[3.0, 2, 3, 4]
1476
- * ```
1477
- * @note the type of scalar should be equal to the quaternion.
1478
- */
1479
- template <typename T>
1480
- friend Quat<T> cv::operator+(const T s, const Quat<T>&);
1481
-
1482
- /**
1483
- * @brief Addition operator of a quaternions and a scalar.
1484
- * Adds right hand operand from left hand operand.
1485
- *
1486
- * For example
1487
- * ```
1488
- * Quatd p{1, 2, 3, 4};
1489
- * double scalar = 2.0;
1490
- * std::cout << p + scalar << std::endl; //[3.0, 2, 3, 4]
1491
- * ```
1492
- * @note the type of scalar should be equal to the quaternion.
1493
- */
1494
- template <typename T>
1495
- friend Quat<T> cv::operator+(const Quat<T>&, const T s);
1496
-
1497
- /**
1498
- * @brief Multiplication operator of a scalar and a quaternions.
1499
- * It multiplies right operand with the left operand and assign the result to left operand.
1500
- *
1501
- * Rule of quaternion multiplication with a scalar:
1502
- * \f[
1503
- * \begin{equation}
1504
- * \begin{split}
1505
- * p * s &= [w, x, y, z] * s\\
1506
- * &=[w * s, x * s, y * s, z * s].
1507
- * \end{split}
1508
- * \end{equation}
1509
- * \f]
1510
- *
1511
- * For example
1512
- * ```
1513
- * Quatd p{1, 2, 3, 4};
1514
- * double s = 2.0;
1515
- * std::cout << s * p << std::endl; //[2.0, 4.0, 6.0, 8.0]
1516
- * ```
1517
- * @note the type of scalar should be equal to the quaternion.
1518
- */
1519
- template <typename T>
1520
- friend Quat<T> cv::operator*(const T s, const Quat<T>&);
1521
-
1522
- /**
1523
- * @brief Multiplication operator of a quaternion and a scalar.
1524
- * It multiplies right operand with the left operand and assign the result to left operand.
1525
- *
1526
- * Rule of quaternion multiplication with a scalar:
1527
- * \f[
1528
- * \begin{equation}
1529
- * \begin{split}
1530
- * p * s &= [w, x, y, z] * s\\
1531
- * &=[w * s, x * s, y * s, z * s].
1532
- * \end{split}
1533
- * \end{equation}
1534
- * \f]
1535
- *
1536
- * For example
1537
- * ```
1538
- * Quatd p{1, 2, 3, 4};
1539
- * double s = 2.0;
1540
- * std::cout << p * s << std::endl; //[2.0, 4.0, 6.0, 8.0]
1541
- * ```
1542
- * @note the type of scalar should be equal to the quaternion.
1543
- */
1544
- template <typename T>
1545
- friend Quat<T> cv::operator*(const Quat<T>&, const T s);
1546
-
1547
- template <typename S>
1548
- friend std::ostream& cv::operator<<(std::ostream&, const Quat<S>&);
1549
-
1550
- /**
1551
- * @brief Transform a quaternion q to Euler angles.
1552
- *
1553
- *
1554
- * When transforming a quaternion \f$q = w + x\boldsymbol{i} + y\boldsymbol{j} + z\boldsymbol{k}\f$ to Euler angles, rotation matrix M can be calculated by:
1555
- * \f[ \begin{aligned} {M} &={\begin{bmatrix}1-2(y^{2}+z^{2})&2(xy-zx)&2(xz+yw)\\2(xy+zw)&1-2(x^{2}+z^{2})&2(yz-xw)\\2(xz-yw)&2(yz+xw)&1-2(x^{2}+y^{2})\end{bmatrix}}\end{aligned}.\f]
1556
- * On the other hand, the rotation matrix can be obtained from Euler angles.
1557
- * Using intrinsic rotations with Euler angles type XYZ as an example,
1558
- * \f$\theta_1 \f$, \f$\theta_2 \f$, \f$\theta_3 \f$ are three angles for Euler angles, the rotation matrix R can be calculated by:\f[R =X(\theta_1)Y(\theta_2)Z(\theta_3)
1559
- * ={\begin{bmatrix}\cos\theta_{2}\cos\theta_{3}&-\cos\theta_{2}\sin\theta_{3}&\sin\theta_{2}\\\cos\theta_{1}\sin\theta_{3}+\cos\theta_{3}\sin\theta_{1}\sin\theta_{2}&\cos\theta_{1}\cos\theta_{3}-\sin\theta_{1}\sin\theta_{2}\sin\theta_{3}&-\cos\theta_{2}\sin\theta_{1}\\\sin\theta_{1}\sin\theta_{3}-\cos\theta_{1}\cos\theta_{3}\sin\theta_{2}&\cos\theta_{3}\sin\theta_{1}+\cos\theta_{1}\sin\theta_{2}\sin\theta_{3}&\cos\theta_{1}\cos_{2}\end{bmatrix}}\f]
1560
- * Rotation matrix M and R are equal. As long as \f$ s_{2} \neq 1 \f$, by comparing each element of two matrices ,the solution is\f$\begin{cases} \theta_1 = \arctan2(-m_{23},m_{33})\\\theta_2 = arcsin(m_{13}) \\\theta_3 = \arctan2(-m_{12},m_{11}) \end{cases}\f$.
1561
- *
1562
- * When \f$ s_{2}=1\f$ or \f$ s_{2}=-1\f$, the gimbal lock occurs. The function will prompt "WARNING: Gimbal Lock will occur. Euler angles is non-unique. For intrinsic rotations, we set the third angle to 0, and for external rotation, we set the first angle to 0.".
1563
- *
1564
- * When \f$ s_{2}=1\f$ ,
1565
- * The rotation matrix R is \f$R = {\begin{bmatrix}0&0&1\\\sin(\theta_1+\theta_3)&\cos(\theta_1+\theta_3)&0\\-\cos(\theta_1+\theta_3)&\sin(\theta_1+\theta_3)&0\end{bmatrix}}\f$.
1566
- *
1567
- * The number of solutions is infinite with the condition \f$\begin{cases} \theta_1+\theta_3 = \arctan2(m_{21},m_{22})\\ \theta_2=\pi/2 \end{cases}\ \f$.
1568
- *
1569
- * We set \f$ \theta_3 = 0\f$, the solution is \f$\begin{cases} \theta_1=\arctan2(m_{21},m_{22})\\ \theta_2=\pi/2\\ \theta_3=0 \end{cases}\f$.
1570
- *
1571
- * When \f$ s_{2}=-1\f$,
1572
- * The rotation matrix R is \f$X_{1}Y_{2}Z_{3}={\begin{bmatrix}0&0&-1\\-\sin(\theta_1-\theta_3)&\cos(\theta_1-\theta_3)&0\\\cos(\theta_1-\theta_3)&\sin(\theta_1-\theta_3)&0\end{bmatrix}}\f$.
1573
- *
1574
- * The number of solutions is infinite with the condition \f$\begin{cases} \theta_1+\theta_3 = \arctan2(m_{32},m_{22})\\ \theta_2=\pi/2 \end{cases}\ \f$.
1575
- *
1576
- * We set \f$ \theta_3 = 0\f$, the solution is \f$ \begin{cases}\theta_1=\arctan2(m_{32},m_{22}) \\ \theta_2=-\pi/2\\ \theta_3=0\end{cases}\f$.
1577
- *
1578
- * Since \f$ sin \theta\in [-1,1] \f$ and \f$ cos \theta \in [-1,1] \f$, the unnormalized quaternion will cause computational troubles. For this reason, this function will normalize the quaternion at first and @ref QuatAssumeType is not needed.
1579
- *
1580
- * When the gimbal lock occurs, we set \f$\theta_3 = 0\f$ for intrinsic rotations or \f$\theta_1 = 0\f$ for extrinsic rotations.
1581
- *
1582
- * As a result, for every Euler angles type, we can get solution as shown in the following table.
1583
- * EulerAnglesType | Ordinary | \f$\theta_2 = π/2\f$ | \f$\theta_2 = -π/2\f$
1584
- * ------------- | -------------| -------------| -------------
1585
- * INT_XYZ|\f$ \theta_1 = \arctan2(-m_{23},m_{33})\\\theta_2 = \arcsin(m_{13}) \\\theta_3= \arctan2(-m_{12},m_{11}) \f$|\f$ \theta_1=\arctan2(m_{21},m_{22})\\ \theta_2=\pi/2\\ \theta_3=0 \f$|\f$ \theta_1=\arctan2(m_{32},m_{22})\\ \theta_2=-\pi/2\\ \theta_3=0 \f$
1586
- * INT_XZY|\f$ \theta_1 = \arctan2(m_{32},m_{22})\\\theta_2 = -\arcsin(m_{12}) \\\theta_3= \arctan2(m_{13},m_{11}) \f$|\f$ \theta_1=\arctan2(m_{31},m_{33})\\ \theta_2=\pi/2\\ \theta_3=0 \f$|\f$ \theta_1=\arctan2(-m_{23},m_{33})\\ \theta_2=-\pi/2\\ \theta_3=0 \f$
1587
- * INT_YXZ|\f$ \theta_1 = \arctan2(m_{13},m_{33})\\\theta_2 = -\arcsin(m_{23}) \\\theta_3= \arctan2(m_{21},m_{22}) \f$|\f$ \theta_1=\arctan2(m_{12},m_{11})\\ \theta_2=\pi/2\\ \theta_3=0 \f$|\f$ \theta_1=\arctan2(-m_{12},m_{11})\\ \theta_2=-\pi/2\\ \theta_3=0 \f$
1588
- * INT_YZX|\f$ \theta_1 = \arctan2(-m_{31},m_{11})\\\theta_2 = \arcsin(m_{21}) \\\theta_3= \arctan2(-m_{23},m_{22}) \f$|\f$ \theta_1=\arctan2(m_{13},m_{33})\\ \theta_2=\pi/2\\ \theta_3=0 \f$|\f$ \theta_1=\arctan2(m_{13},m_{12})\\ \theta_2=-\pi/2\\ \theta_3=0 \f$
1589
- * INT_ZXY|\f$ \theta_1 = \arctan2(-m_{12},m_{22})\\\theta_2 = \arcsin(m_{32}) \\\theta_3= \arctan2(-m_{31},m_{33}) \f$|\f$ \theta_1=\arctan2(m_{21},m_{11})\\ \theta_2=\pi/2\\ \theta_3=0 \f$|\f$ \theta_1=\arctan2(m_{21},m_{11})\\ \theta_2=-\pi/2\\ \theta_3=0 \f$
1590
- * INT_ZYX|\f$ \theta_1 = \arctan2(m_{21},m_{11})\\\theta_2 = \arcsin(-m_{31}) \\\theta_3= \arctan2(m_{32},m_{33}) \f$|\f$ \theta_1=\arctan2(m_{23},m_{22})\\ \theta_2=\pi/2\\ \theta_3=0 \f$|\f$ \theta_1=\arctan2(-m_{12},m_{22})\\ \theta_2=-\pi/2\\ \theta_3=0 \f$
1591
- * EXT_XYZ|\f$ \theta_1 = \arctan2(m_{32},m_{33})\\\theta_2 = \arcsin(-m_{31}) \\\ \theta_3 = \arctan2(m_{21},m_{11})\f$|\f$ \theta_1= 0\\ \theta_2=\pi/2\\ \theta_3=\arctan2(m_{23},m_{22}) \f$|\f$ \theta_1=0\\ \theta_2=-\pi/2\\ \theta_3=\arctan2(-m_{12},m_{22}) \f$
1592
- * EXT_XZY|\f$ \theta_1 = \arctan2(-m_{23},m_{22})\\\theta_2 = \arcsin(m_{21}) \\\theta_3= \arctan2(-m_{31},m_{11})\f$|\f$ \theta_1= 0\\ \theta_2=\pi/2\\ \theta_3=\arctan2(m_{13},m_{33}) \f$|\f$ \theta_1=0\\ \theta_2=-\pi/2\\ \theta_3=\arctan2(m_{13},m_{12}) \f$
1593
- * EXT_YXZ|\f$ \theta_1 = \arctan2(-m_{31},m_{33}) \\\theta_2 = \arcsin(m_{32}) \\\theta_3= \arctan2(-m_{12},m_{22})\f$|\f$ \theta_1= 0\\ \theta_2=\pi/2\\ \theta_3=\arctan2(m_{21},m_{11}) \f$|\f$ \theta_1=0\\ \theta_2=-\pi/2\\ \theta_3=\arctan2(m_{21},m_{11}) \f$
1594
- * EXT_YZX|\f$ \theta_1 = \arctan2(m_{13},m_{11})\\\theta_2 = -\arcsin(m_{12}) \\\theta_3= \arctan2(m_{32},m_{22})\f$|\f$ \theta_1= 0\\ \theta_2=\pi/2\\ \theta_3=\arctan2(m_{31},m_{33}) \f$|\f$ \theta_1=0\\ \theta_2=-\pi/2\\ \theta_3=\arctan2(-m_{23},m_{33}) \f$
1595
- * EXT_ZXY|\f$ \theta_1 = \arctan2(m_{21},m_{22})\\\theta_2 = -\arcsin(m_{23}) \\\theta_3= \arctan2(m_{13},m_{33})\f$|\f$ \theta_1= 0\\ \theta_2=\pi/2\\ \theta_3=\arctan2(m_{12},m_{11}) \f$|\f$ \theta_1= 0\\ \theta_2=-\pi/2\\ \theta_3=\arctan2(-m_{12},m_{11}) \f$
1596
- * EXT_ZYX|\f$ \theta_1 = \arctan2(-m_{12},m_{11})\\\theta_2 = \arcsin(m_{13}) \\\theta_3= \arctan2(-m_{23},m_{33})\f$|\f$ \theta_1=0\\ \theta_2=\pi/2\\ \theta_3=\arctan2(m_{21},m_{22}) \f$|\f$ \theta_1=0\\ \theta_2=-\pi/2\\ \theta_3=\arctan2(m_{32},m_{22}) \f$
1597
- *
1598
- * EulerAnglesType | Ordinary | \f$\theta_2 = 0\f$ | \f$\theta_2 = π\f$
1599
- * ------------- | -------------| -------------| -------------
1600
- * INT_XYX| \f$ \theta_1 = \arctan2(m_{21},-m_{31})\\\theta_2 =\arccos(m_{11}) \\\theta_3 = \arctan2(m_{12},m_{13}) \f$| \f$ \theta_1=\arctan2(m_{32},m_{33})\\ \theta_2=0\\ \theta_3=0 \f$| \f$ \theta_1=\arctan2(m_{23},m_{22})\\ \theta_2=\pi\\ \theta_3=0 \f$
1601
- * INT_XZX| \f$ \theta_1 = \arctan2(m_{31},m_{21})\\\theta_2 = \arccos(m_{11}) \\\theta_3 = \arctan2(m_{13},-m_{12}) \f$| \f$ \theta_1=\arctan2(m_{32},m_{33})\\ \theta_2=0\\ \theta_3=0 \f$| \f$ \theta_1=\arctan2(-m_{32},m_{33})\\ \theta_2=\pi\\ \theta_3=0 \f$
1602
- * INT_YXY| \f$ \theta_1 = \arctan2(m_{12},m_{32})\\\theta_2 = \arccos(m_{22}) \\\theta_3 = \arctan2(m_{21},-m_{23}) \f$| \f$ \theta_1=\arctan2(m_{13},m_{11})\\ \theta_2=0\\ \theta_3=0 \f$| \f$ \theta_1=\arctan2(-m_{31},m_{11})\\ \theta_2=\pi\\ \theta_3=0 \f$
1603
- * INT_YZY| \f$ \theta_1 = \arctan2(m_{32},-m_{12})\\\theta_2 = \arccos(m_{22}) \\\theta_3 =\arctan2(m_{23},m_{21}) \f$| \f$ \theta_1=\arctan2(m_{13},m_{11})\\ \theta_2=0\\ \theta_3=0 \f$| \f$ \theta_1=\arctan2(m_{13},-m_{11})\\ \theta_2=\pi\\ \theta_3=0 \f$
1604
- * INT_ZXZ| \f$ \theta_1 = \arctan2(-m_{13},m_{23})\\\theta_2 = \arccos(m_{33}) \\\theta_3 =\arctan2(m_{31},m_{32}) \f$| \f$ \theta_1=\arctan2(m_{21},m_{22})\\ \theta_2=0\\ \theta_3=0 \f$| \f$ \theta_1=\arctan2(m_{21},m_{11})\\ \theta_2=\pi\\ \theta_3=0 \f$
1605
- * INT_ZYZ| \f$ \theta_1 = \arctan2(m_{23},m_{13})\\\theta_2 = \arccos(m_{33}) \\\theta_3 = \arctan2(m_{32},-m_{31}) \f$| \f$ \theta_1=\arctan2(m_{21},m_{11})\\ \theta_2=0\\ \theta_3=0 \f$| \f$ \theta_1=\arctan2(m_{21},m_{11})\\ \theta_2=\pi\\ \theta_3=0 \f$
1606
- * EXT_XYX| \f$ \theta_1 = \arctan2(m_{12},m_{13}) \\\theta_2 = \arccos(m_{11}) \\\theta_3 = \arctan2(m_{21},-m_{31})\f$| \f$ \theta_1=0\\ \theta_2=0\\ \theta_3=\arctan2(m_{32},m_{33}) \f$| \f$ \theta_1= 0\\ \theta_2=\pi\\ \theta_3= \arctan2(m_{23},m_{22}) \f$
1607
- * EXT_XZX| \f$ \theta_1 = \arctan2(m_{13},-m_{12})\\\theta_2 = \arccos(m_{11}) \\\theta_3 = \arctan2(m_{31},m_{21})\f$| \f$ \theta_1= 0\\ \theta_2=0\\ \theta_3=\arctan2(m_{32},m_{33}) \f$| \f$ \theta_1= 0\\ \theta_2=\pi\\ \theta_3=\arctan2(-m_{32},m_{33}) \f$
1608
- * EXT_YXY| \f$ \theta_1 = \arctan2(m_{21},-m_{23})\\\theta_2 = \arccos(m_{22}) \\\theta_3 = \arctan2(m_{12},m_{32}) \f$| \f$ \theta_1= 0\\ \theta_2=0\\ \theta_3=\arctan2(m_{13},m_{11}) \f$| \f$ \theta_1= 0\\ \theta_2=\pi\\ \theta_3=\arctan2(-m_{31},m_{11}) \f$
1609
- * EXT_YZY| \f$ \theta_1 = \arctan2(m_{23},m_{21}) \\\theta_2 = \arccos(m_{22}) \\\theta_3 = \arctan2(m_{32},-m_{12}) \f$| \f$ \theta_1= 0\\ \theta_2=0\\ \theta_3=\arctan2(m_{13},m_{11}) \f$| \f$ \theta_1=0\\ \theta_2=\pi\\ \theta_3=\arctan2(m_{13},-m_{11}) \f$
1610
- * EXT_ZXZ| \f$ \theta_1 = \arctan2(m_{31},m_{32}) \\\theta_2 = \arccos(m_{33}) \\\theta_3 = \arctan2(-m_{13},m_{23})\f$| \f$ \theta_1=0\\ \theta_2=0\\ \theta_3=\arctan2(m_{21},m_{22}) \f$| \f$ \theta_1= 0\\ \theta_2=\pi\\ \theta_3=\arctan2(m_{21},m_{11}) \f$
1611
- * EXT_ZYZ| \f$ \theta_1 = \arctan2(m_{32},-m_{31})\\\theta_2 = \arccos(m_{33}) \\\theta_3 = \arctan2(m_{23},m_{13}) \f$| \f$ \theta_1=0\\ \theta_2=0\\ \theta_3=\arctan2(m_{21},m_{11}) \f$| \f$ \theta_1= 0\\ \theta_2=\pi\\ \theta_3=\arctan2(m_{21},m_{11}) \f$
1612
- *
1613
- * @param eulerAnglesType the convertion Euler angles type
1614
- */
1615
-
1616
- Vec<_Tp, 3> toEulerAngles(QuatEnum::EulerAnglesType eulerAnglesType);
1617
-
1618
- _Tp w, x, y, z;
1619
-
1620
- };
1621
-
1622
- template <typename T>
1623
- Quat<T> inv(const Quat<T> &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT);
1624
-
1625
- template <typename T>
1626
- Quat<T> sinh(const Quat<T> &q);
1627
-
1628
- template <typename T>
1629
- Quat<T> cosh(const Quat<T> &q);
1630
-
1631
- template <typename T>
1632
- Quat<T> tanh(const Quat<T> &q);
1633
-
1634
- template <typename T>
1635
- Quat<T> sin(const Quat<T> &q);
1636
-
1637
- template <typename T>
1638
- Quat<T> cos(const Quat<T> &q);
1639
-
1640
- template <typename T>
1641
- Quat<T> tan(const Quat<T> &q);
1642
-
1643
- template <typename T>
1644
- Quat<T> asinh(const Quat<T> &q);
1645
-
1646
- template <typename T>
1647
- Quat<T> acosh(const Quat<T> &q);
1648
-
1649
- template <typename T>
1650
- Quat<T> atanh(const Quat<T> &q);
1651
-
1652
- template <typename T>
1653
- Quat<T> asin(const Quat<T> &q);
1654
-
1655
- template <typename T>
1656
- Quat<T> acos(const Quat<T> &q);
1657
-
1658
- template <typename T>
1659
- Quat<T> atan(const Quat<T> &q);
1660
-
1661
- template <typename T>
1662
- Quat<T> power(const Quat<T> &q, const Quat<T> &p, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT);
1663
-
1664
- template <typename T>
1665
- Quat<T> exp(const Quat<T> &q);
1666
-
1667
- template <typename T>
1668
- Quat<T> log(const Quat<T> &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT);
1669
-
1670
- template <typename T>
1671
- Quat<T> power(const Quat<T>& q, const T x, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT);
1672
-
1673
- template <typename T>
1674
- Quat<T> crossProduct(const Quat<T> &p, const Quat<T> &q);
1675
-
1676
- template <typename S>
1677
- Quat<S> sqrt(const Quat<S> &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT);
1678
-
1679
- template <typename T>
1680
- Quat<T> operator*(const T, const Quat<T>&);
1681
-
1682
- template <typename T>
1683
- Quat<T> operator*(const Quat<T>&, const T);
1684
-
1685
- template <typename S>
1686
- std::ostream& operator<<(std::ostream&, const Quat<S>&);
1687
-
1688
- using Quatd = Quat<double>;
1689
- using Quatf = Quat<float>;
1690
-
1691
- //! @} core
1692
- }
1693
-
1694
- #include "opencv2/core/quaternion.inl.hpp"
1695
-
1696
- #endif /* OPENCV_CORE_QUATERNION_HPP */