MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
grad::VecRotInit< T, MatrixExpr > Class Template Reference

#include <matvec.h>

Collaboration diagram for grad::VecRotInit< T, MatrixExpr >:

Public Member Functions

 VecRotInit (const MatrixExpression< MatrixExpr, 3, 3 > &R)
 
index_type iGetNumRows () const
 
void Initialize (Vector< T, 3 > &unit) const
 

Static Public Attributes

static const index_type iNumRows = 3
 

Static Private Member Functions

static void RotCo (const T &phi, T &cf)
 

Private Attributes

const MatrixExpression
< MatrixExpr, 3, 3 > 
R
 

Detailed Description

template<typename T, typename MatrixExpr>
class grad::VecRotInit< T, MatrixExpr >

Definition at line 2814 of file matvec.h.

Constructor & Destructor Documentation

template<typename T , typename MatrixExpr >
grad::VecRotInit< T, MatrixExpr >::VecRotInit ( const MatrixExpression< MatrixExpr, 3, 3 > &  R)
inline

Definition at line 2818 of file matvec.h.

2819  :R(R) {
2820  }
const MatrixExpression< MatrixExpr, 3, 3 > R
Definition: matvec.h:2975

Member Function Documentation

template<typename T , typename MatrixExpr >
index_type grad::VecRotInit< T, MatrixExpr >::iGetNumRows ( void  ) const
inline

Definition at line 2822 of file matvec.h.

References grad::Vector< T, N_rows >::iNumRows.

2822 { return iNumRows; }
static const index_type iNumRows
Definition: matvec.h:2816
template<typename T , typename MatrixExpr >
void grad::VecRotInit< T, MatrixExpr >::Initialize ( Vector< T, 3 > &  unit) const
inline

Definition at line 2888 of file matvec.h.

References a, grad::atan2(), grad::Cross(), grad::Dot(), Mat3x3::GetCol(), grad::Matrix< T, N_rows, N_cols >::GetCol(), R, grad::sqrt(), and grad::Transpose().

2888  {
2889  // Modified from Appendix 2.4 of
2890  //
2891  // author = {Marco Borri and Lorenzo Trainelli and Carlo L. Bottasso},
2892  // title = {On Representations and Parameterizations of Motion},
2893  // journal = {Multibody System Dynamics},
2894  // volume = {4},
2895  // pages = {129--193},
2896  // year = {2000}
2897  using std::atan2;
2898  using std::sqrt;
2899 
2900  const T cosphi = 0.5 * (R(1, 1) + R(2, 2) + R(3, 3) - 1.);
2901 
2902  if (cosphi > 0.) {
2903  unit(1) = 0.5*(R(3, 2) - R(2, 3));
2904  unit(2) = 0.5*(R(1, 3) - R(3, 1));
2905  unit(3) = 0.5*(R(2, 1) - R(1, 2));
2906 
2907  const T sinphi2 = Dot(unit, unit);
2908  T sinphi;
2909 
2910  if (sinphi2 != 0) {
2911  sinphi = sqrt(sinphi2);
2912  } else {
2913  sinphi = unit(1);
2914  }
2915 
2916  const T phi = atan2(sinphi, cosphi);
2917  T a;
2918  RotCo(phi, a);
2919  unit /= a;
2920  } else {
2921  // -1 <= cosphi <= 0
2922  Matrix<T, 3, 3> eet = (R + Transpose(R)) * 0.5;
2923  eet(1, 1) -= cosphi;
2924  eet(2, 2) -= cosphi;
2925  eet(3, 3) -= cosphi;
2926  // largest (abs) component of unit vector phi/|phi|
2927  index_type maxcol = 1;
2928  if (eet(2, 2) > eet(1, 1)) {
2929  maxcol = 2;
2930  }
2931  if (eet(3, 3) > eet(maxcol, maxcol)) {
2932  maxcol = 3;
2933  }
2934  unit = (eet.GetCol(maxcol)/sqrt(eet(maxcol, maxcol)*(1. - cosphi)));
2935  T sinphi(0.);
2936  for (index_type i = 1; i <= 3; ++i) {
2937  sinphi -= Cross(unit, R.GetCol(i))(i) * 0.5;
2938  }
2939 
2940  unit *= atan2(sinphi, cosphi);
2941  }
2942  }
MatrixExpression< TransposedMatrix< MatrixDirectExpr< Matrix< T, N_rows, N_cols > > >, N_cols, N_rows > Transpose(const Matrix< T, N_rows, N_cols > &A)
Definition: matvec.h:2206
const MatrixExpression< MatrixExpr, 3, 3 > R
Definition: matvec.h:2975
integer index_type
Definition: gradient.h:104
static void RotCo(const T &phi, T &cf)
Definition: matvec.h:2945
DotTraits< VectorExprLhs, VectorExprRhs, N_rows, N_rows >::ExpressionType Dot(const VectorExpression< VectorExprLhs, N_rows > &u, const VectorExpression< VectorExprRhs, N_rows > &v)
Definition: matvec.h:3133
GradientExpression< UnaryExpr< FuncSqrt, Expr > > sqrt(const GradientExpression< Expr > &u)
Definition: gradient.h:2974
VectorExpression< VectorCrossExpr< VectorLhsExpr, VectorRhsExpr >, 3 > Cross(const VectorExpression< VectorLhsExpr, 3 > &u, const VectorExpression< VectorRhsExpr, 3 > &v)
Definition: matvec.h:3248
static const doublereal a
Definition: hfluid_.h:289
GradientExpression< BinaryExpr< FuncAtan2, LhsExpr, RhsExpr > > atan2(const GradientExpression< LhsExpr > &u, const GradientExpression< RhsExpr > &v)
Definition: gradient.h:2962

Here is the call graph for this function:

template<typename T , typename MatrixExpr >
static void grad::VecRotInit< T, MatrixExpr >::RotCo ( const T &  phi,
T &  cf 
)
inlinestaticprivate

Definition at line 2945 of file matvec.h.

References grad::cos(), grad::fabs(), grad::sin(), and grad::sqrt().

2945  {
2946  // This algorithm is a simplified version of RotCo in RotCoeff.hc
2947  // from Marco Morandini <morandini@aero.polimi.it>
2948  // and Teodoro Merlini <merlini@aero.polimi.it>
2949  using std::sin;
2950  using std::cos;
2951  using std::sqrt;
2952  using std::fabs;
2953 
2954  T phip[10];
2955  T phi2(phi * phi);
2956 
2957  if (fabs(phi) < RotCoeff::SerThrsh[0]) {
2958  phip[0] = 1.;
2959 
2960  for (index_type j = 1; j <= 9; j++) {
2961  phip[j] = phip[j - 1] * phi2;
2962  }
2963 
2964  cf = 0.;
2965 
2966  for (index_type j = 0; j < RotCoeff::SerTrunc[0]; j++) {
2967  cf += phip[j] / RotCoeff::SerCoeff[0][j];
2968  }
2969 
2970  return;
2971  }
2972 
2973  const T pd(sqrt(phi2));
2974  cf = sin(pd) / pd; // a = sin(phi)/phi
2975  };
GradientExpression< UnaryExpr< FuncSin, Expr > > sin(const GradientExpression< Expr > &u)
Definition: gradient.h:2977
integer index_type
Definition: gradient.h:104
GradientExpression< UnaryExpr< FuncFabs, Expr > > fabs(const GradientExpression< Expr > &u)
Definition: gradient.h:2973
GradientExpression< UnaryExpr< FuncSqrt, Expr > > sqrt(const GradientExpression< Expr > &u)
Definition: gradient.h:2974
GradientExpression< UnaryExpr< FuncCos, Expr > > cos(const GradientExpression< Expr > &u)
Definition: gradient.h:2978

Here is the call graph for this function:

Member Data Documentation

template<typename T , typename MatrixExpr >
const index_type grad::VecRotInit< T, MatrixExpr >::iNumRows = 3
static

Definition at line 2816 of file matvec.h.

template<typename T , typename MatrixExpr >
const MatrixExpression<MatrixExpr, 3, 3> grad::VecRotInit< T, MatrixExpr >::R
private

Definition at line 2975 of file matvec.h.


The documentation for this class was generated from the following file: