36 #include "ndarray/eigen.h"
79 template <
typename Derived>
81 Eigen::MatrixBase<Derived>
const &matrix) {
83 ndarray::allocate(ndarray::makeVector(matrix.rows(), matrix.cols()));
84 ndarray::asEigenMatrix(array) = matrix;
99 return coeffs.size() > 1 && coeffs[0] == 0.0 && coeffs[1] != 0.0;
119 int const nCoeffs = coeffs.
size() - 1;
120 ndarray::Array<double, 2, 2>
const polyCoeffs = ndarray::allocate(ndarray::makeVector(nCoeffs, 3));
121 for (
size_t i = 1; i < coeffs.
size(); ++i) {
122 polyCoeffs[i - 1][0] = coeffs[i];
123 polyCoeffs[i - 1][1] = 1;
124 polyCoeffs[i - 1][2] = i;
127 return ast::PolyMap(polyCoeffs, 1,
"IterInverse=1, TolInverse=1e-8, NIterInverse=30");
135 Eigen::Matrix2d jacobian = original.
getJacobian(inPoint);
136 for (
int i = 0; i < 2; ++i) {
139 buffer <<
"Transform ill-defined: " << inPoint <<
" -> " << outPoint;
143 if (!jacobian.allFinite()) {
145 buffer <<
"Transform not continuous at " << inPoint <<
": J = " << jacobian;
150 auto offset = outPoint.asEigen() - jacobian * inPoint.
asEigen();
162 return std::make_shared<TransformPoint2ToPoint2>(*map);
166 if (!areRadialCoefficients(coeffs)) {
168 buffer <<
"Invalid coefficient vector: " << coeffs;
172 if (coeffs.
empty()) {
173 return std::make_shared<TransformPoint2ToPoint2>(
ast::UnitMap(2));
178 ast::PolyMap const distortion = makeOneDDistortion(coeffs);
185 if (forwardCoeffs.
empty() != inverseCoeffs.
empty()) {
188 "makeRadialTransform must have either both empty or both non-empty coefficient vectors.");
190 if (forwardCoeffs.
empty()) {
192 return std::make_shared<TransformPoint2ToPoint2>(
ast::UnitMap(2));
195 if (!areRadialCoefficients(forwardCoeffs)) {
197 buffer <<
"Invalid forward coefficient vector: " << forwardCoeffs;
200 if (!areRadialCoefficients(inverseCoeffs)) {
202 buffer <<
"Invalid inverse coefficient vector: " << inverseCoeffs;
208 ast::PolyMap const forward = makeOneDDistortion(forwardCoeffs);
209 auto inverse = makeOneDDistortion(inverseCoeffs).inverted();
215 return std::make_shared<TransformPoint2ToPoint2>(
ast::UnitMap(2));
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
SeriesMap then(Mapping const &next) const
Return a series compound mapping this(first(input)) containing shallow copies of the original.
std::shared_ptr< Mapping > simplified() const
Return a simplied version of the mapping (which may be a compound Mapping such as a CmpMap).
MatrixMap is a form of Mapping which performs a general linear transformation.
PolyMap is a Mapping which performs a general polynomial transformation.
ShiftMap is a linear Mapping which shifts each axis by a specified constant value.
TranMap is a Mapping which combines the forward transformation of a supplied Mapping with the inverse...
A UnitMap is a unit (null) Mapping that has no effect on the coordinates supplied to it.
An endpoint for lsst::geom::Point2D.
EigenVector const & asEigen() const noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
Return a fixed-size Eigen representation of the coordinate object.
Reports invalid arguments.
std::shared_ptr< Mapping > makeRadialMapping(std::vector< double > const ¢er, Mapping const &mapping1d)
Construct a radially symmetric mapping from a 1-dimensional mapping.
std::shared_ptr< TransformPoint2ToPoint2 > makeTransform(lsst::geom::AffineTransform const &affine)
Wrap an lsst::geom::AffineTransform as a Transform.
std::shared_ptr< TransformPoint2ToPoint2 > makeRadialTransform(std::vector< double > const &coeffs)
A purely radial polynomial distortion.
std::ostream & operator<<(std::ostream &os, GenericEndpoint const &endpoint)
Print "GenericEndpoint(_n_)" to the ostream where _n_ is the number of axes, e.g. "GenericAxes(4)".
std::shared_ptr< TransformPoint2ToPoint2 > makeIdentityTransform()
Trivial Transform x → x.
lsst::geom::AffineTransform linearizeTransform(TransformPoint2ToPoint2 const &original, lsst::geom::Point2D const &inPoint)
Approximate a Transform by its local linearization.
Point< double, 2 > Point2D
double Scalar
Typedefs to be used for probability and parameter values.
A base class for image defects.