31 #ifndef MLN_GEOM_ROTATE_HH
32 # define MLN_GEOM_ROTATE_HH
34 # include <mln/core/concept/image.hh>
35 # include <mln/core/concept/site_set.hh>
36 # include <mln/core/concept/box.hh>
38 # include <mln/core/routine/extend.hh>
40 # include <mln/core/image/imorph/tr_image.hh>
42 # include <mln/accu/shape/bbox.hh>
44 # include <mln/data/paste.hh>
46 # include <mln/geom/bbox.hh>
48 # include <mln/extension/duplicate.hh>
50 # include <mln/fun/x2x/composed.hh>
51 # include <mln/fun/x2x/rotation.hh>
52 # include <mln/fun/x2x/translation.hh>
54 # include <mln/literal/zero.hh>
56 # include <mln/math/pi.hh>
80 template <
typename I,
typename Ext,
typename S>
82 rotate(const Image<I>& input,
double angle,
83 const Ext& extension, const Site_Set<S>& output_domain);
87 template <typename I, typename Ext>
89 rotate(const Image<I>& input,
double angle, const Ext& extension);
96 rotate(const Image<I>& input,
double angle);
104 template <typename B>
106 rotate(const Box<B>& box_,
double angle, const mln_site(B)& ref);
112 template <typename B>
114 rotate(const Box<B>& box,
double angle);
118 # ifndef MLN_INCLUDE_ONLY
121 template <
typename I,
typename Ext,
typename S>
124 const Ext& extension_, const
Site_Set<S>& output_domain_)
126 trace::entering(
"geom::rotate");
128 const I& input = exact(input_);
129 const S& output_domain = exact(output_domain_);
130 const mln_exact(Ext)& extension = exact(extension_);
134 typedef mln_site(I) P;
135 mln_precondition(P::dim == 2);
136 mln_precondition(input.is_valid());
137 mln_precondition(angle >= -360.0f && angle <= 360.0f);
139 mlc_is_a(S,
Box)::check();
161 if (!output_domain.is_valid())
162 b =
rotate(input.domain(), angle);
165 typename mln::internal::extension_type<const I, mln_exact(Ext)>::result ext_t;
170 tr_t tr = transposed_image(b, ext_t(input, extension), comp_transf);
173 mln_concrete(I) output;
178 trace::exiting(
"geom::rotate");
183 template <
typename I,
typename Ext>
190 typedef mln_domain(I) domain_t;
191 return rotate(input, angle, extension, domain_t());
195 template <
typename I>
203 template <
typename B>
207 trace::entering(
"geom::rotate");
209 const B& box = exact(box_);
211 typedef mln_site(B) P;
212 mln_precondition(P::dim == 2);
213 mln_precondition(box.is_valid());
214 mln_precondition(angle >= -360.0f && angle <= 360.0f);
218 t(-1 * ref.to_vec()),
233 top_right(box.pmin().row(),
235 bot_left(box.pmax().row(),
238 accu.take(P(comp_transf(box.pmin().to_vec())));
239 accu.take(P(comp_transf(top_right.to_vec())));
240 accu.take(P(comp_transf(bot_left.to_vec())));
241 accu.take(P(comp_transf(box.pmax().to_vec())));
245 trace::exiting(
"geom::rotate");
250 template <
typename B>
254 return rotate(box, angle, exact(box).pcenter());
259 # endif // ! MLN_INCLUDE_ONLY
267 #endif // ! MLN_GEOM_ROTATE_HH