2 #ifndef LSST_JOINTCAL_GTRANSFO_H 3 #define LSST_JOINTCAL_GTRANSFO_H 12 #include "lsst/pex/exceptions.h" 15 namespace pexExcept = lsst::pex::exceptions;
42 virtual void apply(
const double xIn,
const double yIn,
double &xOut,
double &yOut)
const = 0;
52 return Point(xout, yout);
56 virtual void dump(std::ostream &stream = std::cout)
const = 0;
78 virtual std::unique_ptr<Gtransfo>
clone()
const = 0;
85 virtual double getJacobian(
const double x,
const double y)
const;
93 const double step = 0.01)
const;
106 virtual std::unique_ptr<Gtransfo>
inverseTransfo(
const double precision,
const Frame ®ion)
const;
115 virtual double paramRef(
const int i)
const;
118 virtual double &
paramRef(
const int i);
132 void write(
const std::string &fileName)
const;
134 virtual void write(std::ostream &stream)
const;
156 void apply(
const double xIn,
const double yIn,
double &xOut,
double &yOut)
const {
162 throw pexExcept::TypeError(
163 "GtransfoIdentity is the identity transformation: it cannot be fit to anything.");
167 void dump(std::ostream &stream = std::cout)
const { stream <<
"x' = x\ny' = y" << std::endl; }
177 void write(std::ostream &s)
const;
179 void read(std::istream &s);
200 std::vector<double> _coeffs;
212 void computeMonomials(
double xIn,
double yIn,
double *monomial)
const;
223 void setDegree(
const unsigned degree);
225 void apply(
const double xIn,
const double yIn,
double &xOut,
double &yOut)
const;
240 void dump(std::ostream &stream = std::cout)
const;
256 std::unique_ptr<Gtransfo>
clone()
const {
return std::unique_ptr<Gtransfo>(
new GtransfoPoly(*
this)); }
259 double coeff(
const unsigned powX,
const unsigned powY,
const unsigned whichCoord)
const;
262 double &coeff(
const unsigned powX,
const unsigned powY,
const unsigned whichCoord);
265 double coeffOrZero(
const unsigned powX,
const unsigned powY,
const unsigned whichCoord)
const;
267 double determinant()
const;
279 void write(std::ostream &s)
const;
280 void read(std::istream &s);
283 double computeFit(
const StarMatchList &starMatchList,
const Gtransfo &InTransfo,
const bool UseErrors);
322 GtransfoLin(
const double ox,
const double oy,
const double aa11,
const double aa12,
const double aa21,
328 std::unique_ptr<Gtransfo>
clone()
const {
return std::unique_ptr<Gtransfo>(
new GtransfoLin(*
this)); }
330 std::unique_ptr<Gtransfo>
inverseTransfo(
const double precision,
const Frame ®ion)
const;
332 double A11()
const {
return coeff(1, 0, 0); }
333 double A12()
const {
return coeff(0, 1, 0); }
334 double A21()
const {
return coeff(1, 0, 1); }
335 double A22()
const {
return coeff(0, 1, 1); }
336 double Dx()
const {
return coeff(0, 0, 0); }
337 double Dy()
const {
return coeff(0, 0, 1); }
340 double &
a11() {
return coeff(1, 0, 0); }
341 double &
a12() {
return coeff(0, 1, 0); }
342 double &
a21() {
return coeff(1, 0, 1); }
343 double &
a22() {
return coeff(0, 1, 1); }
344 double &
dx() {
return coeff(0, 0, 0); }
345 double &
dy() {
return coeff(0, 0, 1); }
352 void setDegree(
const unsigned degree);
376 GtransfoLinRot(
const double angleRad,
const Point *center =
nullptr,
const double scaleFactor = 1.0);
402 std::unique_ptr<GtransfoPoly>
corr;
416 void apply(
const double xIn,
const double yIn,
double &xOut,
double &yOut)
const;
419 Point getTangentPoint()
const;
428 void setCorrections(std::unique_ptr<GtransfoPoly> corrections);
431 Point getCrPix()
const;
437 virtual void pix2TP(
double xPixel,
double yPixel,
double &xTangentPlane,
double &yTangentPlane)
const = 0;
457 virtual void pix2TP(
double xPixel,
double yPixel,
double &xTangentPlane,
double &yTangentPlane)
const;
474 std::unique_ptr<Gtransfo>
inverseTransfo(
const double precision,
const Frame ®ion)
const;
476 std::unique_ptr<Gtransfo>
clone()
const;
478 void dump(std::ostream &stream)
const;
496 virtual void pix2TP(
double xPixel,
double yPixel,
double &xTangentPlane,
double &yTangentPlane)
const;
502 std::unique_ptr<Gtransfo>
inverseTransfo(
const double precision,
const Frame ®ion)
const;
504 std::unique_ptr<Gtransfo>
clone()
const;
506 void dump(std::ostream &stream)
const;
537 void setTangentPoint(
const Point &tangentPoint);
540 Point getTangentPoint()
const;
543 void apply(
const double xIn,
const double yIn,
double &xOut,
double &yOut)
const;
555 std::unique_ptr<Gtransfo>
inverseTransfo(
const double precision,
const Frame ®ion)
const;
557 void dump(std::ostream &stream)
const;
559 std::unique_ptr<Gtransfo>
clone()
const;
565 typedef void(
GtransfoFun)(
const double,
const double,
double &,
double &,
const void *);
571 const void *_userData;
579 void apply(
const double xIn,
const double yIn,
double &xOut,
double &yOut)
const;
581 void dump(std::ostream &stream = std::cout)
const;
585 std::unique_ptr<Gtransfo>
clone()
const;
589 std::unique_ptr<Gtransfo>
gtransfoRead(
const std::string &fileName);
591 std::unique_ptr<Gtransfo>
gtransfoRead(std::istream &s);
595 #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 offsetParams(Eigen::VectorXd const &delta)
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
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