2 #ifndef LSST_JOINTCAL_GTRANSFO_H 3 #define LSST_JOINTCAL_GTRANSFO_H 10 #include "lsst/pex/exceptions.h" 13 namespace pexExcept = lsst::pex::exceptions;
40 virtual void apply(
const double xIn,
const double yIn,
double &xOut,
double &yOut)
const = 0;
50 return Point(xout, yout);
54 virtual void dump(std::ostream &stream = std::cout)
const = 0;
76 virtual std::unique_ptr<Gtransfo>
clone()
const = 0;
83 virtual double getJacobian(
const double x,
const double y)
const;
91 const double step = 0.01)
const;
104 virtual std::unique_ptr<Gtransfo>
inverseTransfo(
const double precision,
const Frame ®ion)
const;
113 virtual double paramRef(
const int i)
const;
116 virtual double &
paramRef(
const int i);
130 void write(
const std::string &fileName)
const;
132 virtual void write(std::ostream &stream)
const;
154 void apply(
const double xIn,
const double yIn,
double &xOut,
double &yOut)
const {
160 throw pexExcept::TypeError(
161 "GtransfoIdentity is the identity transformation: it cannot be fit to anything.");
165 void dump(std::ostream &stream = std::cout)
const { stream <<
"x' = x\ny' = y" << std::endl; }
175 void write(std::ostream &s)
const;
177 void read(std::istream &s);
198 std::vector<double> _coeffs;
210 void computeMonomials(
double xIn,
double yIn,
double *monomial)
const;
221 void setDegree(
const unsigned degree);
223 void apply(
const double xIn,
const double yIn,
double &xOut,
double &yOut)
const;
238 void dump(std::ostream &stream = std::cout)
const;
254 std::unique_ptr<Gtransfo>
clone()
const {
return std::unique_ptr<Gtransfo>(
new GtransfoPoly(*
this)); }
257 double coeff(
const unsigned powX,
const unsigned powY,
const unsigned whichCoord)
const;
260 double &coeff(
const unsigned powX,
const unsigned powY,
const unsigned whichCoord);
263 double coeffOrZero(
const unsigned powX,
const unsigned powY,
const unsigned whichCoord)
const;
265 double determinant()
const;
277 void write(std::ostream &s)
const;
278 void read(std::istream &s);
281 double computeFit(
const StarMatchList &starMatchList,
const Gtransfo &InTransfo,
const bool UseErrors);
320 GtransfoLin(
const double ox,
const double oy,
const double aa11,
const double aa12,
const double aa21,
326 std::unique_ptr<Gtransfo>
clone()
const {
return std::unique_ptr<Gtransfo>(
new GtransfoLin(*
this)); }
328 std::unique_ptr<Gtransfo>
inverseTransfo(
const double precision,
const Frame ®ion)
const;
330 double A11()
const {
return coeff(1, 0, 0); }
331 double A12()
const {
return coeff(0, 1, 0); }
332 double A21()
const {
return coeff(1, 0, 1); }
333 double A22()
const {
return coeff(0, 1, 1); }
334 double Dx()
const {
return coeff(0, 0, 0); }
335 double Dy()
const {
return coeff(0, 0, 1); }
338 double &
a11() {
return coeff(1, 0, 0); }
339 double &
a12() {
return coeff(0, 1, 0); }
340 double &
a21() {
return coeff(1, 0, 1); }
341 double &
a22() {
return coeff(0, 1, 1); }
342 double &
dx() {
return coeff(0, 0, 0); }
343 double &
dy() {
return coeff(0, 0, 1); }
350 void setDegree(
const unsigned degree);
374 GtransfoLinRot(
const double angleRad,
const Point *center =
nullptr,
const double scaleFactor = 1.0);
400 std::unique_ptr<GtransfoPoly>
corr;
414 void apply(
const double xIn,
const double yIn,
double &xOut,
double &yOut)
const;
417 Point getTangentPoint()
const;
426 void setCorrections(std::unique_ptr<GtransfoPoly> corrections);
429 Point getCrPix()
const;
435 virtual void pix2TP(
double xPixel,
double yPixel,
double &xTangentPlane,
double &yTangentPlane)
const = 0;
455 virtual void pix2TP(
double xPixel,
double yPixel,
double &xTangentPlane,
double &yTangentPlane)
const;
472 std::unique_ptr<Gtransfo>
inverseTransfo(
const double precision,
const Frame ®ion)
const;
474 std::unique_ptr<Gtransfo>
clone()
const;
476 void dump(std::ostream &stream)
const;
494 virtual void pix2TP(
double xPixel,
double yPixel,
double &xTangentPlane,
double &yTangentPlane)
const;
500 std::unique_ptr<Gtransfo>
inverseTransfo(
const double precision,
const Frame ®ion)
const;
502 std::unique_ptr<Gtransfo>
clone()
const;
504 void dump(std::ostream &stream)
const;
535 void setTangentPoint(
const Point &tangentPoint);
538 Point getTangentPoint()
const;
541 void apply(
const double xIn,
const double yIn,
double &xOut,
double &yOut)
const;
553 std::unique_ptr<Gtransfo>
inverseTransfo(
const double precision,
const Frame ®ion)
const;
555 void dump(std::ostream &stream)
const;
557 std::unique_ptr<Gtransfo>
clone()
const;
563 typedef void(
GtransfoFun)(
const double,
const double,
double &,
double &,
const void *);
569 const void *_userData;
577 void apply(
const double xIn,
const double yIn,
double &xOut,
double &yOut)
const;
579 void dump(std::ostream &stream = std::cout)
const;
583 std::unique_ptr<Gtransfo>
clone()
const;
587 std::unique_ptr<Gtransfo>
gtransfoRead(
const std::string &fileName);
589 std::unique_ptr<Gtransfo>
gtransfoRead(std::istream &s);
593 #endif // LSST_JOINTCAL_GTRANSFO_H virtual std::unique_ptr< Gtransfo > roughInverse(const Frame ®ion) const
Rough inverse.
Implements the (forward) SIP distorsion scheme.
implements the linear transformations (6 real coefficients).
void getParams(double *params) const
params should be at least Npar() long
std::unique_ptr< Gtransfo > gtransfoCompose(const Gtransfo *left, const Gtransfo *right)
Returns a pointer to a composition.
void apply(const double xIn, const double yIn, double &xOut, double &yOut) const
void transformStar(FatPoint &in) const
allows to write MyTransfo(MyStar)
GtransfoLin(const GtransfoIdentity &)
Handy converter:
void() GtransfoFun(const double, const double, double &, double &, const void *)
signature of the user-provided routine that actually does the coordinate transfo for UserTransfo...
the transformation that handles pix to sideral transfos (Gnomonic, possibly with polynomial distortio...
GtransfoLinShift(double ox=0., double oy=0.)
Add ox and oy.
virtual int getNpar() const
returns the number of parameters (to compute chi2's)
std::unique_ptr< Gtransfo > clone() const
returns a copy (allocated by new) of the transformation.
void apply(const double xIn, const double yIn, double &xOut, double &yOut) const
xOut = xIn; yOut = yIn !
GtransfoLinScale(const double scale=1)
GtransfoLinShift(const Point &point)
bool isIdentity(const Gtransfo *gtransfo)
Shorthand test to tell if a transfo belongs to the GtransfoIdentity class.
virtual double fit(const StarMatchList &starMatchList)=0
fits a transfo to a std::list of Point pairs (p1,p2, the Point fields in StarMatch).
void write(const std::string &fileName) const
std::ostream & operator<<(std::ostream &stream, const Gtransfo >ransfo)
allows 'stream << Transfo;' (by calling gtransfo.dump(stream)).
Polynomial transformation class.
GtransfoLin normalizeCoordinatesTransfo(const Frame &frame)
Returns the transformation that maps the input frame along both axes to [-1,1].
A Point with uncertainties.
int getNpar() const
returns the number of parameters (to compute chi2's)
virtual void paramDerivatives(const Point &where, double *dx, double *dy) const
Derivative w.r.t parameters.
GtransfoLin()
the default constructor constructs the do-nothing transformation.
bool isIntegerShift(const Gtransfo *gtransfo)
Shorthand test to tell if a transfo is a simple integer shift.
std::unique_ptr< GtransfoPoly > inversePolyTransfo(const Gtransfo &Direct, const Frame &frame, const double Prec)
approximates the inverse by a polynomial, up to required precision.
virtual void transformErrors(const Point &where, const double *vIn, double *vOut) const
transform errors (represented as double[3] in order V(xx),V(yy),Cov(xy))
std::unique_ptr< Gtransfo > clone() const
returns a copy (allocated by new) of the transformation.
just here to provide a specialized constructor, and fit.
GtransfoLinScale(const double scaleX, const double scaleY)
virtual void computeDerivative(const Point &where, GtransfoLin &derivative, const double step=0.01) const
Computes the local Derivative of a transfo, w.r.t.
rectangle with sides parallel to axes.
Class for a simple mapping implementing a generic Gtransfo.
virtual double getJacobian(const Point &point) const
returns the local jacobian.
int getNpar() const
total number of parameters
GtransfoIdentity()
constructor.
std::unique_ptr< Gtransfo > reduceCompo(const Gtransfo *right) const
to be overloaded by derived classes if they can really "reduce" the composition (e.g.
virtual double paramRef(const int i) const
virtual void transformPosAndErrors(const FatPoint &in, FatPoint &out) const
void offsetParams(const double *params)
const GtransfoPoly * getCorr() const
the "correction" (non-owning pointer)
unsigned getDegree() const
returns degree
Point apply(const Point &in) const
All these apply(..) shadow the virtual one in derived classes, unless one writes "using Gtransfo::app...
A do-nothing transformation. It anyway has dummy routines to mimick a Gtransfo.
void dump(std::ostream &stream=std::cout) const
dumps the transfo coefficients to stream.
virtual GtransfoLin linearApproximation(const Point &where, const double step=0.01) const
linear (local) approximation.
just here to provide a specialized constructor, and fit.
virtual std::unique_ptr< Gtransfo > reduceCompo(const Gtransfo *right) const
to be overloaded by derived classes if they can really "reduce" the composition (e.g.
void apply(const Point &in, Point &out) const
applies the tranfo to in and writes into out. Is indeed virtual.
This one is the Tangent Plane (called gnomonic) projection (from celestial sphere to tangent plane) ...
double fit(const StarMatchList &starMatchList)
fits a transfo to a std::list of Point pairs (p1,p2, the Point fields in StarMatch).
std::unique_ptr< Gtransfo > clone() const
returns a copy (allocated by new) of the transformation.
just here to provide specialized constructors. GtransfoLin fit routine.
a virtual (interface) class for geometric transformations.
std::unique_ptr< GtransfoPoly > corr
a run-time transfo that allows users to define a Gtransfo with minimal coding (just the transfo routi...
std::unique_ptr< Gtransfo > gtransfoRead(const std::string &fileName)
The virtual constructor from a file.
virtual std::unique_ptr< Gtransfo > clone() const =0
returns a copy (allocated by new) of the transformation.
virtual void dump(std::ostream &stream=std::cout) const =0
dumps the transfo coefficients to stream.
int getNpar() const
total number of parameters
int getNpar() const
total number of parameters
virtual std::unique_ptr< Gtransfo > inverseTransfo(const double precision, const Frame ®ion) const
returns an inverse transfo. Numerical if not overloaded.
virtual void apply(const double xIn, const double yIn, double &xOut, double &yOut) const =0
int getNpar() const
total number of parameters