Commit 135249e7 authored by Pierre NARVOR's avatar Pierre NARVOR
Browse files

[types] Added a Bounds type

parent 13b23647
...@@ -16,6 +16,7 @@ list(APPEND rtac_base_headers ...@@ -16,6 +16,7 @@ list(APPEND rtac_base_headers
include/rtac_base/types/Handle.h include/rtac_base/types/Handle.h
include/rtac_base/types/Shape.h include/rtac_base/types/Shape.h
include/rtac_base/types/Rectangle.h include/rtac_base/types/Rectangle.h
include/rtac_base/types/Bounds.h
include/rtac_base/types/common.h include/rtac_base/types/common.h
include/rtac_base/types/Pose.h include/rtac_base/types/Pose.h
include/rtac_base/types/Point.h include/rtac_base/types/Point.h
......
#ifndef _DEF_RTAC_BASE_TYPES_BOUNDS_H_
#define _DEF_RTAC_BASE_TYPES_BOUNDS_H_
#include <iostream>
#include <array>
namespace rtac { namespace types {
template <typename T>
struct Interval {
T min;
T max;
T length() const {
return this->max - this->min;
}
};
template <typename T, std::size_t N>
using Bounds = std::array<Interval<T>, N>;
}; //namespace types
}; //namespace rtac
template <typename T>
std::ostream& operator<<(std::ostream& os, const rtac::types::Interval<T>& interval)
{
os << "(min : " << interval.min << ", max : " << interval.max << ")";
return os;
}
template <typename T, std::size_t N>
std::ostream& operator<<(std::ostream& os, const rtac::types::Bounds<T,N>& bounds)
{
for(auto& i : bounds) {
os << i << std::endl;
}
return os;
}
#endif //_DEF_RTAC_BASE_TYPES_BOUNDS_H_
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment