Loading [MathJax]/extensions/tex2jax.js
LSST Applications g0fba68d861+b562e0a09f,g1ec0fe41b4+3ea9d11450,g1fd858c14a+9be2b0f3b9,g2440f9efcc+8c5ae1fdc5,g33b6eb7922+23bc9e47ac,g35bb328faa+8c5ae1fdc5,g4a4af6cd76+d25431c27e,g4d2262a081+e64e5ff751,g53246c7159+8c5ae1fdc5,g55585698de+be1c65ba71,g56a49b3a55+92a7603e7a,g60b5630c4e+be1c65ba71,g67b6fd64d1+3fc8cb0b9e,g78460c75b0+7e33a9eb6d,g786e29fd12+668abc6043,g8352419a5c+8c5ae1fdc5,g8852436030+60e38ee5ff,g89139ef638+3fc8cb0b9e,g94187f82dc+be1c65ba71,g989de1cb63+3fc8cb0b9e,g9d31334357+be1c65ba71,g9f33ca652e+69d6bbdd4b,gabe3b4be73+8856018cbb,gabf8522325+977d9fabaf,gb1101e3267+b0077987df,gb89ab40317+3fc8cb0b9e,gc91f06edcd+2e2ca305f6,gcf25f946ba+60e38ee5ff,gd6cbbdb0b4+1cc2750d2e,gdb1c4ca869+be65c9c1d7,gde0f65d7ad+b038c5c67d,ge278dab8ac+6b863515ed,ge410e46f29+3fc8cb0b9e,geb5476ad96+a886b35a30,gf35d7ec915+97dd712d81,gf5e32f922b+8c5ae1fdc5,gf618743f1b+3164b09b60,gf67bdafdda+3fc8cb0b9e,w.2025.18
LSST Data Management Base Package
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
coordinatesystem.cc
Go to the documentation of this file.
1/*
2 * This file is part of gauss2d.
3 *
4 * Developed for the LSST Data Management System.
5 * This product includes software developed by the LSST Project
6 * (https://www.lsst.org).
7 * See the COPYRIGHT file at the top-level directory of this distribution
8 * for details of code ownership.
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 GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
24#ifndef LSST_GAUSS2D_COORDINATESYSTEM_H
25
26#include <cmath>
27#include <stdexcept>
28#include <string>
29
33
34namespace lsst::gauss2d {
35
36double CoordinateSystem::get_dx1() const { return _dx1; }
37double CoordinateSystem::get_dy2() const { return _dy2; }
38
39double CoordinateSystem::get_x_min() const { return _x_min; }
40double CoordinateSystem::get_y_min() const { return _y_min; }
41
42bool CoordinateSystem::is_xy_aligned() const { return true; }
43
45 return (_dx1 == other.get_dx1()) && (_dy2 == other.get_dy2()) && (_x_min == other.get_x_min())
46 && (_y_min == other.get_y_min());
47}
48
49bool CoordinateSystem::operator!=(const CoordinateSystem& other) const { return !(*this == other); }
50
51std::string CoordinateSystem::repr(bool name_keywords, std::string_view namespace_separator) const {
52 return type_name_str<CoordinateSystem>(false, namespace_separator) + "(" + (name_keywords ? "dx1=" : "")
53 + to_string_float(_dx1) + ", " + (name_keywords ? "dy2=" : "") + to_string_float(_dy2) + ", "
54 + (name_keywords ? "x_min=" : "") + to_string_float(_x_min) + ", "
55 + (name_keywords ? "y_min=" : "") + to_string_float(_y_min) + ")";
56}
57
59 return type_name_str<CoordinateSystem>(true) + "(dx1=" + to_string_float(_dx1)
60 + ", dy2=" + to_string_float(_dy2) + ", x_min=" + to_string_float(_x_min)
61 + ", y_min=" + to_string_float(_y_min) + ")";
62}
63
64CoordinateSystem::CoordinateSystem(double dx1, double dy2, double x_min, double y_min)
65 : _dx1(dx1), _dy2(dy2), _x_min(x_min), _y_min(y_min) {
66 std::string errmsg = "";
67 if (!((dx1 != 0) && std::isfinite(dx1) && (dy2 != 0) && std::isfinite(dy2))) {
68 errmsg += "dx1, dy2 = " + to_string_float(_dx1) + ", " + to_string_float(_dy2) + " ==0 or !finite; ";
69 }
70 if (!(std::isfinite(_x_min) && std::isfinite(_y_min))) {
71 errmsg += "x_min, y_min = " + to_string_float(_x_min) + ", " + to_string_float(_y_min) + " !finite; ";
72 }
73 if (errmsg != "") {
74 throw std::invalid_argument(errmsg);
75 }
76}
77
79
80} // namespace lsst::gauss2d
81
82#endif
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.
bool operator==(const CoordinateSystem &other) const
CoordinateSystem(double dx1=1., double dy2=1, double x_min=0, double y_min=0)
std::string str() const override
Return a brief, human-readable string representation of this.
bool operator!=(const CoordinateSystem &other) const
T isfinite(T... args)
std::string type_name_str(bool strip_namespace=false, std::string_view namespace_str=detail::NAMESPACE_SEPARATOR)
Get a string representation of an arbitrary C++ type, potentially modifying its namespace prefix.
Definition type_name.h:104
std::string to_string_float(const T value, const int precision=6, const bool scientific=true)
Definition to_string.h:15