This program is to convert the Normalized coordinates to actual and vice versa . This is a part of Mumbai University MCA Colleges CG Programs MCA Computer Graphics.
#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();
}
Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.
#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();
}
Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.
Download
No comments:
Post a Comment