MRPT  1.9.9
TPixelCoord.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <iosfwd>
12 #include <utility>
13 
14 namespace mrpt::img
15 {
16 /** A pair (x,y) of pixel coordinates (subpixel resolution). \ingroup
17  * mrpt_img_grp */
19 {
20  /** The type of \a x and \a y */
21  using pixel_coord_t = float;
22 
23  float x{.0f}, y{.0f};
24 
25  /** Default constructor: undefined values of x,y */
26  TPixelCoordf() = default;
27  /** Constructor from x,y values */
28  TPixelCoordf(const float _x, const float _y) : x(_x), y(_y) {}
29  template <typename T>
30  TPixelCoordf(const std::pair<T, T>& p)
31  : x(static_cast<float>(p.first)), y(static_cast<float>(p.second))
32  {
33  }
34 };
35 
36 /** Prints TPixelCoordf as "(x,y)" */
37 std::ostream& operator<<(std::ostream& o, const TPixelCoordf& p);
38 
39 /** A pair (x,y) of pixel coordinates (integer resolution). */
41 {
42  /** The type of \a x and \a y */
43  using pixel_coord_t = int;
44 
45  TPixelCoord() = default;
46  TPixelCoord(const int _x, const int _y) : x(_x), y(_y) {}
47  inline bool operator==(const TPixelCoord& o)
48  {
49  return x == o.x && y == o.y;
50  }
51  int x{0}, y{0};
52 };
53 
54 /** Prints TPixelCoord as "(x,y)" */
55 std::ostream& operator<<(std::ostream& o, const TPixelCoord& p);
56 
57 /** A type for image sizes. */
59 
60 } // namespace mrpt::img
float pixel_coord_t
The type of x and y.
Definition: TPixelCoord.h:21
A pair (x,y) of pixel coordinates (subpixel resolution).
Definition: TPixelCoord.h:18
TPixelCoord(const int _x, const int _y)
Definition: TPixelCoord.h:46
TPixelCoordf(const std::pair< T, T > &p)
Definition: TPixelCoord.h:30
A pair (x,y) of pixel coordinates (integer resolution).
Definition: TPixelCoord.h:40
bool operator==(const TPixelCoord &o)
Definition: TPixelCoord.h:47
TPixelCoordf(const float _x, const float _y)
Constructor from x,y values.
Definition: TPixelCoord.h:28
int pixel_coord_t
The type of x and y.
Definition: TPixelCoord.h:43
TPixelCoordf()=default
Default constructor: undefined values of x,y.
std::ostream & operator<<(std::ostream &o, const TColor &c)
Definition: TColor.cpp:80



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020