manmeet

Upload: manmit-singh-dadra

Post on 08-Apr-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/7/2019 MANMEET

    1/10

    Assignment 4

    2011

    CSE 455

    COMPUTER GRAPHICS

    SUBMITTED BY:

    MANMEET SINGH

    RA1805A24

    SUBMITTED TO:

    MR NAVNEET MALIK

    DEPTT OF CSE

  • 8/7/2019 MANMEET

    2/10

    PART-AQ1.Aplly text clipping with all methods for the following diagram.

    Ans:Text clipping are done in 3 ways which are as follows:

    1)string based clipping: the whole string is cut out or clipped off from the screen .

    2) character based clipping: an alphabet or a character is clipped off from theclipping window.

    3) component based clipping: an alphabet , a letter is considered as component and

    which ever portion is required is clipped off from the window.

    Character based clipping

    String based clipping

    INDIA IS MY

    COUNTRY

    INDIA IS MY COUNTRYINDIA IS MY

    COUNTR Y INDIA

    IS M

    INDIA IS MY

    INDIA IS MY

    COUNTRY

  • 8/7/2019 MANMEET

    3/10

    Component based clipping

    Q2.For the following diagram which clipping method do we use, and apply the

    clipping for the following polygon.

    AFTER CLIPPING :-

    FOR THE GIVEN CONDITION WE CAN USE SUTHERLAND HODGMAN BECAUSE THE

    DIAGRAM IS THE CONVEX FIGURE WHICH DONT HAVE MANY CURVES SO IT WILL BE

    FEASIBLE TO USE THE SUTHERLAND HODGMAN

    PART-B

    Q4. Write a program for shear an object with respect to any of three coordinateaxes,using input values for shearing perameters.

    Ans:

    COUNTR Y INDIA

    IS M

    INDIA IS MY

  • 8/7/2019 MANMEET

    4/10

    A PROGRAM :

    #include

    #include

    #include

    #include

    int ch,x,y,az,i,w,ch1,ch2,xa,ya,ra,a[10],b[10],da,db;

    float x1,y1,az1,w1,dx,dy,theta,x1s,y1s,sx,sy,a1[10],b1[10];

    void main()

    {

    int gm ,gr;

    clrscr();

    detectgraph(&gm,&gr);

    initgraph(&gm,&gr,"d:\\tc\\BGI");

    printf("Enter the upper left corner of the rectangle:\n");

    scanf("%d%d",&x,&y);

    printf("Enter the lower right corner of the rectangle:\n");scanf("%d%d",&az,&w);

    rectangle(x,y,az,w);

    da=az-x;

    db=w-y;

    a[0]=x;

    b[0]=y;

    a[1]=x+da;

    b[1]=y;

    a[2]=x+da;

    b[2]=y+db;

    a[3]=x;b[3]=y+db;

    while(1)

    {

    printf("******2D Transformations*******\n");

    printf("1.Translation\n2.Rotation\n3.Scaling\n4.Reflection\n5.Shearing\n6.Exit\nEnter your choice:\n");

    scanf("%d",&ch);

    switch(ch)

    {

    case 1:

    detectgraph(&gm,&gr);

    initgraph(&gm,&gr,"d:\\tc\\BGI");rectangle(x,y,az,w);

    printf("*******Translation*******\n\n");

    printf("Enter the value of shift vector:\n");

    scanf("%f%f",&dx,&dy);

    x1=x+dx;

    y1=y+dy;

    az1=az+dx;

  • 8/7/2019 MANMEET

    5/10

    w1=w+dy;

    rectangle(x1,y1,az1,w1);

    break;

    case 2:

    detectgraph(&gm,&gr);

    initgraph(&gm,&gr,"d:\\tc\\BGI");rectangle(x,y,az,w);

    printf("*******Rotation*******\n\n");

    printf("Enter the value of fixed point and angle of rotation:Enter the value of fixed point and angle of

    rotation:\n");

    scanf("%d%d%d",&xa,&ya,&ra);

    theta=(float)(ra*(3.14/180));

    for(i=0;i

  • 8/7/2019 MANMEET

    6/10

    scanf("%d",&ch1);

    switch(ch1)

    {

    case 1:

    printf("Enter the fixed point\n");

    scanf("%d%d",&xa,&ya);theta=(float)(90*(3.14/180));

    for(i=0;i

  • 8/7/2019 MANMEET

    7/10

    b1[i]=(ya+((-a[i]-xa)*sin(theta)+(-b[i]-ya)*cos(theta)));

    }

    for(i=0;i

  • 8/7/2019 MANMEET

    8/10

    }

    getch();

    }

    Q5. Apply 3d clipping for the following object.

    Window size is (Xmin,Ymin,Zmin)=(3,1,2) (Xmax,Ymax,Zmax)=(12,6,6) object size

    is (Xmin,Ymin,Zmin)=(9,2,3),(Xmax,Ymax,Zmax)=(15,5,5).

    Q6.Differentiate between interior clipping and exterior clipping with example.

    1)interior clipping

    # whatever is to be saved is inside the clip window we only consider the points that

    are inside the window

    Clipping

    window

    Object

  • 8/7/2019 MANMEET

    9/10

  • 8/7/2019 MANMEET

    10/10