LSSTApplications  17.0+124,17.0+14,17.0+73,18.0.0+37,18.0.0+80,18.0.0-4-g68ffd23+4,18.1.0-1-g0001055+12,18.1.0-1-g03d53ef+5,18.1.0-1-g1349e88+55,18.1.0-1-g2505f39+44,18.1.0-1-g5315e5e+4,18.1.0-1-g5e4b7ea+14,18.1.0-1-g7e8fceb+4,18.1.0-1-g85f8cd4+48,18.1.0-1-g8ff0b9f+4,18.1.0-1-ga2c679d+1,18.1.0-1-gd55f500+35,18.1.0-10-gb58edde+2,18.1.0-11-g0997b02+4,18.1.0-13-gfe4edf0b+12,18.1.0-14-g259bd21+21,18.1.0-19-gdb69f3f+2,18.1.0-2-g5f9922c+24,18.1.0-2-gd3b74e5+11,18.1.0-2-gfbf3545+32,18.1.0-26-g728bddb4+5,18.1.0-27-g6ff7ca9+2,18.1.0-3-g52aa583+25,18.1.0-3-g8ea57af+9,18.1.0-3-gb69f684+42,18.1.0-3-gfcaddf3+6,18.1.0-32-gd8786685a,18.1.0-4-gf3f9b77+6,18.1.0-5-g1dd662b+2,18.1.0-5-g6dbcb01+41,18.1.0-6-gae77429+3,18.1.0-7-g9d75d83+9,18.1.0-7-gae09a6d+30,18.1.0-9-gc381ef5+4,w.2019.45
LSSTDataManagementBasePackage
Axes.cc
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008, 2009, 2010 LSST Corporation.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
26 
27 namespace lsst {
28 namespace afw {
29 namespace geom {
30 namespace ellipses {
31 
32 BaseCore::Registrar<Axes> Axes::registrar;
33 
34 std::string Axes::getName() const { return "Axes"; }
35 
37  if (_vector[A] < 0 || _vector[B] < 0)
39  "Major and minor axes cannot be negative.");
40  if (_vector[A] < _vector[B]) {
41  std::swap(_vector[A], _vector[B]);
42  _vector[THETA] += M_PI_2;
43  }
44  if (_vector[THETA] > M_PI_2 || _vector[THETA] <= -M_PI_2) {
45  _vector[THETA] -= M_PI * std::ceil(_vector[THETA] / M_PI - 0.5);
46  }
47 }
48 
49 void Axes::readParameters(double const* iter) {
50  setA(*iter++);
51  setB(*iter++);
52  setTheta(*iter++);
53 }
54 
55 void Axes::writeParameters(double* iter) const {
56  *iter++ = getA();
57  *iter++ = getB();
58  *iter++ = getTheta();
59 }
60 
61 void Axes::_assignToQuadrupole(double& ixx, double& iyy, double& ixy) const {
62  BaseCore::_assignAxesToQuadrupole(_vector[A], _vector[B], _vector[THETA], ixx, iyy, ixy);
63 }
64 
65 BaseCore::Jacobian Axes::_dAssignToQuadrupole(double& ixx, double& iyy, double& ixy) const {
66  return BaseCore::_dAssignAxesToQuadrupole(_vector[A], _vector[B], _vector[THETA], ixx, iyy, ixy);
67 }
68 
69 void Axes::_assignToAxes(double& a, double& b, double& theta) const {
70  a = _vector[A];
71  b = _vector[B];
72  theta = _vector[THETA];
73 }
74 
75 BaseCore::Jacobian Axes::_dAssignToAxes(double& a, double& b, double& theta) const {
76  a = _vector[A];
77  b = _vector[B];
78  theta = _vector[THETA];
79  return Jacobian::Identity();
80 }
81 
82 void Axes::_assignFromQuadrupole(double ixx, double iyy, double ixy) {
83  BaseCore::_assignQuadrupoleToAxes(ixx, iyy, ixy, _vector[A], _vector[B], _vector[THETA]);
84  normalize();
85 }
86 
87 BaseCore::Jacobian Axes::_dAssignFromQuadrupole(double ixx, double iyy, double ixy) {
88  return BaseCore::_dAssignQuadrupoleToAxes(ixx, iyy, ixy, _vector[A], _vector[B], _vector[THETA]);
89  normalize();
90 }
91 
92 void Axes::_assignFromAxes(double a, double b, double theta) {
93  _vector[A] = a;
94  _vector[B] = b;
95  _vector[THETA] = theta;
96 }
97 
98 BaseCore::Jacobian Axes::_dAssignFromAxes(double a, double b, double theta) {
99  _vector[A] = a;
100  _vector[B] = b;
101  _vector[THETA] = theta;
102  return Jacobian::Identity();
103 }
104 } // namespace ellipses
105 } // namespace geom
106 } // namespace afw
107 } // namespace lsst
static Jacobian _dAssignQuadrupoleToAxes(double ixx, double iyy, double ixy, double &a, double &b, double &theta)
Definition: BaseCore.cc:194
double const getB() const
Definition: Axes.h:54
static Jacobian _dAssignAxesToQuadrupole(double a, double b, double theta, double &ixx, double &iyy, double &ixy)
Definition: BaseCore.cc:232
Jacobian _dAssignFromQuadrupole(double ixx, double iyy, double ixy) override
Definition: Axes.cc:87
T ceil(T... args)
void writeParameters(double *iter) const override
Definition: Axes.cc:55
T swap(T... args)
double const getA() const
Definition: Axes.h:51
table::Key< int > b
void setB(double b)
Definition: Axes.h:55
table::Key< int > a
void setA(double a)
Definition: Axes.h:52
std::string getName() const override
Return a string that identifies this parametrization.
Definition: Axes.cc:34
Jacobian _dAssignToAxes(double &a, double &b, double &theta) const override
Definition: Axes.cc:75
static void _assignQuadrupoleToAxes(double ixx, double iyy, double ixy, double &a, double &b, double &theta)
Definition: BaseCore.cc:184
void _assignToAxes(double &a, double &b, double &theta) const override
Definition: Axes.cc:69
void readParameters(double const *iter) override
Definition: Axes.cc:49
#define M_PI
Definition: ListMatch.cc:31
STL class.
void _assignFromQuadrupole(double ixx, double iyy, double ixy) override
Definition: Axes.cc:82
A base class for image defects.
static void _assignAxesToQuadrupole(double a, double b, double theta, double &ixx, double &iyy, double &ixy)
Definition: BaseCore.cc:219
Jacobian _dAssignToQuadrupole(double &ixx, double &iyy, double &ixy) const override
Definition: Axes.cc:65
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
Eigen::Matrix3d Jacobian
Parameter Jacobian matrix type.
Definition: BaseCore.h:64
void setTheta(double theta)
Definition: Axes.h:58
void _assignFromAxes(double a, double b, double theta) override
Definition: Axes.cc:92
void normalize() override
Put the parameters into a "standard form", if possible, and throw InvalidParameterError if they canno...
Definition: Axes.cc:36
Reports invalid arguments.
Definition: Runtime.h:66
void _assignToQuadrupole(double &ixx, double &iyy, double &ixy) const override
Definition: Axes.cc:61
Jacobian _dAssignFromAxes(double a, double b, double theta) override
Definition: Axes.cc:98
double const getTheta() const
Definition: Axes.h:57