https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Updtae fun::x2x::rotation.
* mln/fun/x2x/rotation.hh: Fix h_mat construction.
* sandbox/jardonnet/virtual/access.cc: Update in consequencce.
mln/fun/x2x/rotation.hh | 51 ++++++++++++------------------------
sandbox/jardonnet/virtual/access.cc | 10 ++++---
2 files changed, 24 insertions(+), 37 deletions(-)
Index: mln/fun/x2x/rotation.hh
--- mln/fun/x2x/rotation.hh (revision 2266)
+++ mln/fun/x2x/rotation.hh (working copy)
@@ -51,17 +51,17 @@
namespace internal
{
template < unsigned n, typename C >
- algebra::h_mat<n+1, C>
- get_h_mat(const float alpha_, const algebra::vec<3,C>& axis_
+ algebra::h_mat<n, C>
+ get_rot_h_mat(const float alpha_, const algebra::vec<3,C>& axis_)
{
assert(!"get_h_mat : n not implemented");
}
template <typename C >
- algebra::h_mat<4, C>
- get_h_mat(const float alpha_, const algebra::vec<3,C>& axis_)
+ algebra::h_mat<3, C>
+ get_rot_h_mat(const float alpha_, const algebra::vec<3,C>& axis_)
{
- algebra::h_mat<4, C> m_;
+ algebra::h_mat<3, C> m_;
const float cos_a = cos(alpha_);
const float sin_a = sin(alpha_);
@@ -74,17 +74,17 @@
const float uvw2 = u2 + v2 + w2;
m_(0,0) = (u2 + (v2 + w2) * cos_a) / uvw2;
- m_(0,1) = (u*v * (1 - cos_a) - u * math::sqrt(uvw2) * sin_a) / uvw2;
- m_(0,2) = (u*w * (1 - cos_a) + v * math::sqrt(uvw2) * sin_a) / uvw2;
+ m_(0,1) = (u*v * (1 - cos_a) - u * std::sqrt(uvw2) * sin_a) / uvw2;
+ m_(0,2) = (u*w * (1 - cos_a) + v * std::sqrt(uvw2) * sin_a) / uvw2;
m_(0,3) = 0;
- m_(1,0) = (u*v * (1 - cos_a) + w * math::sqrt(uvw2) * sin_a) / uvw2;
+ m_(1,0) = (u*v * (1 - cos_a) + w * std::sqrt(uvw2) * sin_a) / uvw2;
m_(1,1) = (v2 + (u2 + w2) * cos_a) / uvw2;
- m_(1,2) = (v*w * (1 - cos_a) - u * math::sqrt(uvw2) * sin_a) / uvw2;
+ m_(1,2) = (v*w * (1 - cos_a) - u * std::sqrt(uvw2) * sin_a) / uvw2;
m_(1,3) = 0;
- m_(2,0) = (u*w * (1 - cos_a) - v * math::sqrt(uvw2) * sin_a) / uvw2;
- m_(2,1) = (v*w * (1 - cos_a) + u * math::sqrt(uvw2) * sin_a) / uvw2;
+ m_(2,0) = (u*w * (1 - cos_a) - v * std::sqrt(uvw2) * sin_a) / uvw2;
+ m_(2,1) = (v*w * (1 - cos_a) + u * std::sqrt(uvw2) * sin_a) / uvw2;
m_(2,1) = (u2 + (u2 + v2) * cos_a) / uvw2;
m_(2,3) = 0;
@@ -97,23 +97,10 @@
}
template <typename C >
- algebra::h_mat<3, C>
- get_h_mat(const float alpha_, const algebra::vec<2,C>& axis_
+ algebra::h_mat<2, C>
+ get_rot_h_mat(const float alpha_, const algebra::vec<2,C>& axis_)
{
- algebra::h_mat<3, C> m_;
- const float cos_a = cos(alpha_);
- const float sin_a = sin(alpha_);
- const algebra::vec<4,float> vec
- = make::vec(cos_a, -sin_a, sin_a, cos_a);
- unsigned k = 0;
- for (unsigned i = 0; i < 3; ++i)
- for (unsigned j = 0; j < 3; ++j)
- {
- if (j != this->dir_ && i != this->dir_)
- this->m_(i, j) = vec[k++];
- else
- this->m_(i, j) = (i == j);
- }
+ assert(!"not implemented yet");
}
}
@@ -136,7 +123,7 @@
/// Constructor without argument.
rotation();
/// Constructor with grade alpha and a facultative direction (rotation axis).
- rotation(float alpha, algebra::vec<n,float>& axis);
+ rotation(float alpha, const algebra::vec<n,float>& axis);
using super_::operator();
/// Perform the rotation of the given vector.
@@ -165,11 +152,10 @@
template <unsigned n, typename C>
inline
- rotation<n,C>::rotation(float alpha, algebra::vec<n,float>& axis)
+ rotation<n,C>::rotation(float alpha, const algebra::vec<n,float>&
axis)
:alpha_(alpha),
axis_(axis)
{
- mln_precondition(dir == 2 || n == 3);
this->m_ = algebra::h_mat<n,C>::Id;
update();
}
@@ -216,8 +202,6 @@
void
rotation<n,C>::set_dir(unsigned dir)
{
- mln_precondition(dir == 2 || n == 3);
- dir_ = dir;
update();
}
@@ -228,8 +212,7 @@
void
rotation<n,C>::update()
{
- assert(n == 3); // debug
-
+ this->m_ = internal::get_rot_h_mat(alpha_, axis_);
}
# endif // ! MLN_INCLUDE_ONLY
Index: sandbox/jardonnet/virtual/access.cc
--- sandbox/jardonnet/virtual/access.cc (revision 2266)
+++ sandbox/jardonnet/virtual/access.cc (working copy)
@@ -1,5 +1,5 @@
-
#include <iostream>
+
#include "access.hh"
#include <mln/core/image/image2d.hh>
#include <mln/fun/x2x/all.hh>
@@ -11,8 +11,12 @@
using namespace mln;
image2d<int> img(50,50);
point2d p(5,5);
- algebra::vec<2,float> v = make::vec(3,4);
- fun::x2x::translation<2,float> t(v);
+
+
+ //transformation
+ fun::x2x::translation<2,float> t(make::vec(3,4));
+ fun::x2x::rotation<2,float> r(90., make::vec(0,1));
+
interpolation::nearest_neighbor< image2d<int> > nn(img);
debug::iota(img);