Go to the documentation of this file.00001
00007 #include "Alignment/CommonAlignmentParametrization/interface/FrameToFrameDerivative.h"
00008
00009 #include "Alignment/CommonAlignment/interface/Alignable.h"
00010
00011
00012 #include "DataFormats/CLHEP/interface/Migration.h"
00013
00014
00015 AlgebraicMatrix
00016 FrameToFrameDerivative::frameToFrameDerivative(const Alignable* object,
00017 const Alignable* composedObject) const
00018 {
00019
00020 return getDerivative( object->globalRotation(),
00021 composedObject->globalRotation(),
00022 composedObject->globalPosition() - object->globalPosition() );
00023
00024 }
00025
00026
00027 AlgebraicMatrix66
00028 FrameToFrameDerivative::getDerivative(const align::RotationType &objectRot,
00029 const align::RotationType &composeRot,
00030 const align::GlobalPoint &objectPos,
00031 const align::GlobalPoint &composePos) const
00032 {
00033 return asSMatrix<6,6>(this->getDerivative(objectRot, composeRot, composePos - objectPos));
00034 }
00035
00036
00037 AlgebraicMatrix
00038 FrameToFrameDerivative::getDerivative(const align::RotationType &objectRot,
00039 const align::RotationType &composeRot,
00040 const align::GlobalVector &posVec) const
00041 {
00042
00043 AlgebraicMatrix rotDet = transform(objectRot);
00044 AlgebraicMatrix rotCompO = transform(composeRot);
00045
00046 AlgebraicVector diffVec(3);
00047
00048 diffVec(1) = posVec.x();
00049 diffVec(2) = posVec.y();
00050 diffVec(3) = posVec.z();
00051
00052 AlgebraicMatrix derivative(6,6);
00053
00054 AlgebraicMatrix derivAA(3,3);
00055 AlgebraicMatrix derivAB(3,3);
00056 AlgebraicMatrix derivBB(3,3);
00057
00058 derivAA = derivativePosPos( rotDet, rotCompO );
00059 derivAB = derivativePosRot( rotDet, rotCompO, diffVec );
00060 derivBB = derivativeRotRot( rotDet, rotCompO );
00061
00062 derivative[0][0] = derivAA[0][0];
00063 derivative[0][1] = derivAA[0][1];
00064 derivative[0][2] = derivAA[0][2];
00065 derivative[0][3] = derivAB[0][0];
00066 derivative[0][4] = derivAB[0][1];
00067 derivative[0][5] = derivAB[0][2];
00068 derivative[1][0] = derivAA[1][0];
00069 derivative[1][1] = derivAA[1][1];
00070 derivative[1][2] = derivAA[1][2];
00071 derivative[1][3] = derivAB[1][0];
00072 derivative[1][4] = derivAB[1][1];
00073 derivative[1][5] = derivAB[1][2];
00074 derivative[2][0] = derivAA[2][0];
00075 derivative[2][1] = derivAA[2][1];
00076 derivative[2][2] = derivAA[2][2];
00077 derivative[2][3] = derivAB[2][0];
00078 derivative[2][4] = derivAB[2][1];
00079 derivative[2][5] = derivAB[2][2];
00080 derivative[3][0] = 0;
00081 derivative[3][1] = 0;
00082 derivative[3][2] = 0;
00083 derivative[3][3] = derivBB[0][0];
00084 derivative[3][4] = derivBB[0][1];
00085 derivative[3][5] = derivBB[0][2];
00086 derivative[4][0] = 0;
00087 derivative[4][1] = 0;
00088 derivative[4][2] = 0;
00089 derivative[4][3] = derivBB[1][0];
00090 derivative[4][4] = derivBB[1][1];
00091 derivative[4][5] = derivBB[1][2];
00092 derivative[5][0] = 0;
00093 derivative[5][1] = 0;
00094 derivative[5][2] = 0;
00095 derivative[5][3] = derivBB[2][0];
00096 derivative[5][4] = derivBB[2][1];
00097 derivative[5][5] = derivBB[2][2];
00098
00099 return(derivative.T());
00100
00101 }
00102
00103
00104
00105 AlgebraicMatrix
00106 FrameToFrameDerivative::derivativePosPos(const AlgebraicMatrix &RotDet,
00107 const AlgebraicMatrix &RotRot) const
00108 {
00109
00110 return RotDet * RotRot.T();
00111
00112 }
00113
00114
00115
00116 AlgebraicMatrix
00117 FrameToFrameDerivative::derivativePosRot(const AlgebraicMatrix &RotDet,
00118 const AlgebraicMatrix &RotRot,
00119 const AlgebraicVector &S) const
00120 {
00121
00122 AlgebraicVector dEulerA(3);
00123 AlgebraicVector dEulerB(3);
00124 AlgebraicVector dEulerC(3);
00125 AlgebraicMatrix RotDa(3,3);
00126 AlgebraicMatrix RotDb(3,3);
00127 AlgebraicMatrix RotDc(3,3);
00128
00129 RotDa[1][2] = 1; RotDa[2][1] = -1;
00130 RotDb[0][2] = -1; RotDb[2][0] = 1;
00131 RotDc[0][1] = 1; RotDc[1][0] = -1;
00132
00133 dEulerA = RotDet*( RotRot.T()*RotDa*RotRot*S );
00134 dEulerB = RotDet*( RotRot.T()*RotDb*RotRot*S );
00135 dEulerC = RotDet*( RotRot.T()*RotDc*RotRot*S );
00136
00137 AlgebraicMatrix eulerDeriv(3,3);
00138 eulerDeriv[0][0] = dEulerA[0];
00139 eulerDeriv[1][0] = dEulerA[1];
00140 eulerDeriv[2][0] = dEulerA[2];
00141 eulerDeriv[0][1] = dEulerB[0];
00142 eulerDeriv[1][1] = dEulerB[1];
00143 eulerDeriv[2][1] = dEulerB[2];
00144 eulerDeriv[0][2] = dEulerC[0];
00145 eulerDeriv[1][2] = dEulerC[1];
00146 eulerDeriv[2][2] = dEulerC[2];
00147
00148 return eulerDeriv;
00149
00150 }
00151
00152
00153
00154 AlgebraicMatrix
00155 FrameToFrameDerivative::derivativeRotRot(const AlgebraicMatrix &RotDet,
00156 const AlgebraicMatrix &RotRot) const
00157 {
00158
00159 AlgebraicVector dEulerA(3);
00160 AlgebraicVector dEulerB(3);
00161 AlgebraicVector dEulerC(3);
00162 AlgebraicMatrix RotDa(3,3);
00163 AlgebraicMatrix RotDb(3,3);
00164 AlgebraicMatrix RotDc(3,3);
00165
00166 RotDa[1][2] = 1; RotDa[2][1] = -1;
00167 RotDb[0][2] = -1; RotDb[2][0] = 1;
00168 RotDc[0][1] = 1; RotDc[1][0] = -1;
00169
00170 dEulerA = linearEulerAngles( RotDet*RotRot.T()*RotDa*RotRot*RotDet.T() );
00171 dEulerB = linearEulerAngles( RotDet*RotRot.T()*RotDb*RotRot*RotDet.T() );
00172 dEulerC = linearEulerAngles( RotDet*RotRot.T()*RotDc*RotRot*RotDet.T() );
00173
00174 AlgebraicMatrix eulerDeriv(3,3);
00175
00176 eulerDeriv[0][0] = dEulerA[0];
00177 eulerDeriv[1][0] = dEulerA[1];
00178 eulerDeriv[2][0] = dEulerA[2];
00179 eulerDeriv[0][1] = dEulerB[0];
00180 eulerDeriv[1][1] = dEulerB[1];
00181 eulerDeriv[2][1] = dEulerB[2];
00182 eulerDeriv[0][2] = dEulerC[0];
00183 eulerDeriv[1][2] = dEulerC[1];
00184 eulerDeriv[2][2] = dEulerC[2];
00185
00186 return eulerDeriv;
00187
00188 }
00189
00190
00191
00192
00193 AlgebraicVector
00194 FrameToFrameDerivative::linearEulerAngles(const AlgebraicMatrix &rotDelta ) const
00195 {
00196
00197 AlgebraicMatrix eulerAB(3,3);
00198 AlgebraicVector aB(3);
00199 eulerAB[0][1] = 1;
00200 eulerAB[1][0] = -1;
00201 aB[2] = 1;
00202
00203 AlgebraicMatrix eulerC(3,3);
00204 AlgebraicVector C(3);
00205 eulerC[2][0] = 1;
00206 C[1] = 1;
00207
00208 AlgebraicVector eulerAngles(3);
00209 eulerAngles = eulerAB*rotDelta*aB + eulerC*rotDelta*C;
00210 return eulerAngles;
00211
00212 }
00213