Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MurageKibicho/796af65df7e2f14c006b39ef99ccead6 to your computer and use it in GitHub Desktop.
Save MurageKibicho/796af65df7e2f14c006b39ef99ccead6 to your computer and use it in GitHub Desktop.
Affine test
#include <stdio.h>
#include <math.h>
void FindResult(int *X, int *Y,int *XR, int *YR,double *affineMap, int XYLength)
{
for(int i = 0; i < XYLength; i++)
{
XR[i] = (int)round(affineMap[0] * (double) X[i] + affineMap[1] * (double)Y[i] + affineMap[4]);
YR[i] = (int)round(affineMap[2] * (double) X[i] + affineMap[3] * (double)Y[i] + affineMap[5]);
printf("(%d,%d) to (%d,%d)\n",X[i], Y[i],XR[i],YR[i]);
}
}
int main()
{
double map[6] =
{
1.0000,-1.0000,0.5000,-1.0000,512.0000,256.0000
};
int X[] = {78, 174, -168};
int Y[] = {230,-108, 97};
int XR[3] = {0};
int YR[3] = {0};
FindResult(X,Y, XR,YR, map, 3);
for(int i = 0; i < 3; i++)
{
printf("(%3d ,%3d)\n", XR[i], YR[i]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment