CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Static Private Member Functions

FrameToFrameDerivative Class Reference

#include <FrameToFrameDerivative.h>

List of all members.

Public Member Functions

AlgebraicMatrix frameToFrameDerivative (const Alignable *object, const Alignable *composedObject) const
 Return the derivative DeltaFrame(object)/DeltaFrame(composedobject)
AlgebraicMatrix66 getDerivative (const align::RotationType &objectRot, const align::RotationType &composeRot, const align::GlobalPoint &objectPos, const align::GlobalPoint &composePos) const

Private Member Functions

AlgebraicMatrix derivativePosPos (const AlgebraicMatrix &RotDet, const AlgebraicMatrix &RotRot) const
 Calculates the derivative DPos/DPos.
AlgebraicMatrix derivativePosRot (const AlgebraicMatrix &RotDet, const AlgebraicMatrix &RotRot, const AlgebraicVector &S) const
 Calculates the derivative DPos/DRot.
AlgebraicMatrix derivativeRotRot (const AlgebraicMatrix &RotDet, const AlgebraicMatrix &RotRot) const
 Calculates the derivative DRot/DRot.
AlgebraicMatrix getDerivative (const align::RotationType &objectRot, const align::RotationType &composeRot, const align::GlobalVector &posVec) const
 Calculates derivatives using the orientation Matrixes and the origin difference vector.
AlgebraicVector linearEulerAngles (const AlgebraicMatrix &rotDelta) const
 Gets linear approximated euler Angles.

Static Private Member Functions

static AlgebraicMatrix transform (const align::RotationType &)
 Helper to transform from RotationType to AlgebraicMatrix.

Detailed Description

class for calculating derivatives between different frames

Date:
2010/12/14 01:02:34
Revision:
1.7

(last update by

Author:
flucke

)

Definition at line 17 of file FrameToFrameDerivative.h.


Member Function Documentation

AlgebraicMatrix FrameToFrameDerivative::derivativePosPos ( const AlgebraicMatrix RotDet,
const AlgebraicMatrix RotRot 
) const [private]

Calculates the derivative DPos/DPos.

Definition at line 106 of file FrameToFrameDerivative.cc.

Referenced by getDerivative().

{

  return RotDet * RotRot.T();

}
AlgebraicMatrix FrameToFrameDerivative::derivativePosRot ( const AlgebraicMatrix RotDet,
const AlgebraicMatrix RotRot,
const AlgebraicVector S 
) const [private]

Calculates the derivative DPos/DRot.

Definition at line 117 of file FrameToFrameDerivative.cc.

Referenced by getDerivative().

{

 AlgebraicVector dEulerA(3);
 AlgebraicVector dEulerB(3);
 AlgebraicVector dEulerC(3);
 AlgebraicMatrix RotDa(3,3);
 AlgebraicMatrix RotDb(3,3);
 AlgebraicMatrix RotDc(3,3);
 
 RotDa[1][2] =  1; RotDa[2][1] = -1;
 RotDb[0][2] = -1; RotDb[2][0] =  1; // New beta sign
 RotDc[0][1] =  1; RotDc[1][0] = -1;
 
 dEulerA = RotDet*( RotRot.T()*RotDa*RotRot*S );
 dEulerB = RotDet*( RotRot.T()*RotDb*RotRot*S );
 dEulerC = RotDet*( RotRot.T()*RotDc*RotRot*S );

 AlgebraicMatrix eulerDeriv(3,3);
 eulerDeriv[0][0] = dEulerA[0];
 eulerDeriv[1][0] = dEulerA[1];
 eulerDeriv[2][0] = dEulerA[2];
 eulerDeriv[0][1] = dEulerB[0];
 eulerDeriv[1][1] = dEulerB[1];
 eulerDeriv[2][1] = dEulerB[2];
 eulerDeriv[0][2] = dEulerC[0];
 eulerDeriv[1][2] = dEulerC[1];
 eulerDeriv[2][2] = dEulerC[2];

 return eulerDeriv;

}
AlgebraicMatrix FrameToFrameDerivative::derivativeRotRot ( const AlgebraicMatrix RotDet,
const AlgebraicMatrix RotRot 
) const [private]

Calculates the derivative DRot/DRot.

Definition at line 155 of file FrameToFrameDerivative.cc.

References linearEulerAngles().

Referenced by getDerivative().

{

 AlgebraicVector dEulerA(3);
 AlgebraicVector dEulerB(3);
 AlgebraicVector dEulerC(3);
 AlgebraicMatrix RotDa(3,3);
 AlgebraicMatrix RotDb(3,3);
 AlgebraicMatrix RotDc(3,3);

 RotDa[1][2] =  1; RotDa[2][1] = -1;
 RotDb[0][2] = -1; RotDb[2][0] =  1; // New beta sign
 RotDc[0][1] =  1; RotDc[1][0] = -1;

 dEulerA = linearEulerAngles( RotDet*RotRot.T()*RotDa*RotRot*RotDet.T() );
 dEulerB = linearEulerAngles( RotDet*RotRot.T()*RotDb*RotRot*RotDet.T() );
 dEulerC = linearEulerAngles( RotDet*RotRot.T()*RotDc*RotRot*RotDet.T() );

 AlgebraicMatrix eulerDeriv(3,3);

 eulerDeriv[0][0] = dEulerA[0];
 eulerDeriv[1][0] = dEulerA[1];
 eulerDeriv[2][0] = dEulerA[2];
 eulerDeriv[0][1] = dEulerB[0];
 eulerDeriv[1][1] = dEulerB[1];
 eulerDeriv[2][1] = dEulerB[2];
 eulerDeriv[0][2] = dEulerC[0];
 eulerDeriv[1][2] = dEulerC[1];
 eulerDeriv[2][2] = dEulerC[2];

 return eulerDeriv;

}
AlgebraicMatrix FrameToFrameDerivative::frameToFrameDerivative ( const Alignable object,
const Alignable composedObject 
) const
AlgebraicMatrix FrameToFrameDerivative::getDerivative ( const align::RotationType objectRot,
const align::RotationType composeRot,
const align::GlobalVector posVec 
) const [private]

Calculates derivatives using the orientation Matrixes and the origin difference vector.

Definition at line 38 of file FrameToFrameDerivative.cc.

References funct::derivative(), derivativePosPos(), derivativePosRot(), derivativeRotRot(), transform(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

{

  AlgebraicMatrix rotDet   = transform(objectRot);
  AlgebraicMatrix rotCompO = transform(composeRot);

  AlgebraicVector diffVec(3);

  diffVec(1) = posVec.x();
  diffVec(2) = posVec.y();
  diffVec(3) = posVec.z();

  AlgebraicMatrix derivative(6,6);

  AlgebraicMatrix derivAA(3,3);
  AlgebraicMatrix derivAB(3,3);
  AlgebraicMatrix derivBB(3,3);
  
  derivAA = derivativePosPos( rotDet, rotCompO );
  derivAB = derivativePosRot( rotDet, rotCompO, diffVec );
  derivBB = derivativeRotRot( rotDet, rotCompO );

  derivative[0][0] = derivAA[0][0];
  derivative[0][1] = derivAA[0][1];
  derivative[0][2] = derivAA[0][2];
  derivative[0][3] = derivAB[0][0];                                
  derivative[0][4] = derivAB[0][1];                               
  derivative[0][5] = derivAB[0][2];                             
  derivative[1][0] = derivAA[1][0];
  derivative[1][1] = derivAA[1][1];
  derivative[1][2] = derivAA[1][2];
  derivative[1][3] = derivAB[1][0];                                 
  derivative[1][4] = derivAB[1][1];                             
  derivative[1][5] = derivAB[1][2];                           
  derivative[2][0] = derivAA[2][0];
  derivative[2][1] = derivAA[2][1];
  derivative[2][2] = derivAA[2][2];
  derivative[2][3] = derivAB[2][0];            
  derivative[2][4] = derivAB[2][1];
  derivative[2][5] = derivAB[2][2];
  derivative[3][0] = 0;
  derivative[3][1] = 0;
  derivative[3][2] = 0;
  derivative[3][3] = derivBB[0][0];
  derivative[3][4] = derivBB[0][1];
  derivative[3][5] = derivBB[0][2];
  derivative[4][0] = 0;
  derivative[4][1] = 0;
  derivative[4][2] = 0;
  derivative[4][3] = derivBB[1][0];
  derivative[4][4] = derivBB[1][1];
  derivative[4][5] = derivBB[1][2];
  derivative[5][0] = 0;
  derivative[5][1] = 0;
  derivative[5][2] = 0;
  derivative[5][3] = derivBB[2][0];
  derivative[5][4] = derivBB[2][1];
  derivative[5][5] = derivBB[2][2];
  
  return(derivative.T());

}
AlgebraicMatrix66 FrameToFrameDerivative::getDerivative ( const align::RotationType objectRot,
const align::RotationType composeRot,
const align::GlobalPoint objectPos,
const align::GlobalPoint composePos 
) const

Calculates derivatives DeltaFrame(object)/DeltaFrame(composedobject) using their positions and orientations. As a new method it gets a new interface avoiding CLHEP that should anyway be replaced by SMatrix at some point...

Definition at line 28 of file FrameToFrameDerivative.cc.

Referenced by frameToFrameDerivative().

{
  return asSMatrix<6,6>(this->getDerivative(objectRot, composeRot, composePos - objectPos));
}
AlgebraicVector FrameToFrameDerivative::linearEulerAngles ( const AlgebraicMatrix rotDelta) const [private]

Gets linear approximated euler Angles.

Definition at line 194 of file FrameToFrameDerivative.cc.

References funct::C.

Referenced by derivativeRotRot().

{
  
  AlgebraicMatrix eulerAB(3,3);
  AlgebraicVector aB(3);
  eulerAB[0][1] =  1; 
  eulerAB[1][0] = -1; // New beta sign
  aB[2] = 1;

  AlgebraicMatrix eulerC(3,3);
  AlgebraicVector C(3);
  eulerC[2][0] = 1;
  C[1] = 1;

  AlgebraicVector eulerAngles(3);
  eulerAngles = eulerAB*rotDelta*aB + eulerC*rotDelta*C;
  return eulerAngles;

}
AlgebraicMatrix FrameToFrameDerivative::transform ( const align::RotationType rot) [inline, static, private]

Helper to transform from RotationType to AlgebraicMatrix.

Definition at line 61 of file FrameToFrameDerivative.h.

References dttmaxenums::R, TkRotation< T >::xx(), TkRotation< T >::xy(), TkRotation< T >::xz(), TkRotation< T >::yx(), TkRotation< T >::yy(), TkRotation< T >::yz(), TkRotation< T >::zx(), TkRotation< T >::zy(), and TkRotation< T >::zz().

Referenced by getDerivative().

{
  AlgebraicMatrix R(3, 3);

  R(1, 1) = rot.xx(); R(1, 2) = rot.xy(); R(1, 3) = rot.xz();
  R(2, 1) = rot.yx(); R(2, 2) = rot.yy(); R(2, 3) = rot.yz();
  R(3, 1) = rot.zx(); R(3, 2) = rot.zy(); R(3, 3) = rot.zz();

  return R;
}