27 #ifndef MLN_FUN_X2X_ROTATION_HH
28 # define MLN_FUN_X2X_ROTATION_HH
44 # include <mln/core/concept/function.hh>
45 # include <mln/fun/internal/x2x_linear_impl.hh>
46 # include <mln/algebra/vec.hh>
47 # include <mln/algebra/mat.hh>
48 # include <mln/algebra/quat.hh>
49 # include <mln/make/h_mat.hh>
51 # include <mln/norm/l2.hh>
66 template <
unsigned n,
typename C >
74 << __FILE__ <<
":" << __LINE__ <<
": error:"
75 <<
" generic mln::fun::x2x::internal::get_rot_h_mat<n, C>"
76 <<
" not implemented."
82 template <
typename C >
86 const C cos_a =
cos(alpha);
87 const C sin_a =
sin(alpha);
91 m(0,0) = cos_a; m(0,1) = -sin_a; m(0,2) = 0;
92 m(1,0) = sin_a; m(1,1) = cos_a; m(1,2) = 0;
93 m(2,0) = 0; m(2,1) = 0; m(2,2) = 1;
99 template <
typename C >
112 const C cos_a =
cos(alpha);
113 const C sin_a =
sin(alpha);
114 const C u = normed_axis[0];
115 const C v = normed_axis[1];
116 const C w = normed_axis[2];
123 m(0,0) = u2 + (1 - u2) * cos_a;
124 m(0,1) = u * v * (1 - cos_a) - w * sin_a;
125 m(0,2) = u * w * (1 - cos_a) + v * sin_a;
128 m(1,0) = u * v * (1 - cos_a) + w * sin_a;
129 m(1,1) = v2 + (1 - v2) * cos_a;
130 m(1,2) = v * w * (1 - cos_a) - u * sin_a;
133 m(2,0) = u * w * (1 - cos_a) - v * sin_a;
134 m(2,1) = v * w * (1 - cos_a) + u * sin_a;
135 m(2,2) = w2 + (1 - w2) * cos_a;
150 template <
unsigned n,
typename C>
183 # ifndef MLN_INCLUDE_ONLY
186 template <
unsigned n,
typename C>
192 template <
unsigned n,
typename C>
200 template <
unsigned n,
typename C>
205 mlc_bool(n == 3)::check();
209 mln_assertion(check_rotation(q));
213 template <
unsigned n,
typename C>
221 template <
unsigned n,
typename C>
226 algebra::mat<n+1,1,C> hmg;
227 algebra::mat<n+1,1,C> tmp;
228 algebra::vec<n,C> res;
229 for (
unsigned i = 0; i < n; ++i)
232 tmp = this->m_ * hmg;
233 mln_assertion(tmp(n,0) == 1);
234 for (
unsigned i = 0; i < n; ++i)
239 template <
unsigned n,
typename C>
250 template <
unsigned n,
typename C>
258 template <
unsigned n,
typename C>
269 p_rot_1 = q.rotate(
p),
270 p_rot_2 = (*this)(
p);
271 return norm::l2(p_rot_1 - p_rot_2) < mln_epsilon(C);
274 # endif // ! MLN_INCLUDE_ONLY
284 #endif // ! MLN_FUN_X2X_ROTATION_HH