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