complete construction, environmental and economics information of biomass com...
Window to viewprt
1. EXPERIMENT
Objective: - Write a program for window to viewport transformation
Software Used: - Turbo c
Theory: - A viewport is a polygon viewing region in computer graphics. In computer
graphics theory, there are two region-like notions of relevance when rendering some objects to
an image. In textbook terminology, the world coordinate window is the area of interest (meaning
what the user wants to visualize) in some application-specific coordinates, e.g. miles, centimeters
etc. In contrast, the viewport is an area (typically rectangular) expressed in rendering-device-
specific coordinates, e.g. pixels for screen coordinates, in which the objects of interest are going
to be rendered. Clipping to the world-coordinates window is usually applied to the objects before
they are passed through the window-to-viewport transformation. For a 2D object, the latter
transformation is simply a combination of translation and scaling, the latter not necessarily
uniform.[1] An analogy of this transformation process based on traditional photography notions is
to equate the world-clipping window with the camera settings and the variously sized prints that
can be obtained from the resulting film image as possible viewports.
Program :
#include"stdio.h"
#include"conio.h"
#include"graphics.h"
#include"stdlib.h"
void main()
{
float xwmin,xwmax,ywmax,ywmin;
float xvmin,xvmax,yvmax,yvmin;
float x[10],y[10],yv,xv,sx,sy;
int gd=DETECT,gm,i;
clrscr();
printf("n enter window port coordinates:n(xwmin,ywmin,xwmax,ywmax):");
scanf("%f%f%f%f",&xwmin,&ywmin,&xwmax,&ywmax);
printf("n enter view port coordinates:n(xvmin,yvmin,xvmax,yvmax):");
scanf("%f%f%f%f",&xvmin,&yvmin,&xvmax,&yvmax);
printf("n enter vertices for triangle:");
for(i=0;i < 3;i++)
{
printf("n enter(x%d,y%d):",i,i);
scanf("%f%f",&x[i],&y[i]);
}
sx=((xvmax-xvmin)/(xwmax-xwmin));