3 inline double operator/(
const dcovec2& A,
const dcovec2& B)
5 return A(0)*B(1) -A(1)*B(0);
10 inline double v2t(
const dcovec2& v)
12 return std::atan2(v(1),v(0));
17 inline dcovec2
rotate(
const dcovec2& v,
const double&
t)
20 w(0) =v(0)*std::cos(t) -v(1)*std::sin(t);
21 w(1) =v(0)*std::sin(t) +v(1)*std::cos(t);
37 inline dcovec3
operator/(
const dcovec3& A,
const dcovec3& B)
40 C(0) =A(1)*B(2) -A(2)*B(1);
41 C(1) =A(2)*B(0) -A(0)*B(2);
42 C(2) =A(0)*B(1) -A(1)*B(0);
56 inline dquater
vr2q(
const dcovec3& v,
const double& r)
58 return dquater(v(0),v(1),v(2),r);
63 inline dquater
vt2q(
const dcovec3& v,
const double& theta)
65 return vr2q( v/(
nrm2(v)+DBL_MIN)*std::sin(0.5*theta), std::cos(0.5*theta) );
70 inline dcovec3
rotate(
const dcovec3& v,
const dquater& q)
87 inline dquater
conj(
const dquater& q)
89 return dquater(-q(0),-q(1),-q(2), q(3));
94 inline dcovec3
imag(
const dquater& q)
96 return dcovec3(q(0),q(1),q(2));
101 inline dquater
inv(
const dquater& q)
102 {CPPL_VERBOSE_REPORT;
108 inline dquater
operator*(
const dquater& q1,
const dquater& q2)
109 {CPPL_VERBOSE_REPORT;
110 return dquater(q1(3)*q2(0) +q1(0)*q2(3) +q1(1)*q2(2) -q1(2)*q2(1),
111 q1(3)*q2(1) -q1(0)*q2(2) +q1(1)*q2(3) +q1(2)*q2(0),
112 q1(3)*q2(2) +q1(0)*q2(1) -q1(1)*q2(0) +q1(2)*q2(3),
113 q1(3)*q2(3) -q1(0)*q2(0) -q1(1)*q2(1) -q1(2)*q2(2) );
118 inline dquater
operator/(
const dquater& q1,
const dquater& q2)
119 {CPPL_VERBOSE_REPORT;
126 {CPPL_VERBOSE_REPORT;
134 {CPPL_VERBOSE_REPORT;
141 inline dcovec3
q2vt(
const dquater& q)
142 {CPPL_VERBOSE_REPORT;
143 double sin_theta_half;
144 double theta( 2.*std::acos(q(3)) );
147 sin_theta_half =std::sin(0.5*theta);
151 sin_theta_half =-std::sin(0.5*theta);
154 return dcovec3( theta*q(0)/sin_theta_half,
155 theta*q(1)/sin_theta_half,
156 theta*q(2)/sin_theta_half );
161 inline dgemat3
q2m(
const dquater& q)
162 {CPPL_VERBOSE_REPORT;
163 dquater cq(
conj(q) );
164 dquater X( dquater(+q(3),+q(2),-q(1),-q(0))*cq );
165 dquater Y( dquater(-q(2),+q(3),+q(0),-q(1))*cq );
166 dquater Z( dquater(+q(1),-q(0),+q(3),-q(2))*cq );
168 mat(0,0)=X(0); mat(0,1)=Y(0); mat(0,2)=Z(0);
169 mat(1,0)=X(1); mat(1,1)=Y(1); mat(1,2)=Z(1);
170 mat(2,0)=X(2); mat(2,1)=Y(2); mat(2,2)=Z(2);
dquater inv(const dquater &q)
dquater vt2q(const dcovec3 &v, const double &theta)
dcovec2 rotate(const dcovec2 &v, const double &t)
double nrm2(const _dcovector &vec)
dquater conj(const dquater &q)
dquater vr2q(const dcovec3 &v, const double &r)
dgemat3 q2m(const dquater &q)
dcovec3 operator/=(dcovec3 &A, const dcovec3 &B)
dcovec3 q2vt(const dquater &q)
double v2t(const dcovec2 &v)
double operator/(const dcovec2 &A, const dcovec2 &B)
drovector t(const _dcovector &covec)
dcovec3 imag(const dquater &q)
dquater operator*(const dquater &q1, const dquater &q2)
dquater operator*=(dquater &q1, const dquater &q2)