/*******************************************************
 *
 * Author: Takeshi Mita, Shinsaku Hiura, Hirokazu Kato
 *
 *         tmita@inolab.sys.es.osaka-u.ac.jp
 *         shinsaku@sys.es.osaka-u.ac.jp
 *         kato@sys.im.hiroshima-cu.ac.jp
 *
 * Revision: 4.1
 * Date: 01/12/07
 *
*******************************************************/

#include <stdio.h>
#include <math.h>
#include <AR/param.h>


int arParamChangeSize( ARParam *source, int xsize, int ysize, ARParam *newparam )
{
    double  scale;
    int     i;

    newparam->xsize = xsize;
    newparam->ysize = ysize;

    scale = (double)xsize / (double)(source->xsize);
    for( i = 0; i < 4; i++ ) {
        newparam->mat[0][i] = source->mat[0][i] * scale;
        newparam->mat[1][i] = source->mat[1][i] * scale;
        newparam->mat[2][i] = source->mat[2][i];
    }

    newparam->dist_factor[0] = source->dist_factor[0] * scale;
    newparam->dist_factor[1] = source->dist_factor[1] * scale;
    newparam->dist_factor[2] = source->dist_factor[2] / (scale*scale);
    newparam->dist_factor[3] = source->dist_factor[3];

    return 0;
}
