This program is to convert the Normalized coordinates to actual and vice versa
#include<stdio.h>
#include<conio.h>
void main()
{
float xa,ya,xn,yn,xwidth,ywidth;
int maxx=639,maxy=479,choice,minx=0,miny=0;
clrscr();
printf("Enter 1 to enter your co-ordinates in normal form\n 2 to enter in actual form:\n");
scanf("%d",&choice);
switch(choice)
{
case 1:
{
printf("Enter xn:\t");
scanf("%f",&xn);
printf("Enter yn:\t");
scanf("%f",&yn);
xwidth=maxx-minx;
ywidth=maxy-miny;
xa=xn*(maxx-miny)+minx;
ya=yn*(maxy-miny)+miny;
printf("\n\nNormal(%f,%f) to Actual(%f,%f)",xn,yn,xa,ya);
break;
}
case 2:
{
printf("Enter xa :\t");
scanf("%f",&xa);
printf("Enter ya:\t");
scanf("%f",&ya);
xn=(xa-minx)/(maxx-minx);
yn=(ya-minx)/(maxy-miny);
printf("\n\nActual(%f,%f) to Normal(%f,%f)",xa,ya,xn,yn);
break;
}
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
float xa,ya,xn,yn,xwidth,ywidth;
int maxx=639,maxy=479,choice,minx=0,miny=0;
clrscr();
printf("Enter 1 to enter your co-ordinates in normal form\n 2 to enter in actual form:\n");
scanf("%d",&choice);
switch(choice)
{
case 1:
{
printf("Enter xn:\t");
scanf("%f",&xn);
printf("Enter yn:\t");
scanf("%f",&yn);
xwidth=maxx-minx;
ywidth=maxy-miny;
xa=xn*(maxx-miny)+minx;
ya=yn*(maxy-miny)+miny;
printf("\n\nNormal(%f,%f) to Actual(%f,%f)",xn,yn,xa,ya);
break;
}
case 2:
{
printf("Enter xa :\t");
scanf("%f",&xa);
printf("Enter ya:\t");
scanf("%f",&ya);
xn=(xa-minx)/(maxx-minx);
yn=(ya-minx)/(maxy-miny);
printf("\n\nActual(%f,%f) to Normal(%f,%f)",xa,ya,xn,yn);
break;
}
}
getch();
}