40template <
typename T,
size_t dimension>
44 static_assert(dimension >= 2,
"A Point must consist of at least two coordinates (x,y)!");
45 static_assert(std::is_arithmetic<T>::value,
"A point must be created from an arithmetic type!");
63 constexpr explicit PointXd(std::array<T, dimension> coordinates)
64 : m_coordinates{ coordinates }
76 return m_coordinates.at(0);
88 return m_coordinates.at(1);
102 template <
typename H,
106 typename std::enable_if_t<std::is_integral<H>::value,
int> = 0
111 return std::equal(this->m_coordinates.begin(), this->m_coordinates.end(), rhs.
GetCoordinates().begin());
125 template <
typename H,
size_t d>
128 return !(*
this == rhs);
143 template <
typename H,
147 typename std::enable_if_t<std::is_floating_point<H>::value,
int> = 0
152 using common_type = std::common_type_t<T, H>;
155 constexpr uint32_t ulp = 4;
157 return std::equal(this->m_coordinates.begin(), this->m_coordinates.end(), rhs.
GetCoordinates().begin(),
158 [ulp](
const auto& left,
const auto& right) {
159 return detail::AreAlmostEqual<common_type>(static_cast<common_type>(left), static_cast<common_type>(right), ulp);
172 return m_coordinates;
176 std::array<T, dimension> m_coordinates{};
198 static_assert(std::is_arithmetic<T>::value,
"Template argument of Point must be arithmetic.");
233 return os <<
"{ x: " << point.
GetX() <<
", y: " << point.
GetY() <<
" }";
247 std::ostringstream ss;
253 friend detail::BackendAccessor<PointT<T>>;
255 template <
typename U = T,
typename std::enable_if<has_c_type_of<Po
intT<U>>::value,
bool>::type = false>
256 constexpr explicit PointT(peak::common::detail::c_type_of_t<
PointT<U>> point)
257 :
PointT(static_cast<T>(point.x), static_cast<T>(point.y))
260 template <
typename U = T,
typename std::enable_if<has_c_type_of<Po
intT<U>>::value,
bool>::type = false>
261 constexpr explicit operator peak::common::detail::c_type_of_t<PointT<U>>()
const
263 return { this->
GetX(), this->
GetY() };
266 friend detail::BackendAccessor<PointType>;
2D point template type.
Definition peak_common_point.hpp:192
constexpr PointT(T x, T y)
Point constructor from x and y coordinates.
Definition peak_common_point.hpp:216
friend std::ostream & operator<<(std::ostream &os, PointT point)
Stream output operator for PointT.
Definition peak_common_point.hpp:231
constexpr PointT()=default
Default constructor for PointT (2D point).
PEAK_COMMON_NO_DISCARD std::string ToString() const
Returns a string representation of the point.
Definition peak_common_point.hpp:245
PEAK_COMMON_NO_DISCARD constexpr T GetY() const
Returns the y-coordinate (second component).
Definition peak_common_point.hpp:86
constexpr bool operator==(const PointXd< H, d > &rhs) const
Equality operator for comparing integral coordinates.
Definition peak_common_point.hpp:109
PEAK_COMMON_NO_DISCARD constexpr std::array< T, dimension > GetCoordinates() const
Returns the coordinates of the point as an array.
Definition peak_common_point.hpp:170
constexpr PointXd(std::array< T, dimension > coordinates)
Constructs a PointXd from an array of coordinates.
Definition peak_common_point.hpp:63
constexpr bool operator!=(const PointXd< H, d > &rhs) const
Inequality operator for comparing coordinates.
Definition peak_common_point.hpp:126
constexpr PointXd()=default
Default constructor for PointXd.
PEAK_COMMON_NO_DISCARD constexpr T GetX() const
Returns the x-coordinate (first component).
Definition peak_common_point.hpp:74
detail::PointT< int32_t > Point
2D point with 32-bit signed integer coordinates.
Definition peak_common_point.hpp:283
detail::PointT< uint32_t > PointU
2D point with 32-bit unsigned integer coordinates.
Definition peak_common_point.hpp:311
detail::PointT< float > PointF
2D point with single-precision floating-point coordinates.
Definition peak_common_point.hpp:297
Namespace for internal implementation details and low-level types.
Definition peak_common_math.hpp:24
Root namespace for common types and interfaces shared across multiple libraries.
Definition peak_common_math.hpp:22
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_dynamic_loader.h:35
#define PEAK_COMMON_NO_DISCARD
Definition peak_common_defines.h:94