Boost logo

Boost Users :

Subject: [Boost-users] [boost::polygon::transform.hpp] Concatenation of transformations fails.
From: Dimitris Dakopoulos (dakopoulos_at_[hidden])
Date: 2011-08-25 10:38:58


Hello to all,

I want to apply to geometrical transformations (in this case
translations) on a point.

Point3D trans1(1,0,0);
Point3D trans2(2,0,0);

Point2D p(100,100);

gtl::transformation<int> T1( trans1 );
gtl::transformation<int> T2( trans2 );

gtl::transform( p, T1 );
gtl::transform( p, T2 );

--- ... and the point's coordinates are (97,100) as expected.

--- When I try to concatenate the transformations:

Point3D trans1(1,0,0);
Point3D trans2(2,0,0);

Point2D p(100,100);

gtl::transformation<int> T1( trans1 );
gtl::transformation<int> T2( trans2 );

gtl::transform( p, T1 + T2 );

--- ... and I get random numbers.

I checked the boost/polygon/detail/transform_detail.hpp

 template <typename coordinate_type>
 inline const transformation<coordinate_type>&
transformation<coordinate_type>::operator+=(const
transformation<coordinate_type>& tr){
   //apply the inverse transformation of this to the translation point of that
   //and convolve it with this translation point
   coordinate_type x, y, z;
   transformation<coordinate_type> inv = inverse();
   inv.transform(x, y, z);
   p_.set(HORIZONTAL, p_.get(HORIZONTAL) + x);
   p_.set(VERTICAL, p_.get(VERTICAL) + y);
   p_.set(PROXIMAL, p_.get(PROXIMAL) + z);
   //concatenate axis transforms
   atr_ += tr.atr_;
   return *this;
 }

... and I noticed that the coordinate_type x, y, z; is not initialized
and then the transformation is applied: inv.transform(x,y,z); which of
course results to something random.

Any ideas?

Thank you for checking.

Dimitris


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net