Loading [MathJax]/extensions/tex2jax.js
LSST Applications g04a91732dc+cc8870d3f5,g07dc498a13+5aa0b8792f,g0fba68d861+488cddfaa9,g1409bbee79+5aa0b8792f,g1a7e361dbc+5aa0b8792f,g1fd858c14a+f64bc332a9,g35bb328faa+fcb1d3bbc8,g4d2262a081+b1c1982739,g4d39ba7253+9633a327c1,g4e0f332c67+5d362be553,g53246c7159+fcb1d3bbc8,g60b5630c4e+9633a327c1,g668ecb457e+25d63fd678,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g7b71ed6315+fcb1d3bbc8,g8852436030+8b64ca622a,g89139ef638+5aa0b8792f,g89e1512fd8+37f975783e,g8d6b6b353c+9633a327c1,g9125e01d80+fcb1d3bbc8,g989de1cb63+5aa0b8792f,g9f33ca652e+b196626af7,ga9baa6287d+9633a327c1,gaaedd4e678+5aa0b8792f,gabe3b4be73+1e0a283bba,gb1101e3267+71e32094df,gb58c049af0+f03b321e39,gb90eeb9370+2807b1ad02,gc741bbaa4f+1ae86710ed,gcf25f946ba+8b64ca622a,gd315a588df+a39986a76f,gd6cbbdb0b4+c8606af20c,gd9a9a58781+fcb1d3bbc8,gde0f65d7ad+94dfc458f4,ge278dab8ac+932305ba37,ge82c20c137+76d20ab76d,gfe73954cf8+a1301e4c20,w.2025.11
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