27 #ifndef SCRIBO_FILTER_INTERNAL_ALIGNMENT_ANGLE_HH
28 # define SCRIBO_FILTER_INTERNAL_ALIGNMENT_ANGLE_HH
36 # include <mln/util/array.hh>
37 # include <mln/math/abs.hh>
38 # include <mln/math/pi.hh>
40 # include <scribo/core/macros.hh>
41 # include <scribo/core/tag/anchor.hh>
42 # include <scribo/core/component_set.hh>
62 alignment_angle(
const component_set<L>& comps,
63 unsigned current_object,
unsigned nbh_object,
67 # ifndef MLN_INCLUDE_ONLY
72 alignment_angle(
const component_set<L>& comps,
73 unsigned current_object,
unsigned nbh_object,
76 mln_trace(
"scribo::filter::internal::alignment_angle");
78 mln_precondition(comps.is_valid());
80 float dr, dc, result = 0;
82 if (nbh_object == current_object)
91 - comps(nbh_object).
bbox().pcenter().row());
93 - comps(nbh_object).
bbox().pcenter().col());
95 result = std::atan(dr / dc);
100 case anchor::MassCenter:
102 dr =
math::abs(comps(current_object).mass_center().row()
103 - comps(nbh_object).mass_center().row());
104 dc =
math::abs(comps(current_object).mass_center().col()
105 - comps(nbh_object).mass_center().col());
107 result = std::atan(dr / dc);
112 case anchor::StrictTopCenter:
113 case anchor::TopStrictLeft:
117 - comps(nbh_object).
bbox().pmin().row());
119 - comps(nbh_object).
bbox().pcenter().col());
121 result = std::atan(dr / dc);
126 case anchor::StrictBottomCenter:
127 case anchor::BottomStrictRight:
131 - comps(nbh_object).
bbox().pmax().row());
133 - comps(nbh_object).
bbox().pcenter().col());
135 result = std::atan(dr / dc);
143 - comps(nbh_object).
bbox().pcenter().row());
145 - comps(nbh_object).
bbox().pmin().col());
147 result = std::atan(dc / dr);
155 - comps(nbh_object).
bbox().pcenter().row());
157 - comps(nbh_object).
bbox().pmax().col());
159 result = std::atan(dc / dr);
164 mln_trace_warning(
"scribo::filter::internal::alignment_angle,"
165 " Invalid anchor value... Aborting computation.");
171 # endif // ! MLN_INCLUDE_ONLY
179 #endif // SCRIBO_FILTER_INTERNAL_ALIGNMENT_ANGLE_HH