Skip to content

Geometric transformations

I think "geometry" should be "geometric", but maybe geom is good enough.

I reorganize the project a little bit to make it more digest for me. I looks like a lot of changes but it's more splitting and moving things around:

  • point
  • rectangle
  • transformation
  • isomorphic

I introduced rational_cast for point (and remove the operator* that had both responsibility). More verbose but Single Responsibility Principle.

There was also overcomplicated stuff such as:

namespace concepts {

  template <typename T>
  constexpr bool is_any_isometric_xform = std::is_same_v<
    concepts::remove_cvref_t<T>,
    any_isometric_xform_t
  >;

} // namespace concepts

template <typename T,
	  std::enable_if_t<concepts::is_any_isometric_xform<T>, int> = 0>
affine_t get_affine(const T& t, point_t input_dimensions)
{
	return std::visit([&](auto&& x) {
		   return get_affine(x, input_dimensions);
	       }, t);
}

which is equivalent to

affine_t get_affine(const any_isometric_xform_t& t, point_t input_dimensions)
{
  return std::visit([&](auto&& x) {
    return get_affine(x, input_dimensions);
  }, t);
}

And I think your concepts::remove_cvref_t is basically std::decay_t.

I changed image_rect::overlap to overlaps, a free function and a predicate (returning a true if two rectangle intersects or are contained). Then we have an intersection() algo, a free function that returns the point set intersection (here a new rectangle).

I need more time to review the "isomorphic" part and how to use it in Lima.

Edited by Alejandro Homs Puron

Merge request reports