31 #ifndef DUAL_QUATERNION_HPP 32 #define DUAL_QUATERNION_HPP 41 template<
typename T>
inline int sign(T v)
43 return (v < 0) ? -1 : 1;
50 M(i, j + 1) = -w * q.
i;
51 M(i, j + 2) = -w * q.
j;
52 M(i, j + 3) = -w * q.
k;
53 M(i + 1, j) = w * q.
i;
54 M(i + 1, j + 1) = w * q.
w;
55 M(i + 1, j + 2) = -w * q.
k;
56 M(i + 1, j + 3) = w * q.
j;
57 M(i + 2, j) = w * q.
j;
58 M(i + 2, j + 1) = w * q.
k;
59 M(i + 2, j + 2) = w * q.
w;
60 M(i + 2, j + 3) = -w * q.
i;
61 M(i + 3, j) = w * q.
k;
62 M(i + 3, j + 1) = -w * q.
j;
63 M(i + 3, j + 2) = w * q.
i;
64 M(i + 3, j + 3) = w * q.
w;
95 double d =
dot(R, tR_2);
136 const double h0 = std::acos(R.
w);
137 if (h0 * h0 < dq_epsilon)
147 const double ish0 = 1.0 /
norm(R);
150 const double he = -tR_2.
w * ish0;
154 Rp *= -
dot(R, tR_2) /
dot(R, R);
172 const double h0 = 2.0 *
norm(R);
174 if (h0 * h0 < dq_epsilon)
184 const double sh0 =
sin(h0), ch0 =
cos(h0);
186 Rp *= -
dot(R, tR_2) /
dot(R, R);
193 Rp *= he * ch0 * 2.0 / h0;
209 result.
R = a.
R * b.
R;
238 M(i, j + 4) = M(i, j + 5) = M(i, j + 6) = M(i, j + 7) = 0;
239 M(i + 1, j + 4) = M(i + 1, j + 5) = M(i + 1, j + 6) = M(i + 1, j + 7) = 0;
240 M(i + 2, j + 4) = M(i + 2, j + 5) = M(i + 2, j + 6) = M(i + 2, j + 7) = 0;
241 M(i + 3, j + 4) = M(i + 3, j + 5) = M(i + 3, j + 6) = M(i + 3, j + 7) = 0;
258 return out <<
"( " << dq.
R.
w <<
", " << dq.
R.
i <<
", " << dq.
R.
j <<
", " << dq.
R.
k <<
", "
double dot(const dual_quaternion &a, const dual_quaternion &b)
dual_quaternion(double v=1.0)
dual_quaternion operator!(const dual_quaternion &a)
std::ostream & operator<<(std::ostream &out, const dual_quaternion &dq)
static dual_quaternion rigid_transformation(const quaternion< double > &r, const point3d &t)
void to_vector(T *p) const
dual_quaternion operator*(const dual_quaternion &a, const dual_quaternion &b)
point3d get_translation()
quaternion< double > tR_2
T norm(const quaternion< T > &a)
T dot(const quaternion< T > &a, const quaternion< T > &b)
dual_quaternion & normalize()
void set_dual_quaternion_matrix(matrix< double > &M, const dual_quaternion &dq, int i=0, int j=0, double w=1.0)
dual_quaternion & operator*=(double a)
dual_quaternion operator~(const dual_quaternion &a)
void normalize(quaternion< T > &q)
static dual_quaternion convert(const double *p)
void to_vector(double *p)
dual_quaternion & operator+=(const dual_quaternion &a)
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
static constexpr double dq_epsilon
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)
void set_quaternion_matrix(matrix< double > &M, const quaternion< double > &q, int i=0, int j=0, double w=1.0)