1 #ifndef SIMPLEPOLYMAPPING__H
2 #define SIMPLEPOLYMAPPING__H
21 CountedRef<Gtransfo> transfo;
24 std::auto_ptr<GtransfoLin> lin;
27 static_assert(std::is_base_of<Gtransfo, Tr>::value,
29 "SimpleGtransfoMapping requires a class deriving from Gtransfo");
38 lin.reset(
new GtransfoLin);
46 if (toFit)
return transfo->Npar();
53 if (Indices.size() <
Npar()) Indices.resize(
Npar());
54 for (
unsigned k=0; k<
Npar(); ++k) Indices[k] = index+k;
59 FatPoint &OutPos)
const
61 transfo->TransformPosAndErrors(Where,OutPos);
65 void PosDerivative(Point &Where, Eigen::Matrix2d &Der,
const double & Eps)
const
67 transfo->Derivative(Where, *lin, Eps);
68 Der(0,0) = lin->Coeff(1,0,0);
75 Der(1,0) = lin->Coeff(0,1,0);
76 Der(0,1) = lin->Coeff(1,0,1);
77 Der(1,1) = lin->Coeff(0,1,1);
81 void OffsetParams(
const double *Delta)
83 transfo->OffsetParams(Delta);
87 unsigned Index()
const {
return index;}
90 void SetIndex(
unsigned I) {index=I;}
94 Eigen::MatrixX2d &H)
const
97 transfo->ParamDerivatives(Where, &H(0,0), &H(0,1));
101 const Gtransfo&
Transfo()
const {
return *transfo;}
115 SimplePolyMapping(
const Point& Center,
const GtransfoPoly& P):
121 GtransfoLinShift shift(center.x, center.y);
122 transfo =
new GtransfoPoly(P*shift);
125 assert((&H(1,0) - &H(0,0)) == 1);
134 Eigen::MatrixX2d &H)
const
137 transfo->ParamDerivatives(Where-center, &H(0,0), &H(0,1));
142 FatPoint &OutPos)
const
144 FatPoint where = Where;
147 transfo->TransformPosAndErrors(where,OutPos);
166 Eigen::MatrixX2d &H)
const
virtual class needed in the abstraction of the distortion model
Definition: mapping.h:13
void PosDerivative(Point &Where, Eigen::Matrix2d &Der, const double &Eps) const
The derivative w.r.t. position.
Definition: simplepolymapping.h:65
virtual void ComputeTransformAndDerivatives(const FatPoint &Where, FatPoint &OutPos, Eigen::MatrixX2d &H) const
Actually applies the mapping and evaluates the derivatives w.r.t the fitted parameters.
Definition: simplepolymapping.h:92
unsigned Index() const
position of the parameters within the grand fitting scheme
Definition: simplepolymapping.h:87
Class for a simple mapping implementing a generic Gtransfo.
Definition: simplepolymapping.h:14
void TransformPosAndErrors(const FatPoint &Where, FatPoint &OutPos) const
The same as above but without the parameter derivatives (used to evaluate chi^2)
Definition: simplepolymapping.h:58
void GetMappingIndices(std::vector< unsigned > &Indices) const
Provides for this parameter set (of length Npar()) how they map into the "grand" fit.
Definition: simplepolymapping.h:51
const Gtransfo & Transfo() const
Access to the (fitted) transfo.
Definition: simplepolymapping.h:101
unsigned Npar() const
Mumber of parameters in total.
Definition: simplepolymapping.h:44