Skip to content
Snippets Groups Projects
Commit 01c95abd authored by Aaron Grabowy's avatar Aaron Grabowy
Browse files

Added min_element and max_element for comp

parent 6126c0b8
No related branches found
No related tags found
1 merge request!97Added any_point for all objects and ellipse type including all its functions
......@@ -3,6 +3,7 @@
#include <typed-geometry/functions/basic/limits.hh>
#include <typed-geometry/functions/basic/scalar_math.hh>
#include <typed-geometry/types/comp.hh>
#include <typed-geometry/types/pos.hh>
#include <typed-geometry/types/size.hh>
#include <typed-geometry/types/span.hh>
......@@ -45,6 +46,27 @@ template <class T, class... Ts>
}
template <class ScalarT>
[[nodiscard]] constexpr ScalarT min_element(comp<1, ScalarT> const& p)
{
return p.comp0;
}
template <class ScalarT>
[[nodiscard]] constexpr ScalarT min_element(comp<2, ScalarT> const& p)
{
return min(p.comp0, p.comp1);
}
template <class ScalarT>
[[nodiscard]] constexpr ScalarT min_element(comp<3, ScalarT> const& p)
{
return min(p.comp0, p.comp1, p.comp2);
}
template <class ScalarT>
[[nodiscard]] constexpr ScalarT min_element(comp<4, ScalarT> const& p)
{
return min(min(p.comp0, p.comp1), min(p.comp2, p.comp3));
}
template <class ScalarT>
[[nodiscard]] constexpr ScalarT min_element(pos<1, ScalarT> const& p)
{
......@@ -108,6 +130,28 @@ template <class ScalarT>
return min(min(p.width, p.height), min(p.depth, p.w));
}
template <class ScalarT>
[[nodiscard]] constexpr ScalarT max_element(comp<1, ScalarT> const& p)
{
return p.comp0;
}
template <class ScalarT>
[[nodiscard]] constexpr ScalarT max_element(comp<2, ScalarT> const& p)
{
return max(p.comp0, p.comp1);
}
template <class ScalarT>
[[nodiscard]] constexpr ScalarT max_element(comp<3, ScalarT> const& p)
{
return max(p.comp0, p.comp1, p.comp2);
}
template <class ScalarT>
[[nodiscard]] constexpr ScalarT max_element(comp<4, ScalarT> const& p)
{
return max(max(p.comp0, p.comp1), max(p.comp2, p.comp3));
}
template <class ScalarT>
[[nodiscard]] constexpr ScalarT max_element(pos<1, ScalarT> const& p)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment