Dimitris Dakopoulos wrote:
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
& transformation ::operator+=(const transformation & 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 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
Here is the fix. This function was working before I changed the interface to all my geometry data objects when I "boostified" the API in 2007. Apparrently when I went through and fixed all the code that was broken by that interface change I didn't properly test this function. Oddly, the comment was also wrong because it didn't match the code. It would have been correct if I applied the inverse of the axis_transformation in (*this), but was redundant to convolve the translation points given that applying the full inverse transformation to the translation point does that already. I tested several combinations of axis_transformation and translation points and everything seems to be working properly with the fixed code below:
template <typename coordinate_type>
inline const transformation