28 #include <boost/format.hpp> 40 RegistryMap& getRegistry() {
41 static RegistryMap instance;
46 RegistryMap::iterator i = getRegistry().find(name);
47 if (i == getRegistry().
end()) {
49 (
boost::format(
"Ellipse core with name '%s' not found in registry.") % name).str());
51 return i->second->clone();
64 result->setParameterVector(parameters);
93 getRegistry()[example->getName()] = example;
125 double ixx, iyy, ixy;
157 if (&other !=
this) {
172 return Jacobian::Identity();
178 double ixx, iyy, ixy;
186 double xx_p_yy = ixx + iyy;
187 double xx_m_yy = ixx - iyy;
188 double t =
std::sqrt(xx_m_yy * xx_m_yy + 4 * ixy * ixy);
195 double&
b,
double& theta) {
196 double xx_p_yy = ixx + iyy;
197 double xx_m_yy = ixx - iyy;
198 double t2 = xx_m_yy * xx_m_yy + 4.0 * ixy * ixy;
199 Eigen::Vector3d dt2(2.0 * xx_m_yy, -2.0 * xx_m_yy, 8.0 * ixy);
205 m(0, 0) = 0.25 * (1.0 + 0.5 * dt2[0] / t) / a;
206 m(0, 1) = 0.25 * (1.0 + 0.5 * dt2[1] / t) / a;
207 m(0, 2) = 0.25 * (0.5 * dt2[2] / t) / a;
208 m(1, 0) = 0.25 * (1.0 - 0.5 * dt2[0] / t) / b;
209 m(1, 1) = 0.25 * (1.0 - 0.5 * dt2[1] / t) / b;
210 m(1, 2) = 0.25 * (-0.5 * dt2[2] / t) / b;
212 m.row(2).setConstant(1.0 / (t * t));
225 ixy = (a -
b) * c * s;
233 double& iyy,
double& ixy) {
235 m.col(0).setConstant(2 * a);
236 m.col(1).setConstant(2 * b);
239 m.col(2).setConstant(a - b);
243 ixy = (a -
b) * c * s;
250 m(0, 2) *= -2.0 * cs;
An ellipse core with quadrupole moments as parameters.
static Jacobian _dAssignQuadrupoleToAxes(double ixx, double iyy, double ixy, double &a, double &b, double &theta)
Jacobian dAssign(BaseCore const &other)
Assign other to this and return the derivative of the conversion, d(this)/d(other).
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
static Jacobian _dAssignAxesToQuadrupole(double a, double b, double theta, double &ixx, double &iyy, double &ixy)
virtual Jacobian _dAssignToQuadrupole(double &ixx, double &iyy, double &ixy) const =0
static void _assignQuadrupoleToAxes(double ixx, double iyy, double ixy, double &a, double &b, double &theta)
ItemVariant const * other
lsst::geom::Extent2D computeDimensions() const
Return the size of the bounding box for the ellipse core.
double getTraceRadius() const
Return the radius defined as the square root of one half the trace of the quadrupole matrix...
static std::shared_ptr< BaseCore > make(std::string const &name)
afw::table::PointKey< int > dimensions
void setParameterVector(ParameterVector const &vector)
Set the core parameters from a vector.
ParameterVector const getParameterVector() const
Return the core parameters as a vector.
BaseCore & operator=(BaseCore const &other)
Set the parameters of this ellipse core from another.
A base class for image defects.
void grow(double buffer)
Increase the major and minor radii of the ellipse core by the given buffer.
Eigen::Vector3d ParameterVector
Parameter vector type.
virtual void _assignFromAxes(double a, double b, double theta)=0
void scale(double factor)
Scale the size of the ellipse core by the given factor.
static void _assignAxesToQuadrupole(double a, double b, double theta, double &ixx, double &iyy, double &ixy)
double getArea() const
Return the area of the ellipse core.
virtual void _assignToAxes(double &a, double &b, double &theta) const =0
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Eigen::Matrix3d Jacobian
Parameter Jacobian matrix type.
A base class for parametrizations of the "core" of an ellipse - the ellipticity and size...
virtual void readParameters(double const *iter)=0
Reports invalid arguments.
virtual std::string getName() const =0
Return a string that identifies this parametrization.
void apply(BaseCore &result) const
virtual Jacobian _dAssignFromQuadrupole(double ixx, double iyy, double ixy)=0
double getDeterminantRadius() const
Return the radius defined as the 4th root of the determinant of the quadrupole matrix.
static void registerSubclass(std::shared_ptr< BaseCore > const &example)
bool operator==(BaseCore const &other) const
Compare two ellipse cores for equality.
virtual void _assignToQuadrupole(double &ixx, double &iyy, double &ixy) const =0
A temporary-only expression object for ellipse core convolution.
double constexpr PI
The ratio of a circle's circumference to diameter.
virtual void writeParameters(double *iter) const =0