lsst.geom  16.0-2-ge920381
Extent.cc
Go to the documentation of this file.
1 /*
2  * Developed for the LSST Data Management System.
3  * This product includes software developed by the LSST Project
4  * (https://www.lsst.org).
5  * See the COPYRIGHT file at the top-level directory of this distribution
6  * for details of code ownership.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
23 #include "lsst/geom/Point.h"
24 #include "lsst/geom/Extent.h"
25 
26 namespace lsst {
27 namespace geom {
28 
29 template <typename T, int N>
30 Extent<T, N>::Extent(Point<T, N> const &other) : Super(other.asEigen()) {}
31 
32 // The following two template specializations raise Doxygen warnings and produce no documenation.
33 // This is a known Doxygen bug: <https://bugzilla.gnome.org/show_bug.cgi?id=406027>
35 template <typename T>
36 Extent<T, 2>::Extent(Point<T, 2> const &other) : Super(other.asEigen()) {}
37 
38 template <typename T>
39 Extent<T, 3>::Extent(Point<T, 3> const &other) : Super(other.asEigen()) {}
41 
42 template <typename T, int N>
45  for (int n = 0; n < N; ++n) r[n] = this->_vector[n] == other[n];
46  return r;
47 }
48 
49 template <typename T, int N>
52  for (int n = 0; n < N; ++n) r[n] = this->_vector[n] != other[n];
53  return r;
54 }
55 
56 template <typename T, int N>
59  for (int n = 0; n < N; ++n) r[n] = this->_vector[n] < other[n];
60  return r;
61 }
62 
63 template <typename T, int N>
66  for (int n = 0; n < N; ++n) r[n] = this->_vector[n] <= other[n];
67  return r;
68 }
69 
70 template <typename T, int N>
73  for (int n = 0; n < N; ++n) r[n] = this->_vector[n] > other[n];
74  return r;
75 }
76 
77 template <typename T, int N>
80  for (int n = 0; n < N; ++n) r[n] = this->_vector[n] >= other[n];
81  return r;
82 }
83 
84 template <typename T, int N>
86  return Point<T, N>(static_cast<Extent<T, N> const &>(*this));
87 }
88 
89 template <typename T, int N>
91  return Point<T, N>(this->_vector + other.asEigen());
92 }
93 
94 template <int N>
96  Extent<int, N> result;
97  for (int i = 0; i < N; ++i) {
98  result[i] = static_cast<int>(input[i]);
99  }
100  return result;
101 }
102 
103 template <int N>
105  Extent<int, N> result;
106  for (int i = 0; i < N; ++i) {
107  result[i] = std::floor(input[i]);
108  }
109  return result;
110 }
111 
112 template <int N>
114  Extent<int, N> result;
115  for (int i = 0; i < N; ++i) {
116  result[i] = std::ceil(input[i]);
117  }
118  return result;
119 }
120 
121 #ifndef DOXYGEN
122 
123 template class ExtentBase<int, 2>;
124 template class ExtentBase<int, 3>;
125 template class ExtentBase<double, 2>;
126 template class ExtentBase<double, 3>;
127 template class Extent<int, 2>;
128 template class Extent<int, 3>;
129 template class Extent<double, 2>;
130 template class Extent<double, 3>;
131 template Extent<double, 2>::Extent(Extent<int, 2> const &);
132 template Extent<double, 3>::Extent(Extent<int, 3> const &);
133 template Extent<double, 2>::Extent(Point<int, 2> const &);
134 template Extent<double, 3>::Extent(Point<int, 3> const &);
135 
136 template Extent<int, 2> truncate(Extent<double, 2> const &);
137 template Extent<int, 3> truncate(Extent<double, 3> const &);
138 template Extent<int, 2> floor(Extent<double, 2> const &);
139 template Extent<int, 3> floor(Extent<double, 3> const &);
140 template Extent<int, 2> ceil(Extent<double, 2> const &);
141 template Extent<int, 3> ceil(Extent<double, 3> const &);
142 
143 #endif // !DOXYGEN
144 
145 } // namespace geom
146 } // namespace lsst
Extent(T val=static_cast< T >(0))
Construct an Extent with all elements set to the same scalar value.
Definition: Extent.h:196
A coordinate class intended to represent absolute positions (2-d specialization). ...
Definition: Point.h:194
T ceil(T... args)
A coordinate class intended to represent absolute positions (3-d specialization). ...
Definition: Point.h:247
A coordinate class intended to represent absolute positions.
constexpr Angle operator+(Angle a, Angle d) noexcept
Sum of two angles.
Definition: Angle.h:295
Extent< int, N > truncate(Extent< double, N > const &input)
Return the component-wise truncation (round towards zero).
Definition: Extent.cc:95
Extent< int, N > ceil(Extent< double, N > const &input)
Return the component-wise ceil (round towards more positive).
Definition: Extent.cc:113
T floor(T... args)
Eigen::Vector3d asEigen(sphgeom::Vector3d const &vector)
Definition: sphgeomUtils.h:36
A boolean coordinate.
A coordinate class intended to represent offsets and dimensions.
Extent< int, N > floor(Extent< double, N > const &input)
Return the component-wise floor (round towards more negative).
Definition: Extent.cc:104
EigenVector const & asEigen() const
Return a fixed-size Eigen representation of the coordinate object.