![]() |
GeneralBrokenLines
V01-11-00
|
00001 /* 00002 * GblPoint.cpp 00003 * 00004 * Created on: Aug 18, 2011 00005 * Author: kleinwrt 00006 */ 00007 00008 #include "GblPoint.h" 00009 00011 00015 GblPoint::GblPoint(const TMatrixD &aJacobian) : 00016 theLabel(0), theOffset(0), measDim(0), transFlag(false), measTransformation(), scatFlag( 00017 false), localDerivatives(), globalLabels(), globalDerivatives() { 00018 // TODO Auto-generated constructor stub 00019 for (unsigned int i = 0; i < 5; i++) { 00020 for (unsigned int j = 0; j < 5; j++) { 00021 p2pJacobian(i, j) = aJacobian(i, j); 00022 } 00023 } 00024 } 00025 00026 GblPoint::~GblPoint() { 00027 // TODO Auto-generated destructor stub 00028 } 00029 00031 00038 void GblPoint::addMeasurement(const TMatrixD &aProjection, 00039 const TVectorD &aResiduals, const TVectorD &aPrecision) { 00040 measDim = aResiduals.GetNrows(); 00041 unsigned int iOff = 5 - measDim; 00042 for (unsigned int i = 0; i < measDim; i++) { 00043 measResiduals(iOff + i) = aResiduals[i]; 00044 measPrecision(iOff + i) = aPrecision[i]; 00045 for (unsigned int j = 0; j < measDim; j++) { 00046 measProjection(iOff + i, iOff + j) = aProjection(i, j); 00047 } 00048 } 00049 } 00050 00052 00059 void GblPoint::addMeasurement(const TVectorD &aResiduals, 00060 const TMatrixDSym &aPrecision) { 00061 measDim = aResiduals.GetNrows(); 00062 TMatrixDSymEigen measEigen(aPrecision); 00063 measTransformation = measEigen.GetEigenVectors(); 00064 measTransformation.T(); 00065 transFlag = true; 00066 TVectorD transResiduals = measTransformation * aResiduals; 00067 TVectorD transPrecision = measEigen.GetEigenValues(); 00068 unsigned int iOff = 5 - measDim; 00069 for (unsigned int i = 0; i < measDim; i++) { 00070 measResiduals(iOff + i) = transResiduals[i]; 00071 measPrecision(iOff + i) = transPrecision[i]; 00072 for (unsigned int j = 0; j < measDim; j++) { 00073 measProjection(iOff + i, iOff + j) = measTransformation(i, j); 00074 } 00075 } 00076 } 00077 00079 00083 unsigned int GblPoint::hasMeasurement() const{ 00084 return measDim; 00085 } 00086 00088 00093 void GblPoint::getMeasurement(SMatrix55 &aProjection, SVector5 &aResiduals, 00094 SVector5 &aPrecision) const{ 00095 aProjection = measProjection; 00096 aResiduals = measResiduals; 00097 aPrecision = measPrecision; 00098 } 00099 00101 00105 void GblPoint::addScatterer(const TVectorD &aResiduals, 00106 const TVectorD &aPrecision) { 00107 scatFlag = true; 00108 scatResiduals(0) = aResiduals[0]; 00109 scatResiduals(1) = aResiduals[1]; 00110 scatPrecision(0) = aPrecision[0]; 00111 scatPrecision(1) = aPrecision[1]; 00112 } 00113 00115 bool GblPoint::hasScatterer() const{ 00116 return scatFlag; 00117 } 00118 00120 00124 void GblPoint::getScatterer(SVector2 &aResiduals, SVector2 &aPrecision) const{ 00125 aResiduals = scatResiduals; 00126 aPrecision = scatPrecision; 00127 } 00128 00130 00134 void GblPoint::addLocals(const TMatrixD &aDerivatives) { 00135 if (measDim) { 00136 localDerivatives.ResizeTo(aDerivatives); 00137 if (transFlag) { 00138 localDerivatives = measTransformation * aDerivatives; 00139 } else { 00140 localDerivatives = aDerivatives; 00141 } 00142 } 00143 } 00144 00146 unsigned int GblPoint::getNumLocals() const{ 00147 return localDerivatives.GetNcols(); 00148 } 00149 00151 TMatrixD GblPoint::getLocalDerivatives() const{ 00152 return localDerivatives; 00153 } 00154 00156 00161 void GblPoint::addGlobals(const std::vector<int> &aLabels, 00162 const TMatrixD &aDerivatives) { 00163 if (measDim) { 00164 globalLabels = aLabels; 00165 globalDerivatives.ResizeTo(aDerivatives); 00166 if (transFlag) { 00167 globalDerivatives = measTransformation * aDerivatives; 00168 } else { 00169 globalDerivatives = aDerivatives; 00170 } 00171 00172 } 00173 } 00174 00176 unsigned int GblPoint::getNumGlobals() const{ 00177 return globalDerivatives.GetNcols(); 00178 } 00179 00181 std::vector<int> GblPoint::getGlobalLabels() const{ 00182 return globalLabels; 00183 } 00184 00186 TMatrixD GblPoint::getGlobalDerivatives() const{ 00187 return globalDerivatives; 00188 } 00189 00191 00194 void GblPoint::setLabel(unsigned int aLabel) { 00195 theLabel = aLabel; 00196 } 00197 00199 unsigned int GblPoint::getLabel() const{ 00200 return theLabel; 00201 } 00202 00204 00207 void GblPoint::setOffset(int anOffset) { 00208 theOffset = anOffset; 00209 } 00210 00212 int GblPoint::getOffset() const{ 00213 return theOffset; 00214 } 00215 00217 SMatrix55 GblPoint::getP2pJacobian() const{ 00218 return p2pJacobian; 00219 } 00220 00222 00225 void GblPoint::addPrevJacobian(const SMatrix55 aJac) { 00226 int ifail = 0; 00227 // to optimize: need only two last rows of inverse 00228 // prevJacobian = aJac.InverseFast(ifail); 00229 // block matrix algebra 00230 SMatrix23 CA = aJac.Sub<SMatrix23>(3, 0) 00231 * aJac.Sub<SMatrix33>(0, 0).InverseFast(ifail); // C*A^-1 00232 SMatrix22 DCAB = aJac.Sub<SMatrix22>(3, 3) - CA * aJac.Sub<SMatrix32>(0, 3); // D - C*A^-1 *B 00233 DCAB.InvertFast(); 00234 prevJacobian.Place_at(DCAB, 3, 3); 00235 prevJacobian.Place_at(-DCAB * CA, 3, 0); 00236 } 00237 00239 00242 void GblPoint::addNextJacobian(const SMatrix55 aJac) { 00243 nextJacobian = aJac; 00244 } 00245 00247 00255 void GblPoint::getDerivatives(int aDirection, SMatrix22 &matW, SMatrix22 &matWJ, 00256 SVector2 &vecWd) const{ 00257 00258 if (aDirection < 1) { 00259 matWJ = prevJacobian.Sub<SMatrix22>(3, 3); 00260 matW = -prevJacobian.Sub<SMatrix22>(3, 1); 00261 vecWd = prevJacobian.SubCol<SVector2>(0, 3); 00262 } else { 00263 matWJ = nextJacobian.Sub<SMatrix22>(3, 3); 00264 matW = nextJacobian.Sub<SMatrix22>(3, 1); 00265 vecWd = nextJacobian.SubCol<SVector2>(0, 3); 00266 } 00267 matW.InvertFast(); 00268 matWJ = matW * matWJ; 00269 vecWd = matW * vecWd; 00270 }
1.7.6.1