42 auto rawCopy =
reinterpret_cast<AstMapping *
>(astCopy(
getRawPtr()));
44 assertOK(
reinterpret_cast<AstObject *
>(rawCopy));
46 return Object::fromAstObject<Mapping>(
reinterpret_cast<AstObject *
>(rawCopy),
false);
54 Array2D fit = ndarray::allocate(ndarray::makeVector(1 + nIn, nOut));
55 int isOK = astLinearApprox(
getRawPtr(), lbnd.
data(), ubnd.
data(), tol, fit.getData());
63template <
typename Class>
65 if ((i < 0) || (i > 1)) {
67 os <<
"i =" << i <<
"; must be 0 or 1";
75 int series, invert1, invert2;
76 astDecompose(
getRawPtr(), &rawMap1, &rawMap2, &series, &invert1, &invert2);
81 astAnnul(
reinterpret_cast<AstObject *
>(rawMap1));
83 os <<
"This " <<
getClassName() <<
" is not a compound object";
88 AstMapping *retRawMap;
91 retRawMap =
reinterpret_cast<AstMapping *
>(astCopy(
reinterpret_cast<AstObject *
>(rawMap1)));
94 retRawMap =
reinterpret_cast<AstMapping *
>(astCopy(
reinterpret_cast<AstObject *
>(rawMap2)));
97 astAnnul(
reinterpret_cast<AstObject *
>(rawMap1));
98 astAnnul(
reinterpret_cast<AstObject *
>(rawMap2));
104 if (invert != astGetI(retRawMap,
"Invert")) {
105 astInvert(retRawMap);
109 return Object::fromAstObject<Class>(
reinterpret_cast<AstObject *
>(retRawMap),
copy);
119 int const nPts = from.getSize<1>();
122 astTranN(
getRawPtr(), nPts, nFromAxes, nPts, from.getData(),
static_cast<int>(doForward), nToAxes, nPts,
129void Mapping::_tranGrid(
PointI const &lbnd,
PointI const &ubnd,
double tol,
int maxpix,
bool doForward,
136 int const nPts = to.getSize<0>();
137 astTranGrid(
getRawPtr(), nFromAxes, lbnd.data(), ubnd.data(), tol, maxpix,
static_cast<int>(doForward),
138 nToAxes, nPts, to.getData());
An abstract base class for objects which transform one set of coordinates to another.
std::shared_ptr< Mapping > copy() const
Return a deep copy of this object.
SeriesMap then(Mapping const &next) const
Return a series compound mapping this(first(input)) containing shallow copies of the original.
std::shared_ptr< Class > decompose(int i, bool copy) const
Return a deep copy of one of the two component mappings.
ParallelMap under(Mapping const &next) const
Return a parallel compound mapping containing shallow copies of the original.
Array2D linearApprox(PointD const &lbnd, PointD const &ubnd, double tol) const
Compute a linear approximation to the forward transformation.
int getNOut() const
Get NOut: the number of output axes.
int getNIn() const
Get NIn: the number of input axes.
std::shared_ptr< Mapping > inverted() const
Get an inverse mapping.
std::string getClassName() const
Get Class: the name of the class (e.g.
AstObject const * getRawPtr() const
Get the raw AST pointer.
A parallel compound mapping where the first Mapping is used to transform the lower numbered coordinat...
A series compound mapping where the first Mapping is used to transform the coordinates of each point ...
void assertEqual(T1 val1, std::string const &descr1, T2 val2, std::string const &descr2)
void astBadToNan(std::vector< double > &p)
Replace AST__BAD with a quiet NaN in a vector.
AST wrapper classes and functions.
ndarray::Array< const double, 2, 2 > ConstArray2D
2D array of const double; typically used for lists of const points
std::vector< int > PointI
Vector of ints; typically used for the bounds of Mapping.tranGridForward and inverse.
ndarray::Array< double, 2, 2 > Array2D
2D array of const double; typically used for lists of const points
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST's state is bad.