You are on page 1of 9

C Programming

22/02/12 17:21

Compartilhar

Denunciar abuso

Prximo blog

Criar um blog

Login

C Programming
SUNDAY, JUNE 7, 2009

clock

C Program For Oblique projection of a 3D object


#include<stdio.h>
#include<math.h>
#include<graphics.h>
main()
{
int x1,y1,x2,y2,gd,gm;
int ymax,a[4][8];
float par[4][4],b[4][8];
int i,j,k,m,n,p;
double L1,phi;

a[0][0] = 100; a[1][0] = 100; a[2][0] = 100;


a[0][1] = 200; a[1][1] = 100; a[2][1] = 100;
a[0][2] = 200; a[1][2] = 200; a[2][2] = 100;
a[0][3] = 100; a[1][3] = 200; a[2][3] = 100;
a[0][4] = 100; a[1][4] = 100; a[2][4] = 200;
a[0][5] = 200; a[1][5] = 100; a[2][5] = 200;
a[0][6] = 200; a[1][6] = 200; a[2][6] = 200;
a[0][7] = 100; a[1][7] = 200; a[2][7] = 200;
phi = (double) (3.14*45.0)/180 ;
L1 = 0.5;
par[0][0] = 1; par[0][1] = 0;
par[0][2] = L1*cos(phi); par[0][3] = 0;
par[1][0] = 0; par[1][1] = 1;
par[1][2] = L1*sin(phi); par[1][3] = 0;
par[2][0] = 0; par[2][1] = 0;
par[2][2] = 0; par[2][3] = 0;
par[3][0] = 0; par[3][1] = 0;
par[3][2] = 0; par[3][3] = 1;

http://code-heaven.blogspot.com/search?updated-max=2009-09-19T04:32:00-07:00&max-results=4

Labels
Animation (1)
Bezier Curve Drawing Algorithm
(1)
Boundary Fill Algorithm (1)
Bresenham Circle Drawing
algorithm (1)
Bresenham line drawing
algorithm (1)
C++ (1)
C++ program to make a pie chart
(1)
Calender (1)
Character Generation (1)
Cohen Sutherland Line Clipping
Algorithm (1)
Digital Differential Analyzer Line
drawing algorithm (1)
Flood Fill Algorithm (1)
Install Turbo C (1)
Liang Barsky Line Clipping
Algorithm (1)
Mid-Point Ellipse Drawing

Pgina 1 de 9

C Programming

m=4; n=4; p=8;

22/02/12 17:21

Algorithm (1)
new folder.exe (1)

for(i=0; i<m; i++)


for(k=0; k<p; k++)
b[i][k] = 0;

Oblique projection (1)

for(i=0; i<m; i++)


for(k=0; k<p; k++)
for(j=0; j<n; j++)
b[i][k] += (float)par[i][j] * a[j][k];

regsvr.exe (1)

detectgraph(&gd,&gm);
initgraph(&gd,&gm, "c:\\tc\\bgi");

The Olympic Symbol (1)

ymax = getmaxy();

Virus removal (1)

Perspective projection (1)


Polygon (1)

Rotation (2)
Scaling (2)
Scan Line (1)

Translation (2)

/*- front plane display -*/


for(j=0;j<3;j++)
{
x1=(int) b[0][j]; y1=(int) b[1][j];
x2=(int) b[0][j+1]; y2=(int) b[1][j+1];
line( x1,ymax-y1,x2,ymax-y2);
}
x1=(int) b[0][3]; y1=(int) b[1][3];
x2=(int) b[0][0]; y2=(int) b[1][0];
line( x1,ymax-y1,x2,ymax-y2);
/*- back plane display -*/
setcolor(11);
for(j=4;j<7;j++)
{
x1=(int) b[0][j]; y1=(int) b[1][j];
x2=(int) b[0][j+1]; y2=(int) b[1][j+1];
line( x1,ymax-y1,x2,ymax-y2);

Advertise on
this site
Powered By
AdBrite

}
x1=(int) b[0][7]; y1=(int) b[1][7];
x2=(int) b[0][4]; y2=(int) b[1][4];
line( x1,ymax-y1,x2,ymax-y2);
setcolor(13);
for(i=0;i<4;i++)
{
x1=(int) b[0][i]; y1=(int) b[1][i];
x2=(int) b[0][4+i]; y2=(int) b[1][4+i];
line( x1,ymax-y1,x2,ymax-y2);
}

Your Ad Here

getch(); getch();
http://code-heaven.blogspot.com/search?updated-max=2009-09-19T04:32:00-07:00&max-results=4

Pgina 2 de 9

C Programming

22/02/12 17:21

About Me

Posted by Angad at 2:17 PM

Angad
MUMBAI,
Maharashtra,
India

Labels: Oblique projection


3 comments

C Program For Perspective projection of 3D Object


#include<stdio.h>
#include<math.h>
#include<graphics.h>
main()
{
int x1,y1,x2,y2,gd,gm;
int ymax,a[4][8];
float par[4][4],b[4][8];
int i,j,k,m,n,p;
int xp, yp, zp, x, y, z;

For any questions or difficulties


feel free to mail me at: angadbhasin@hotmail.com
View my complete profile
Blog Archive
October (2)
September (2)
June (2)
May (15)
Followers
Join this site
with Google Friend Connect

a[0][0] = 100; a[1][0] = 100; a[2][0] = -100;


a[0][1] = 200; a[1][1] = 100; a[2][1] = -100;

Members (45) More

a[0][2] = 200; a[1][2] = 200; a[2][2] = -100;


a[0][3] = 100; a[1][3] = 200; a[2][3] = -100;
a[0][4] = 100; a[1][4] = 100; a[2][4] = -200;
a[0][5] = 200; a[1][5] = 100; a[2][5] = -200;
a[0][6] = 200; a[1][6] = 200; a[2][6] = -200;
a[0][7] = 100; a[1][7] = 200; a[2][7] = -200;

Already a member? Sign in

detectgraph(&gd,&gm);
initgraph(&gd,&gm, "c:\\tc\\bgi");
ymax = getmaxy();
xp = 300; yp = 320; zp = 100;
for(j=0; j<8; j++)
{
x = a[0][j]; y = a[1][j]; z = a[2][j];
b[0][j] = xp - ( (float)( x - xp )/(z - zp)) * (zp);
b[1][j] = yp - ( (float)( y - yp )/(z - zp)) * (zp);
}
/*- front plane display -*/
for(j=0;j<3;j++)
http://code-heaven.blogspot.com/search?updated-max=2009-09-19T04:32:00-07:00&max-results=4

Pgina 3 de 9

C Programming

22/02/12 17:21

{
x1=(int) b[0][j]; y1=(int) b[1][j];
x2=(int) b[0][j+1]; y2=(int) b[1][j+1];
line( x1,ymax-y1,x2,ymax-y2);
}
x1=(int) b[0][3]; y1=(int) b[1][3];
x2=(int) b[0][0]; y2=(int) b[1][0];
line( x1, ymax-y1, x2, ymax-y2);
/*- back plane display -*/
setcolor(11);
for(j=4;j<7;j++)
{
x1=(int) b[0][j]; y1=(int) b[1][j];
x2=(int) b[0][j+1]; y2=(int) b[1][j+1];
line( x1, ymax-y1, x2, ymax-y2);
}
x1=(int) b[0][7]; y1=(int) b[1][7];
x2=(int) b[0][4]; y2=(int) b[1][4];
line( x1, ymax-y1, x2, ymax-y2);
setcolor(7);
for(i=0;i<4;i++)
{
x1=(int) b[0][i]; y1=(int) b[1][i];
x2=(int) b[0][4+i]; y2=(int) b[1][4+i];
line( x1, ymax-y1, x2, ymax-y2);
}

getch(); getch();
}

Posted by Angad at 1:56 PM

Labels: Perspective projection


3 comments

TUESDAY, MAY 12, 2009

Installing TURBO C
All My programs can be compiled using the turbo C complier.The
following tutorial is for installation of Turbo C on your computer.
Step 1> Copy the code for the program to notepad and save the file
with a ".c" extension (for c code) & ".c++" extension (for c++ code).
Step 2> Download the compiler from the above link and save the file.
Step 3> Open the file tc3.zip, find INSTALL.exe from its contents and
double click to open it.
http://code-heaven.blogspot.com/search?updated-max=2009-09-19T04:32:00-07:00&max-results=4

Pgina 4 de 9

C Programming

22/02/12 17:21

Step 4> A new window should open up now, press ENTER.

Step 5> Enter the drive letter you want to install turbo c on and press
ENTER.

http://code-heaven.blogspot.com/search?updated-max=2009-09-19T04:32:00-07:00&max-results=4

Pgina 5 de 9

C Programming

22/02/12 17:21

Step 6> Now on thw following screen type the source path or press
ENTER to select the default path.

Step 7> After this just press F9 on the screen that follows to continue
installation.

http://code-heaven.blogspot.com/search?updated-max=2009-09-19T04:32:00-07:00&max-results=4

Pgina 6 de 9

C Programming

22/02/12 17:21

CONGRACTULATIONS you have set up turbo c on your computer


successfully
Now copy the file you saved in Step 1 to the C:\TC\Bin folder and run
it from turbo c!!
Note:- Inorder to run graphics programs you have to include the
graphics library, for this
run turbo c then select Options->Linker->Libraries and check the
graphics library.

This tutorial is for Installation of Turbo C on windows XP 32-bit, will


post instructions for installation on XP 64-bit and Vista in some
time......
http://code-heaven.blogspot.com/search?updated-max=2009-09-19T04:32:00-07:00&max-results=4

Pgina 7 de 9

C Programming

Posted by Angad at 3:55 AM

22/02/12 17:21

Labels: Install Turbo C


57 comments

Graphics program to Display Animation (Fireworks)


#include<conio.h>
#include<graphics.h>
#include<stdio.h>
#include<math.h>
void main()
{
int gd,gm;
int x,y;
int i,j,kk;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"c:\\tc\\bgi");
setcolor(WHITE);
line(0,400,640,400);
rectangle(300,330,340,400);
rectangle(310,320,330,330);
setcolor(4);
line(319,280,319,398);
line(320,280,320,398);
rectangle(320,280,330,300);
outtextxy(340,280,"PRESS ANY KEY TO IGNITE THE ROCKET");
getch();
for(j=400;j<640;j++)
{
cleardevice();
setcolor(WHITE);
line(0,j,640,j);
rectangle(300,j-70,340,j);
rectangle(310,j-80,330,j-70);
setcolor(RED);
line(319,280,319,400);
line(320,280,320,400);
rectangle(320,280,330,300);
setcolor(YELLOW);
circle(325,300,2);
delay(5);
}
for(i=400;i>340;i--)
{
cleardevice();
setcolor(RED);
http://code-heaven.blogspot.com/search?updated-max=2009-09-19T04:32:00-07:00&max-results=4

Pgina 8 de 9

C Programming

22/02/12 17:21

line(319,i,319,i-120);
line(320,i,320,i-120);
rectangle(320,i-120,330,i-100);
setcolor(YELLOW);
circle(325,i-100,2);
delay(25);
}
cleardevice();
kk=0;
for(j=100;j<350;j++)
{
if(j%20==0)
{
setcolor(kk);
kk=kk+3;
delay(50);
}
ellipse(320,30,0,360,j+100,j+0);
}
for(j=100;j<350;j++)
{
if(j%20==0)
{
setcolor(BLACK);
delay(2);
}
ellipse(320,30,0,360,j+100,j+0);
}
cleardevice();
for(i=0;i<70;i++)
{
setcolor(i);
settextstyle(GOTHIC_FONT,HORIZ_DIR,6);
outtextxy(110,150,"HAPPY NEWYEAR");
delay(90);
}
getch();
}
Labels: Animation
12 comments

Posted by Angad at 12:52 AM


Newer Posts

Home

Older Posts

Subscribe to: Posts (Atom)

http://code-heaven.blogspot.com/search?updated-max=2009-09-19T04:32:00-07:00&max-results=4

Pgina 9 de 9

You might also like