I have a image coordinate system and a tile coordinate system.
I would like to know the Point (u_img / v_img) in the tile coordinate system.
The coordinate system is scaled with sigma. u_img = sigma * u_tile; The shift is given in in the tile coordinate system. The rotation angle between the two coordinate systems is the heading.
what I want is something like (u_tile v_tile) = f( u_img, v_img, sigma, heading, u_trans, v_trans)
I started with:
void image2tile( uint u_img, uint v_img,
int u_trans_tile, int v_trans_tile,
float imgPixelSize, float tilePixelSize,
float heading,
int& u_tile, int& v_tile )
{
float ratio = imgPixelSize / tilePixelSize;
int u_trans = u_img * ratio + u_trans_tile;
int v_trans = v_img * ratio + v_trans_tile;
v_tile = floor( v_trans * cos( heading ) + u_trans * sin ( heading ) );
u_tile = floor( -v_trans * sin( heading ) + u_trans * cos ( heading ) );
}
There are results that seem reasonable, but if I put in u_img = 0 and v_img = 0 I should end up with u_trans_tile and v_trans_tile what actually is NOT the case.
I think the solution could look like this:
1.) transforming the translation in tile coordinates to the image coordinates 2.) after that it was just a normal transformation using the scale factor multiplied with the rotation matrix multiplied with the point vector and added by the new translation vector.
u_trans_tile -> u_trans_img v_trans_tile -> u_trans_img
v_tile = floor( ratio*( v_img * cos( heading ) + u_img * sin ( heading ) + u_trans_img);
u_tile = floor( ratio*(-v_img * sin( heading ) + u_img * cos ( heading ) + v_trans_img);
But actually I couldn't get it work.. ANY SOLUTIONS?
imgPixelSizeandtilePixelSize? If they are integers then your problem is integer division which doesn't yield the expected result. - denahirocos(m_currGpsPos_s.heading)returns the value that you expect? Otherwise your transform looks correct, although the code is somewhat confusing as you switched the order ofv_tileandu_tile. - denahiro