How to know the benefits of Easy Learning Basic 2D transformations C Language programming

 “On this page you will find about the benefits of  Easy Learning circle Basic 2D transformations C Language programming Basic 2D transformations C Language programming  a major role in IT department and in the Computer professional . We will explain why easily Easy Learning  Basic 2D transformations C Language programming  using DDA Algorithm is important, how to Basic 2D transformations C Language programming  and how to learn it if you're unfamiliar with Basic 2D transformations C Language programming. "

What is Basic 2D transformations C Language programming and why is it important? 

Do not worry if you have any doest not know to computer knowledge while getting job and go to IT field. It will be more effective if we use the tips mentioned. It will be more effective if we use the tips mentioned. The number of sizes to use in the notes is specifically given.

Basic 2D transformations C Language programming and Reminders:

You mentioned similar tips on another page about Basic 2D transformations C Language programming.

How to know the benefits of easily Easy Learning  circle Drawing using Bresenbarri's circle Algorithm:

Aim:

To write a program to perform the Basic 2D transformations C Language programming  like translation rotation and scaling using transformation equation in C.

Algorithm:

1.start the program 

2. obtion the coordinates of the line xa,ya,xb,yb 

3.Get the translation factors tx,ty, rotation angle a and scalling factors sx,sy.

4. find the translation coordinates by applaying the angle as x’=x+y and y’=y+ty

5.Get the rotation coordinates by applaying the angle as x=abs(xa-yb) cos a-abs(ya-yb) sin a y’=abs(xa-xb)sina +abs(ya-yb) cos a

6.scalling is applied as 

X’= x*sx

Y’=y*sy

7.Draw the transformed line with the new coordinates (x’,y’)

8.stop the program 

Basic 2D transformation 

Program:

#include <stdio.h>

#include<conio.h>

#include <graphics.h>

#include<math.h>

void getdata();

Int x1,y1,z1,x2,y2;

Void main()

{

Int gd=DETECT,gm;

Int x3,x4,y3,y4,tx,ty,ch;

Float sx,sy,a,t;

Initgraph(gd,&gm,””);

clrscr();

setcolor(1);

do

{

Printf(“1.Translation\t2.scaling\t3.Roatation\t4.Exit\nEnter your choice:”);

scanf(“%d”,&ch);

switch(ch)

{

case 1: 

getdata();


printf(“enter the translation factor in x-axis:”);

scanf(“%d”,&tx);

printf(“enter the transalation factor in y-axis:”);

scanf(“%d”,&ty);

x3=x1+tx;

x4=x2+tx;

y3=y1+ty;

y4=y2+ty;

line(x3,y3,x4,y4);

getch();

cleardevice();

break;

case 2;

getdata();

printf(“Enter the scaling factor in x-axis:”);

scanf(“%f’,&sx);

printf(“Enter the scaling factor in y-axis:”);

scanf(“%f’,&sy);

x3=x1*sx;

x4=x2*sx;

y3=y1*sy;

y4=y2*sy;

line(x3,y3,x4,y4);

getch();

cleardevice();

break;

case 3:

getdata();

printf(“Enter the rotation angle:”);

scanf(“%f”,&a);

t=a*(3.14159/180);

x4=x1+abs(x2-x1)*cos(t)-abs(y2-y1)*sin(t);

scanf(“%f”,&a);

t=a*(3.14159/180);

x4=x1+abs(x2-x1)*cos(t)-abs(y2-y1)*sin(t);

y4=y1+abs(x2-x1)*sin(t)+abs(y2-y1)*cos(t);

line(x1,y1,x4,y4);

getch();

cleardevice();

break;

case 4;

exit(0);

breakl;

}

}

while(ch<4);

getch();

closegraph();

}

void getdata()

{

cleardevice();

printf(“Enter the x1 value:”);

scanf(“%d”,&x1);

printf(“Enter the y1 value:”);

scanf(“%D”,&Y1);

Printf(“Enter the x2 value:”);

scanf(“%d”,&x2);

Printf(“Enter the y2 value:”);

scanf(“%d”,&y2);

line(x1,y1,x2,y2);

}

Output:

1. Translation 2.scaling 3.Rotation 4.Exit 

  Enter the choice: 1

 Enter the x1 value:100

Enter the y1 value:100

Enter the x2 value: 200

Enter the y2 value:200

Enter the translation factor in x-axis : 25 25

Enter the tranlation factor in y-axis:0 0




 01.Rranslation 2.Scaling 3.Rotation 4.Exit 

Enter the choice: 2

Enter the x1 value:100

Enter the y1 value:100

Enter the x2 value:200

Enter the y2 value:200

Enter the scaling factor in x-axis:1

Enter the scaling factor in y-sxis:2




1.Translation 2.Scaling 3.Rotation 4.Exit 

Enter the choice:3

Enter the x1 value:100

Enter the y1 value:100

Enter the x2 value:200

Enter the y2 value:200

Enter the rotation angle:45



2D Transformation (Reflection And Shearing)

Program:

#include<stdio.h>

#iclude<conio.h>

#include<graphics.h>

Void reflection();

Void shearing();

Void main();

{

Int gd =DETECT, gm,ch;

Initgraph(&gd,&gm,””);

do

{

cleardevice();

Printf(“1.Reflection\t2.Shearing\t3.Exit\nEnter your choice:”);

scanf(“%d”,&ch);

swirch(ch)

{

case 1:

cleardevice();

reflection();

break;

case 2;

cleardevice();

shearing();

break;

case 3;

exit(0);

break;

}

}

While(Ch<3);

Gerch();

Closegraph();

}

Void Reflection()

{

int xa,ya,yb,xc,yc,x1,y1,x2,y2,x3,y3,ch;

printf(“enter the xa&ya value:”);

scanf(‘’%d\n%d”,&xa,&ya);

printf(“enter the xb&yb value:”);

scanf(“%d\n%d”,&xb,&yb);

printf(“enter the xc&yc value:”);

scanf(“%d\n%d”,&xc,&yc);

line(xa,ya,xb,yb);

line(xb,yb,xc,yc);

line(xc,yc,xa,ya);

do

{

printf(“1.about x-axis\t2.about y-axis\t3.about/t4.ecxit\nenter the choice:”);

scanf(“%d”,&ch);

switch (ch)

{

case 1:

cleardevice();

line(xa,ya,xb,yb);

line(xb,yb,xc,yc);

line(xc,yc,xa,ya);

y1=ya+2*(gatmaxy()\2-ya);

y2=yb+2*(gatmaxy()\2-yb);

y3=yc+2*(gatmaxy()\2-yc);

line(xa,y1,xb,y2);

line(xb,y2,xc,y3);

line(xc,y3,xa,y1);

break;

case 2:

cleardevice();

line(xa,ya,xb,yb);

line(xb,yb,xc,yc);

line(xc,yc,xa,ya);

case 3:

cleardevice();

line(xa,ya,xb,yb);

line(xb,yb,xc,yc);

line(xc,yc,xc,yc);

x1=xa+2*(getmaxy()/2-xa);

x2=xb+2*(getmaxy()/2-xb);

x3=xc+2*(getmaxy()/2-xc);

y1=ya+2*(getmaxy()/2-ya);

y2=yb+2*(getmaxy()/2-yb);

y3=yc+2*(getmaxy()/2-yc);

line(x1,y2,x2,y2);

line(x2,y2,x3,y3);

line(x3,y3,x1,y1);

break;

case 4;

break;

}

}

while(ch<4);

}

void shearing()

{

Float xa,xb,xc,ya,yb,yc,yd,xe,xf,ye,yf,shx,shy;

Int ch;

void rect();

printf(“enter the xa&ya value:”);

scanf(“%f\n%f”,&xa,&ya);

printf(“enter the xb&yb value:”);

scanf(“%f\n%f”,&xb,&yb);

printf(“enter the xc&yc values:”);

scanf(“%f\n%f”,&yc);

printf(“enter the xd&yd value:”);

scanf(“%f\n%f”,&xd, &yd);

do

{

printf(“1.about x-axis\t2.about y-axis\t3.about both\t4.exit\nenter the choice:”);

scanf(“%d”,&ch);

switch(ch)

{

case 1:

cleardevice();

line(xa,ya,xb,yb);

line(xb,yb,xc,yc);

line(xd,yd,xa,ya);

printf(“enter the shearing factor for x:”);

scanf(“%f”,&shx);

xe=xc+shx;

xf=xd+shx;

line(xa,ya,xb,yb);

line(xb,yb,xe,yc);

line(xe,yc,xf,yd);

line(xf,yd,xa,ya);

break;

case 2:

cleardevice();

printf(“enter the shearing factor for y:”);

scanf(“%f”,&shy);

ye=yb+shy;

yf=yc+shy;

line(xa,ya,xb,ye);

line(xb,ye,xc,yf);

line(xc,yf,xd,yd);

line(xd,yd,xa,ya);

break;

case 3:

cleardevice();

printf(“Enter the shearing factor for x:”);

Scanf(“%f”,&shx);

printf(“enter the shearing factor for y:”);

scanf(“%f’,&shy);

xe=xc+shx;

Xf=xd+shx;

ye=yb+shy;

ye=yb+shy;

yf=yc+shy;

line(xa,ya,xb,ye);

line(xb,ye,xe,yf);

line(xe,yf, xf,yd);

line(xf,yd,xa,ya);

break;

case 4:

break;

}

}

while(ch<4);

cleardevice();

}



Output :

1.Reflection 2.Shearing 3.Exit 

Enter the choice:1

Enter the xa&ya value: 200 100 

Enter the xb&yb value:200 200 

Enter the xc&yc value:100 200

1.About x-axis 2.About y-axis 3.About both 4.Exit 

Enter the choice:1











1.About x-axis 2.About y-axis 3.About both 4.Exit 







1.About x-axis 2.About y-axis 3.About both 4.Exit 

     






1.About x-axis 2.About y-axis 3.About both 4.Exit 

Enter the choice:4

1.Reflection 2.Shearing 3.Exit 

Enter the xa&ya value: 200 200

Enter the xb&yb value:300 200

Enter the xc&yc value:300 300

Enter the xd&yd value:200 300

1.About x-axis 2.About y-axis 3.About both 4.Exit 

Enter the choice: 1

Enter the shearing factor for x:50











1.About x-axis 2.About y

Enter the choice :2

Enter the shearing factor for y:50










1.About x-axis 2. About y-axis   3.About both 4.Exit 

Enter the choice:3

Enter the shearing factor for x:50

Enter the shearing factor for y:50











Enter the choice: 4

Enter the choice: 3


Comments