Positions and Bounds
-
template<class T>
class Position Class for storing 2d position vectors in an (x, y) format.
Public Functions
-
inline Position()
Default Constructor = (0,0)
-
template<typename T2>
inline Position<typename SelfPromotion<T, T2>::type> &operator+=(const Position<T2> &rhs) Overloaded += operator, following standard vector algebra rules.
-
template<typename T2>
inline Position<typename SelfPromotion<T, T2>::type> &operator-=(const Position<T2> &rhs) Overloaded -= operator, following standard vector algebra rules.
-
template<typename T2>
inline Position<typename Promotion<T, T2>::type> operator+(const Position<T2> &rhs) const Overloaded vector + addition operator with a Position on the rhs.
-
template<typename T2>
inline Position<typename Promotion<T, T2>::type> operator-(const Position<T2> &rhs) const Overloaded vector - subtraction operator with a Position on the rhs.
-
inline bool operator!=(const Position<T> &rhs) const
Overloaded != relational non-equality operator.
-
inline void write(std::ostream &fout) const
Write (x, y) position to output stream.
-
inline void read(std::istream &fin)
Read (x, y) position from input istream.
-
inline Position()
-
template<class T>
class Bounds Class for storing image bounds, essentially the vertices of a rectangle.
This is used to keep track of the bounds of catalogs and fields. You can set values, but generally you just keep including positions of each galaxy or the bounds of each catalog respectively using the += operators.
The bounds are stored as four numbers in each instance, (xmin, ymin, xmax, ymax), with an additional boolean switch to say whether or not the Bounds rectangle has been defined.
Rectangle is undefined if min>max in either direction.
Public Functions
-
inline Bounds(const T x1, const T x2, const T y1, const T y2)
Constructor using four scalar positions (xmin, xmax, ymin, ymax).
-
inline Bounds(const Position<T> &pos1, const Position<T> &pos2)
Constructor using two Positions, first for x/ymin, second for x/ymax.
-
inline Bounds()
Constructor for empty Bounds, .isDefined() method will return false.
-
inline ~Bounds()
Destructor.
-
Position<T> center() const
Return the nominal center of the image.
This is the position of the pixel that is considered to be (0,0)
-
Position<double> trueCenter() const
Return the true center of the image.
For even-sized, integer bounds, this will not be an integer, since the center in that case falls between two pixels.
-
void expand(const double m)
expand bounds by a factor m around the current center.
-
template<typename T2>
inline bool includes(const Position<T2> &pos) const return whether the bounded region includes a given point
-
inline bool includes(const Bounds<T> &rhs) const
return whether the bounded region includes all of the given bounds
-
inline bool isSameShapeAs(const Bounds<T> &rhs) const
Check if two bounds have same shape, but maybe different origin.
-
inline T area() const
Return the area of the enclosed region.
The area is a bit different for integer-type Bounds and float-type bounds. For floating point types, it is simply (xmax-xmin)*(ymax-ymin). However, for integer type, we need to add 1 to each size to correctly count the number of pixels being described by the bounding box.
-
std::vector<Bounds<T>> divide(int nx, int ny) const
divide the current bounds into (nx x ny) sub-regions
-
inline void write(std::ostream &fout) const
write out to a file
-
inline void read(std::istream &fin)
read in from a file
-
inline Bounds(const T x1, const T x2, const T y1, const T y2)
.