27 #ifndef MLN_MAKE_H_MAT_HH
28 # define MLN_MAKE_H_MAT_HH
34 # include <mln/algebra/h_mat.hh>
35 # include <mln/metal/math/sqrt.hh>
51 template <
typename T,
unsigned N>
52 algebra::h_mat<mlc_sqrt_int(N), T>
h_mat(
const T (&tab)[N]);
62 algebra::h_mat<3, C>
h_mat(
const C& v,
const algebra::quat& q);
64 # ifndef MLN_INCLUDE_ONLY
66 template <
typename T,
unsigned N>
68 algebra::h_mat<mlc_sqrt_int(N), T>
71 enum { n = mlc_sqrt_int(N) };
72 mlc_bool(N == n * n)::check();
73 algebra::h_mat<n,T> tmp;
74 for (
unsigned i = 0; i < N; ++i)
75 tmp(i / n, i % n) = tab[i];
83 h_mat(
const C& v,
const algebra::quat& q)
85 mln_precondition(q.is_unit());
88 algebra::h_mat<3, C> m;
91 x = q.to_vec()[1], x2 = 2*x*x, xw = 2*x*w,
92 y = q.to_vec()[2], y2 = 2*y*y, xy = 2*x*y, yw = 2*y*w,
93 z = q.to_vec()[3], z2 = 2*z*z, xz = 2*x*z, yz = 2*y*z, zw = 2*z*w;
95 C t[9] = {1.f - y2 - z2, xy - zw, xz + yw,
96 xy + zw, 1.f - x2 - z2, yz - xw,
97 xz - yw, yz + xw, 1.f - x2 - y2};
104 # endif // ! MLN_INCLUDE_ONLY
111 #endif // ! MLN_MAKE_H_MAT_HH