Add helper function to add Dimensions

This commit is contained in:
Jonathan G Rennison
2020-11-06 23:46:21 +00:00
parent d50f3cd580
commit 74efe0b840
2 changed files with 15 additions and 0 deletions

View File

@@ -26,3 +26,17 @@ Dimension maxdim(const Dimension &d1, const Dimension &d2)
d.height = max(d1.height, d2.height); d.height = max(d1.height, d2.height);
return d; return d;
} }
/**
* Compute sum of both dimensions.
* @param d1 First dimension.
* @param d2 Second dimension.
* @return The sum of both dimensions.
*/
Dimension adddim(const Dimension &d1, const Dimension &d2)
{
Dimension d;
d.width = d1.width + d2.width;
d.height = d1.height + d2.height;
return d;
}

View File

@@ -13,5 +13,6 @@
#include "geometry_type.hpp" #include "geometry_type.hpp"
Dimension maxdim(const Dimension &d1, const Dimension &d2); Dimension maxdim(const Dimension &d1, const Dimension &d2);
Dimension adddim(const Dimension &d1, const Dimension &d2);
#endif /* GEOMETRY_FUNC_HPP */ #endif /* GEOMETRY_FUNC_HPP */