Commit f1812256 authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Fix precision issue with algebra::vec conversion.

	* mln/core/point.hh: Round float values.

	* tests/geom/rotate.cc: Check precision issues
parent 2ec107af
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.
......@@ -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;
}
......
// 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);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment