LSST Applications g0fba68d861+5616995c1c,g1ebb85f214+2420ccdea7,g1fd858c14a+44c57a1f81,g21d47ad084+8e51fce9ac,g262e1987ae+1a7d68eb3b,g2cef7863aa+3bd8df3d95,g35bb328faa+fcb1d3bbc8,g36ff55ed5b+2420ccdea7,g47891489e3+5c6313fe9a,g53246c7159+fcb1d3bbc8,g646c943bdb+dbb9921566,g67b6fd64d1+5c6313fe9a,g6bd32b75b5+2420ccdea7,g74acd417e5+37fc0c974d,g786e29fd12+cf7ec2a62a,g86c591e316+6e13bcb9e9,g87389fa792+1e0a283bba,g89139ef638+5c6313fe9a,g90f42f885a+fce05a46d3,g9125e01d80+fcb1d3bbc8,g93e38de9ac+5345a64125,g95a1e89356+47d08a1cc6,g97be763408+bba861c665,ga9e4eb89a6+85210110a1,gb0b61e0e8e+1f27f70249,gb58c049af0+f03b321e39,gb89ab40317+5c6313fe9a,gc4e39d7843+4e09c98c3d,gd16ba4ae74+5402bcf54a,gd8ff7fe66e+2420ccdea7,gd9a9a58781+fcb1d3bbc8,gdab6d2f7ff+37fc0c974d,gde280f09ee+604b327636,ge278dab8ac+50e2446c94,ge410e46f29+5c6313fe9a,gef3c2e6661+6b480e0fb7,gf67bdafdda+5c6313fe9a,gffca2db377+fcb1d3bbc8,v29.2.0.rc1
LSST Data Management Base Package
Loading...
Searching...
No Matches
centroid.h
Go to the documentation of this file.
1// -*- LSST-C++ -*-
2/*
3 * This file is part of gauss2d.
4 *
5 * Developed for the LSST Data Management System.
6 * This product includes software developed by the LSST Project
7 * (https://www.lsst.org).
8 * See the COPYRIGHT file at the top-level directory of this distribution
9 * for details of code ownership.
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
25#ifndef LSST_GAUSS2D_CENTROID_H
26#define LSST_GAUSS2D_CENTROID_H
27
28#include <array>
29#include <memory>
30#include <string>
31
32#include "object.h"
33
34namespace lsst::gauss2d {
35
43class CentroidData : public Object {
44public:
46 virtual double get_x() const = 0;
48 virtual std::array<double, 2> get_xy() const = 0;
50 virtual double get_y() const = 0;
51
52 virtual void set_x(double x) = 0;
53 virtual void set_xy(const std::array<double, 2>& xy) = 0;
54 virtual void set_y(double y) = 0;
55
56 bool operator==(const CentroidData& other) const {
57 return (get_x() == other.get_x()) && (get_y() == other.get_y());
58 };
59
60 virtual std::string repr(bool name_keywords = false, std::string_view namespace_separator
61 = Object::CC_NAMESPACE_SEPARATOR) const override
62 = 0;
63 virtual std::string str() const override = 0;
64 virtual ~CentroidData() = default;
65};
66
74class CentroidValues : public virtual CentroidData {
75public:
76 double get_x() const override;
77 std::array<double, 2> get_xy() const override;
78 double get_y() const override;
79
80 void set_x(double x) override;
81 void set_xy(const std::array<double, 2>& xy) override;
82 void set_y(double y) override;
83
84 std::string repr(bool name_keywords, std::string_view namespace_separator) const override;
85 std::string str() const override;
86
87 bool operator==(const CentroidValues& other) const;
88 bool operator!=(const CentroidValues& other) const;
89
97 CentroidValues(double x = 0, double y = 0);
98
99 virtual ~CentroidValues() {};
100
101private:
104};
105
114class Centroid : public Object {
115public:
117 explicit Centroid(double x = 0, double y = 0);
125 void convolve(const Centroid& cen);
126
128 const CentroidData& get_data() const;
130 double get_x() const;
134 double get_y() const;
135
148
149 void set_x(double x);
150 void set_xy(const std::array<double, 2>& xy);
151 void set_y(double y);
152
153 std::string repr(bool name_keywords = false,
154 std::string_view namespace_separator = Object::CC_NAMESPACE_SEPARATOR) const override;
155 std::string str() const override;
156
157 bool operator==(const Centroid& other) const;
158 bool operator!=(const Centroid& other) const;
159
160private:
162};
163
164} // namespace lsst::gauss2d
165#endif
Interface for an object storing Centroid data.
Definition centroid.h:43
virtual ~CentroidData()=default
virtual void set_y(double y)=0
virtual double get_x() const =0
Get the x value.
virtual double get_y() const =0
Get the y value.
virtual std::array< double, 2 > get_xy() const =0
Get the x and y values.
bool operator==(const CentroidData &other) const
Definition centroid.h:56
virtual void set_x(double x)=0
virtual std::string str() const override=0
Return a brief, human-readable string representation of this.
virtual std::string repr(bool name_keywords=false, std::string_view namespace_separator=Object::CC_NAMESPACE_SEPARATOR) const override=0
Return a full, callable string representation of this.
virtual void set_xy(const std::array< double, 2 > &xy)=0
double get_y() const
Get the y value.
Definition centroid.cc:80
std::shared_ptr< Centroid > make_convolution(const Centroid &cen) const
Return the convolution of this with another centroid.
Definition centroid.cc:82
std::array< double, 2 > get_xy() const
Get the x and y values.
Definition centroid.cc:78
std::string repr(bool name_keywords=false, std::string_view namespace_separator=Object::CC_NAMESPACE_SEPARATOR) const override
Return a full, callable string representation of this.
Definition centroid.cc:96
std::string str() const override
Return a brief, human-readable string representation of this.
Definition centroid.cc:101
void set_xy(const std::array< double, 2 > &xy)
Definition centroid.cc:93
bool operator!=(const Centroid &other) const
Definition centroid.cc:107
void set_y(double y)
Definition centroid.cc:94
bool operator==(const Centroid &other) const
Definition centroid.cc:103
void set_x(double x)
Definition centroid.cc:92
std::unique_ptr< Centroid > make_convolution_uniq(const Centroid &cen) const
Same as make_convolution(), but returning a unique_ptr.
Definition centroid.cc:85
const CentroidData & get_data() const
Get this centroid's data.
Definition centroid.cc:74
Centroid(std::shared_ptr< CentroidData > data)
Definition centroid.cc:109
double get_x() const
Get the x value.
Definition centroid.cc:76
void convolve(const Centroid &cen)
Convolve this with another centroid.
Definition centroid.cc:69
void set_y(double y) override
Definition centroid.cc:44
void set_xy(const std::array< double, 2 > &xy) override
Definition centroid.cc:40
double get_y() const override
Get the y value.
Definition centroid.cc:37
bool operator!=(const CentroidValues &other) const
Definition centroid.cc:60
bool operator==(const CentroidValues &other) const
Definition centroid.cc:56
void set_x(double x) override
Definition centroid.cc:39
std::string str() const override
Return a brief, human-readable string representation of this.
Definition centroid.cc:51
std::string repr(bool name_keywords, std::string_view namespace_separator) const override
Return a full, callable string representation of this.
Definition centroid.cc:46
CentroidValues(std::shared_ptr< double > x, std::shared_ptr< double > y)
Construct a new Centroid Values object.
Definition centroid.cc:62
std::array< double, 2 > get_xy() const override
Get the x and y values.
Definition centroid.cc:36
double get_x() const override
Get the x value.
Definition centroid.cc:35
A generic object from the gauss2d library.
Definition object.h:40
static constexpr std::string_view CC_NAMESPACE_SEPARATOR
The C++ namespace separator.
Definition object.h:45