CPPLapack
 All Classes Files Functions Variables Friends Pages
Classes | Functions
dcovector_small.hpp File Reference

Go to the source code of this file.

Classes

class  dcovector_small< l >
 Samll Real Double-precision Column Vector Class. More...
 

Functions

double operator/ (const dcovec2 &, const dcovec2 &)
 
dcovec2 rotate (const dcovec2 &, const double &)
 
dcovec3 operator/ (const dcovec3 &, const dcovec3 &)
 
dcovec3 operator/= (dcovec3 &, const dcovec3 &)
 
dquater vr2q (const dcovec3 &, const double &)
 
dquater vt2q (const dcovec3 &, const double &)
 
dcovec3 rotate (const dcovec3 &, const dquater &)
 
dquater conj (const dquater &)
 
dcovec3 imag (const dquater &)
 
dquater inv (const dquater &)
 
dquater operator* (const dquater &, const dquater &)
 
dquater operator/ (const dquater &, const dquater &)
 
dquater operator*= (dquater &, const dquater &)
 
dquater operator/= (dquater &, const dquater &)
 
dcovec3 q2vt (const dquater &)
 
dgemat3 q2m (const dquater &)
 

Function Documentation

double operator/ ( const dcovec2 &  A,
const dcovec2 &  B 
)
inline

calculate vector product only for 2D vector

Definition at line 3 of file dcovector_small-specialized.hpp.

4 {CPPL_VERBOSE_REPORT;
5  return A(0)*B(1) -A(1)*B(0);
6 }
dcovec2 rotate ( const dcovec2 &  v,
const double &  t 
)
inline

rotate 2D vector by theta [rad]

Definition at line 17 of file dcovector_small-specialized.hpp.

18 {CPPL_VERBOSE_REPORT;
19  dcovec2 w;
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);
22  return w;
23 }
drovector t(const _dcovector &covec)
dcovec3 operator/ ( const dcovec3 &  A,
const dcovec3 &  B 
)
inline

calculate vector product only for 3D vector

Definition at line 37 of file dcovector_small-specialized.hpp.

38 {CPPL_VERBOSE_REPORT;
39  dcovec3 C;
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);
43  return C;
44 }
dcovec3 operator/= ( dcovec3 &  A,
const dcovec3 &  B 
)
inline

calculate vector product only for 3D vector

Definition at line 48 of file dcovector_small-specialized.hpp.

49 {CPPL_VERBOSE_REPORT;
50  A =A/B;
51  return A;
52 }
dquater vr2q ( const dcovec3 &  v,
const double &  r 
)
inline

make quaternion from imag vector and real value

Definition at line 56 of file dcovector_small-specialized.hpp.

Referenced by rotate(), and vt2q().

57 {CPPL_VERBOSE_REPORT;
58  return dquater(v(0),v(1),v(2),r);
59 }
dquater vt2q ( const dcovec3 &  v,
const double &  theta 
)
inline

make quaternion from directional vector and rotational angle

Definition at line 63 of file dcovector_small-specialized.hpp.

References nrm2(), and vr2q().

Referenced by m2q().

64 {CPPL_VERBOSE_REPORT;
65  return vr2q( v/(nrm2(v)+DBL_MIN)*std::sin(0.5*theta), std::cos(0.5*theta) );
66 }
double nrm2(const _dcovector &vec)
dquater vr2q(const dcovec3 &v, const double &r)
dcovec3 rotate ( const dcovec3 &  v,
const dquater &  q 
)
inline

rotate 3D vector by quaternion

Definition at line 70 of file dcovector_small-specialized.hpp.

References conj(), imag(), and vr2q().

71 {CPPL_VERBOSE_REPORT;
72  return imag( q*vr2q(v,0.)*conj(q) );
73 }
dquater conj(const dquater &q)
dquater vr2q(const dcovec3 &v, const double &r)
dcovec3 imag(const dquater &q)
dquater conj ( const dquater &  q)
inline

conjuction

Definition at line 87 of file dcovector_small-specialized.hpp.

Referenced by inv(), q2m(), and rotate().

88 {CPPL_VERBOSE_REPORT;
89  return dquater(-q(0),-q(1),-q(2), q(3));
90 }
dcovec3 imag ( const dquater &  q)
inline

imag

Definition at line 94 of file dcovector_small-specialized.hpp.

Referenced by zhsmatrix::checkup(), zhematrix::complete(), operator<<(), rotate(), _zhematrix::write(), and zhematrix::write().

95 {CPPL_VERBOSE_REPORT;
96  return dcovec3(q(0),q(1),q(2));
97 }
dquater inv ( const dquater &  q)
inline

inverse

Definition at line 101 of file dcovector_small-specialized.hpp.

References conj(), and nrm2().

Referenced by operator/().

102 {CPPL_VERBOSE_REPORT;
103  return conj(q)/std::pow(nrm2(q),2);
104 }
double nrm2(const _dcovector &vec)
dquater conj(const dquater &q)
dquater operator* ( const dquater &  q1,
const dquater &  q2 
)
inline

dquater*dquater operator

Definition at line 108 of file dcovector_small-specialized.hpp.

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) );
114 }
dquater operator/ ( const dquater &  q1,
const dquater &  q2 
)
inline

dquater/dquater operator

Definition at line 118 of file dcovector_small-specialized.hpp.

References inv().

119 {CPPL_VERBOSE_REPORT;
120  return q1*inv(q2);
121 }
dquater inv(const dquater &q)
dquater operator*= ( dquater &  q1,
const dquater &  q2 
)
inline

dquater*=dquater operator

Definition at line 125 of file dcovector_small-specialized.hpp.

126 {CPPL_VERBOSE_REPORT;
127  q1 =q1*q2;
128  return q1;
129 }
dquater operator/= ( dquater &  q1,
const dquater &  q2 
)
inline

dquater/=dquater operator

Definition at line 133 of file dcovector_small-specialized.hpp.

134 {CPPL_VERBOSE_REPORT;
135  q1 =q1/q2;
136  return q1;
137 }
dcovec3 q2vt ( const dquater &  q)
inline

return vector from quaternion (|vector|=theta)

Definition at line 141 of file dcovector_small-specialized.hpp.

142 {CPPL_VERBOSE_REPORT;
143  double sin_theta_half;
144  double theta( 2.*std::acos(q(3)) );
145 
146  if(theta<M_PI){
147  sin_theta_half =std::sin(0.5*theta);
148  }
149  else{
150  theta -=2.*M_PI;
151  sin_theta_half =-std::sin(0.5*theta);
152  }
153 
154  return dcovec3( theta*q(0)/sin_theta_half,
155  theta*q(1)/sin_theta_half,
156  theta*q(2)/sin_theta_half );
157 }
dgemat3 q2m ( const dquater &  q)
inline

return rotational matrix made of quaternion

Definition at line 161 of file dcovector_small-specialized.hpp.

References conj().

Referenced by rotate().

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 );
167  dgemat3 mat;
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);
171  return mat;
172 }
dquater conj(const dquater &q)