EstervQrCode 2.0.0
Library for qr code manipulation
Loading...
Searching...
No Matches
dualquaternion.hpp
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 <kongliangqian@huawei.com>
25// Longbu Wang <wanglongbu@huawei.com>
26#ifndef OPENCV_CORE_DUALQUATERNION_HPP
27#define OPENCV_CORE_DUALQUATERNION_HPP
28
29#include <opencv2/core/quaternion.hpp>
30#include <opencv2/core/affine.hpp>
31
32namespace cv{
35
36template <typename _Tp> class DualQuat;
37template <typename _Tp> std::ostream& operator<<(std::ostream&, const DualQuat<_Tp>&);
38
145template <typename _Tp>
147 static_assert(std::is_floating_point<_Tp>::value, "Dual quaternion only make sense with type of float or double");
148 using value_type = _Tp;
149
150public:
151 static constexpr _Tp CV_DUAL_QUAT_EPS = (_Tp)1.e-6;
152
153 DualQuat();
154
158 DualQuat(const _Tp w, const _Tp x, const _Tp y, const _Tp z, const _Tp w_, const _Tp x_, const _Tp y_, const _Tp z_);
159
164
165 _Tp w, x, y, z, w_, x_, y_, z_;
166
184 static DualQuat<_Tp> createFromQuat(const Quat<_Tp> &realPart, const Quat<_Tp> &dualPart);
185
209 static DualQuat<_Tp> createFromAngleAxisTrans(const _Tp angle, const Vec<_Tp, 3> &axis, const Vec<_Tp, 3> &translation);
210
242 static DualQuat<_Tp> createFromMat(InputArray _R);
243
247 static DualQuat<_Tp> createFromAffine3(const Affine3<_Tp> &R);
248
273 static DualQuat<_Tp> createFromPitch(const _Tp angle, const _Tp d, const Vec<_Tp, 3> &axis, const Vec<_Tp, 3> &moment);
274
280 Quat<_Tp> getRealPart() const;
281
287 Quat<_Tp> getDualPart() const;
288
301 template <typename T>
302 friend DualQuat<T> conjugate(const DualQuat<T> &dq);
303
315 DualQuat<_Tp> conjugate() const;
316
320 Quat<_Tp> getRotation(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const;
321
338 Vec<_Tp, 3> getTranslation(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const;
339
357 DualQuat<_Tp> norm() const;
358
395 DualQuat<_Tp> normalize() const;
396
407 template <typename T>
408 friend DualQuat<T> inv(const DualQuat<T> &dq, QuatAssumeType assumeUnit);
409
419 DualQuat<_Tp> inv(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const;
420
425 _Tp dot(DualQuat<_Tp> p) const;
426
438 template <typename T>
439 friend DualQuat<T> power(const DualQuat<T> &dq, const T t, QuatAssumeType assumeUnit);
440
452 DualQuat<_Tp> power(const _Tp t, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const;
453
465 template <typename T>
466 friend DualQuat<T> power(const DualQuat<T>& p, const DualQuat<T>& q, QuatAssumeType assumeUnit);
467
479 DualQuat<_Tp> power(const DualQuat<_Tp>& q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const;
480
485 template <typename T>
486 friend DualQuat<T> exp(const DualQuat<T> &dq);
487
491 DualQuat<_Tp> exp() const;
492
500 template <typename T>
501 friend DualQuat<T> log(const DualQuat<T> &dq, QuatAssumeType assumeUnit);
502
508 DualQuat<_Tp> log(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const;
509
513 Vec<_Tp, 8> toVec() const;
514
519 Matx<_Tp, 4, 4> toMat(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const;
520
524 Affine3<_Tp> toAffine3(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const;
525
552 static DualQuat<_Tp> sclerp(const DualQuat<_Tp> &q1, const DualQuat<_Tp> &q2, const _Tp t,
553 bool directChange=true, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT);
572 static DualQuat<_Tp> dqblend(const DualQuat<_Tp> &q1, const DualQuat<_Tp> &q2, const _Tp t,
573 QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT);
574
590 template <int cn>
591 static DualQuat<_Tp> gdqblend(const Vec<DualQuat<_Tp>, cn> &dualquat, InputArray weights,
592 QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT);
593
609 static DualQuat<_Tp> gdqblend(InputArray dualquat, InputArray weights,
610 QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT);
611
622 DualQuat<_Tp> operator-() const;
623
628 bool operator==(const DualQuat<_Tp>&) const;
629
642
657
669 DualQuat<_Tp> operator+(const DualQuat<_Tp>&) const;
670
685
710
735
736
760
784 DualQuat<_Tp> operator/(const _Tp s) const;
785
807
830
854 Quat<_Tp>& operator/=(const _Tp s);
855
868 template <typename T>
869 friend DualQuat<T> cv::operator+(const T s, const DualQuat<T>&);
870
883 template <typename T>
884 friend DualQuat<T> cv::operator+(const DualQuat<T>&, const T s);
885
908 template <typename T>
909 friend DualQuat<T> cv::operator*(const T s, const DualQuat<T>&);
910
923 template <typename T>
924 friend DualQuat<T> cv::operator-(const DualQuat<T>&, const T s);
925
938 template <typename T>
939 friend DualQuat<T> cv::operator-(const T s, const DualQuat<T>&);
940
963 template <typename T>
964 friend DualQuat<T> cv::operator*(const DualQuat<T>&, const T s);
965
966 template <typename S>
968
969};
970
973
975}//namespace
976
977#include "dualquaternion.inl.hpp"
978
979#endif /* OPENCV_CORE_QUATERNION_HPP */
Definition dualquaternion.hpp:146
DualQuat(const _Tp w, const _Tp x, const _Tp y, const _Tp z, const _Tp w_, const _Tp x_, const _Tp y_, const _Tp z_)
create from eight same type numbers.
DualQuat(const Vec< _Tp, 8 > &q)
create from a double or float vector.
DualQuat< _Tp > operator/(const _Tp s) const
Division operator of a dual quaternions and a scalar. It divides left operand with the right operand ...
DualQuat< _Tp > power(const _Tp t, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const
return the value of where p is a dual quaternion. This could be calculated as:
DualQuat< _Tp > operator*=(const _Tp s)
Multiplication assignment operator of a quaternions and a scalar. It multiplies right operand with th...
static DualQuat< _Tp > gdqblend(const Vec< DualQuat< _Tp >, cn > &dualquat, InputArray weights, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT)
The generalized Dual Quaternion linear Blending works for more than two rigid transformations....
DualQuat< _Tp > operator/(const DualQuat< _Tp > &) const
Division operator of two dual quaternions p and q. Divides left hand operand by right hand operand.
Quat< _Tp > & operator/=(const _Tp s)
Division assignment operator of a dual quaternions and a scalar. It divides left operand with the rig...
DualQuat< _Tp > operator-(const DualQuat< _Tp > &) const
Subtraction operator of two dual quaternions p and q. It returns a new dual quaternion that each valu...
DualQuat< _Tp > & operator*=(const DualQuat< _Tp > &)
Multiplication assignment operator of two quaternions. It multiplies right operand with the left oper...
DualQuat< _Tp > power(const DualQuat< _Tp > &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const
return the value of where p and q are dual quaternions. This could be calculated as:
_Tp w
Definition dualquaternion.hpp:165
DualQuat< _Tp > & operator/=(const DualQuat< _Tp > &)
Division assignment operator of two dual quaternions p and q; It divides left operand with the right ...
Template class for small matrices whose type and size are known at compilation time.
Definition matx.hpp:100
Definition quaternion.hpp:211
Template class for short numerical vectors, a partial case of Matx.
Definition matx.hpp:369
CV_EXPORTS_W double norm(InputArray src1, int normType=NORM_L2, InputArray mask=noArray())
Calculates the absolute norm of an array.
CV_EXPORTS_W void normalize(InputArray src, InputOutputArray dst, double alpha=1, double beta=0, int norm_type=NORM_L2, int dtype=-1, InputArray mask=noArray())
Normalizes the norm or value range of an array.
static String & operator<<(String &out, Ptr< Formatted > fmtd)
Definition core.hpp:3164
const CvArr * angle
Definition core_c.h:1194
CvArr double power
Definition core_c.h:1199
const CvArr CvArr * x
Definition core_c.h:1195
const CvArr * y
Definition core_c.h:1187
CV_INLINE v_reg< _Tp, n > & operator-=(v_reg< _Tp, n > &a, const v_reg< _Tp, n > &b)
CV_INLINE v_reg< _Tp, n > & operator+=(v_reg< _Tp, n > &a, const v_reg< _Tp, n > &b)
#define CV_EXPORTS
Definition cvdef.h:435
QuatAssumeType
Unit quaternion flag.
Definition quaternion.hpp:39
"black box" representation of the file storage associated with a file on disk.
Definition calib3d.hpp:441
DualQuat< T > inv(const DualQuat< T > &dq, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT)
Definition dualquaternion.inl.hpp:187
DualQuat< T > operator-(const DualQuat< T > &q, const T a)
Definition dualquaternion.inl.hpp:255
DualQuat< T > conjugate(const DualQuat< T > &dq)
Definition dualquaternion.inl.hpp:125
CV_EXPORTS bool operator==(const FileNodeIterator &it1, const FileNodeIterator &it2)
DualQuat< T > operator+(const T a, const DualQuat< T > &q)
Definition dualquaternion.inl.hpp:243
DualQuat< T > operator*(const T a, const DualQuat< T > &q)
Definition dualquaternion.inl.hpp:274