CPPLapack
 All Classes Files Functions Variables Friends
Functions
dcovector_small-specialized.hpp File Reference

Go to the source code of this file.

Functions

double operator/ (const dcovec2 &A, const dcovec2 &B)
double v2t (const dcovec2 &v)
dcovec2 rotate (const dcovec2 &v, const double &t)
dcovec3 operator/ (const dcovec3 &A, const dcovec3 &B)
dcovec3 operator/= (dcovec3 &A, const dcovec3 &B)
dquater vr2q (const dcovec3 &v, const double &r)
dquater vt2q (const dcovec3 &v, const double &theta)
dcovec3 rotate (const dcovec3 &v, const dquater &q)
dquater conj (const dquater &q)
dcovec3 imag (const dquater &q)
dquater inv (const dquater &q)
dquater operator* (const dquater &q1, const dquater &q2)
dquater operator/ (const dquater &q1, const dquater &q2)
dquater operator*= (dquater &q1, const dquater &q2)
dquater operator/= (dquater &q1, const dquater &q2)
dcovec3 q2vt (const dquater &q)
dgemat3 q2m (const dquater &q)

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.

{VERBOSE_REPORT;
  return A(0)*B(1) -A(1)*B(0);
}
double v2t ( const dcovec2 &  v) [inline]

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

{VERBOSE_REPORT;
  return atan2(v(1),v(0));
}
dcovec2 rotate ( const dcovec2 &  v,
const double &  t 
) [inline]

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

{VERBOSE_REPORT;
  dcovec2 w;
  w(0)=v(0)*cos(t)-v(1)*sin(t);
  w(1)=v(0)*sin(t)+v(1)*cos(t);
  return w;
}
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.

{VERBOSE_REPORT;
  dcovec3 C;
  C(0) =A(1)*B(2) -A(2)*B(1);
  C(1) =A(2)*B(0) -A(0)*B(2);
  C(2) =A(0)*B(1) -A(1)*B(0);
  return C;
}
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.

{VERBOSE_REPORT;
  A =A/B;
  return A;
}
dquater vr2q ( const dcovec3 &  v,
const double &  r 
) [inline]

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

Referenced by rotate(), and vt2q().

{VERBOSE_REPORT;
  return dquater(v(0),v(1),v(2),r);
}
dquater vt2q ( const dcovec3 &  v,
const double &  theta 
) [inline]

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

References nrm2(), and vr2q().

Referenced by m2q().

{VERBOSE_REPORT;
  return vr2q( v/(nrm2(v)+DBL_MIN)*std::sin(0.5*theta), std::cos(0.5*theta) );
}
dcovec3 rotate ( const dcovec3 &  v,
const dquater &  q 
) [inline]

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

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

{VERBOSE_REPORT;
  return imag( q*vr2q(v,0.)*conj(q) );
}
dquater conj ( const dquater &  q) [inline]

conjuction

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

{VERBOSE_REPORT;
  return dquater(-q(0),-q(1),-q(2), q(3));
}
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().

{VERBOSE_REPORT;
  return dcovec3(q(0),q(1),q(2));
}
dquater inv ( const dquater &  q) [inline]

inverse

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

References conj(), and nrm2().

Referenced by operator/().

{VERBOSE_REPORT;
  return conj(q)/pow(nrm2(q),2);
}
dquater operator* ( const dquater &  q1,
const dquater &  q2 
) [inline]

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

{VERBOSE_REPORT;
  return dquater(q1(3)*q2(0) +q1(0)*q2(3) +q1(1)*q2(2) -q1(2)*q2(1),
                 q1(3)*q2(1) -q1(0)*q2(2) +q1(1)*q2(3) +q1(2)*q2(0),
                 q1(3)*q2(2) +q1(0)*q2(1) -q1(1)*q2(0) +q1(2)*q2(3),
                 q1(3)*q2(3) -q1(0)*q2(0) -q1(1)*q2(1) -q1(2)*q2(2) );
}
dquater operator/ ( const dquater &  q1,
const dquater &  q2 
) [inline]

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

References inv().

{VERBOSE_REPORT;
  return q1*inv(q2);
}
dquater operator*= ( dquater &  q1,
const dquater &  q2 
) [inline]

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

{VERBOSE_REPORT;
  q1 =q1*q2;
  return q1;
}
dquater operator/= ( dquater &  q1,
const dquater &  q2 
) [inline]

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

{VERBOSE_REPORT;
  q1 =q1/q2;
  return q1;
}
dcovec3 q2vt ( const dquater &  q) [inline]

return vector from quaternion (|vector|=theta)

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

{VERBOSE_REPORT;
  double sin_theta_half;
  double theta( 2.*std::acos(q(3)) );
  
  if(theta<M_PI){
    sin_theta_half =std::sin(0.5*theta);
  }
  else{
    theta -=2.*M_PI;
    sin_theta_half =-std::sin(0.5*theta);
  }
  
  return dcovec3( theta*q(0)/sin_theta_half,
                  theta*q(1)/sin_theta_half,
                  theta*q(2)/sin_theta_half );
}
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().

{VERBOSE_REPORT;
  dquater cq( conj(q) );
  dquater X( dquater(+q(3),+q(2),-q(1),-q(0))*cq );
  dquater Y( dquater(-q(2),+q(3),+q(0),-q(1))*cq );
  dquater Z( dquater(+q(1),-q(0),+q(3),-q(2))*cq );
  dgemat3 mat;
  mat(0,0)=X(0); mat(0,1)=Y(0); mat(0,2)=Z(0);
  mat(1,0)=X(1); mat(1,1)=Y(1); mat(1,2)=Z(1);
  mat(2,0)=X(2); mat(2,1)=Y(2); mat(2,2)=Z(2);
  return mat;
}
 All Classes Files Functions Variables Friends