
* mln/core/point.hh: Round float values. * tests/geom/rotate.cc: Check precision issues --- milena/ChangeLog | 9 +++++++++ milena/mln/core/point.hh | 32 ++++++++++---------------------- milena/tests/geom/rotate.cc | 22 ++++++++++++---------- 3 files changed, 31 insertions(+), 32 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 3437368..5523182 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,14 @@ 2011-05-17 Guillaume Lazzara <z@lrde.epita.fr> + Fix precision issue with algebra::vec conversion. + + * mln/core/point.hh: Round float values. + + * tests/geom/rotate.cc: Add a test to be sure there is no + precision issues. + +2011-05-17 Guillaume Lazzara <z@lrde.epita.fr> + Add fastest versions for skeleton constrained related algorithms. * mln/morpho/skeleton_constrained.hh, diff --git a/milena/mln/core/point.hh b/milena/mln/core/point.hh index df1fc2c..9cc57b7 100644 --- a/milena/mln/core/point.hh +++ b/milena/mln/core/point.hh @@ -331,16 +331,10 @@ namespace mln mlc_bool(G::dim == n)::check(); unsigned j = 0; - //FIXME: to be improved while adding a conversion routine. - if (dim < 3) - to.hook_coord_() = from; - else - { - for (unsigned i = dim - 2; i < dim; ++i) - to[i] = mln::internal::convert_data<C2>(from[j++]); - for (unsigned i = 2; i < dim; ++i, ++j) - to[i-j] = mln::internal::convert_data<C2>(from[j]); - } + for (unsigned i = dim - 2; i < dim; ++i) + to[i] = mln::internal::convert_data<C2>(from[j++]); + for (unsigned i = 2; i < dim; ++i, ++j) + to[i-j] = mln::internal::convert_data<C2>(from[j]); } template <unsigned n, typename C1, typename G> @@ -352,16 +346,10 @@ namespace mln mlc_bool(G::dim == n)::check(); unsigned j = 0; - //FIXME: to be improved while adding a conversion routine. - if (dim < 3) - to.hook_coord_() = from; - else - { - for (unsigned i = dim - 2; i < dim; ++i) - to[i] = from[j++]; - for (unsigned i = 2; i < dim; ++i, ++j) - to[i-j] = from[j]; - } + for (unsigned i = dim - 2; i < dim; ++i) + to[i] = from[j++]; + for (unsigned i = 2; i < dim; ++i, ++j) + to[i-j] = from[j]; } @@ -566,9 +554,9 @@ namespace mln mln::algebra::vec<G::dim, float> tmp; unsigned j = 0; for (unsigned i = dim - 2; i < dim; ++i) - tmp[j++] = coord_[i]; + tmp[j++] = mln::internal::convert_data<float>(coord_[i]); for (unsigned i = 2; i < dim; ++i, ++j) - tmp[j] = coord_[i-j]; + tmp[j] = mln::internal::convert_data<float>(coord_[i-j]); return tmp; } diff --git a/milena/tests/geom/rotate.cc b/milena/tests/geom/rotate.cc index 0b7a842..bc7519f 100644 --- a/milena/tests/geom/rotate.cc +++ b/milena/tests/geom/rotate.cc @@ -1,5 +1,5 @@ -// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2009, 2010, 2011 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -27,18 +27,17 @@ # include <mln/core/image/image2d.hh> # include <mln/geom/rotate.hh> # include <mln/make/image.hh> -# include <mln/make/box1d.hh> # include <mln/data/compare.hh> int main() { using namespace mln; - bool ref_values[][5] = { { 0, 1, 0, 0, 0 }, - { 0, 1, 1, 0, 0 }, - { 0, 0, 1, 1, 0 }, - { 0, 0, 0, 1, 1 }, - { 0, 0, 0, 0, 1 } }; + bool ref_values[][5] = { { 0, 0, 0, 0, 0 }, + { 0, 1, 0, 0, 0 }, + { 0, 0, 1, 0, 0 }, + { 0, 0, 0, 1, 0 }, + { 0, 0, 0, 0, 0 } }; bool values[][5] = { { 0, 0, 1, 0, 0 }, @@ -49,10 +48,13 @@ int main() image2d<bool> ima = make::image(values); - image2d<bool> ref = make::image(ref_values); - image2d<bool> ima_rot = geom::rotate(ima, 45); + image2d<bool> ima_rot = geom::rotate(ima, 45, false, ima.domain()); mln_assertion(ima_rot == ref); + + ima_rot = geom::rotate(ima_rot, - 45, false, ima.domain()); + + mln_assertion(ima_rot == ima); } -- 1.5.6.5