Add geom::cast for intervals and boxes
This commit is contained in:
parent
969dc1d2f5
commit
3472bf056b
2 changed files with 15 additions and 0 deletions
|
|
@ -67,6 +67,15 @@ namespace psemek::geom
|
||||||
box & operator |= (box const & b);
|
box & operator |= (box const & b);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T1, typename T, std::size_t N>
|
||||||
|
box<T1, N> cast(box<T, N> const & b)
|
||||||
|
{
|
||||||
|
box<T1, N> result;
|
||||||
|
for (std::size_t i = 0; i < N; ++i)
|
||||||
|
result[i] = cast<T1>(b[i]);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, std::size_t N>
|
template <typename T, std::size_t N>
|
||||||
box<T, N> operator + (box<T, N> const & b, vector<T, N> const & delta)
|
box<T, N> operator + (box<T, N> const & b, vector<T, N> const & delta)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,12 @@ namespace psemek::geom
|
||||||
interval & operator |= (interval const & i);
|
interval & operator |= (interval const & i);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T1, typename T>
|
||||||
|
interval<T1> cast(interval<T> const & i)
|
||||||
|
{
|
||||||
|
return {static_cast<T1>(i.min), static_cast<T1>(i.max)};
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
interval<T> operator + (interval<T> const & i, T const & delta)
|
interval<T> operator + (interval<T> const & i, T const & delta)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue