PLZ HELP!

I

IN

This program have some problem, plz help me debug this bug)

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <dos.h>
#define dX 640/2
#define dY 480/2
#define koeff dX/10
#define dZ 2
#define c 8
#define str 5
#define stl 4
#define elA 4
#define elB 2
#define Sx 1.5
#define Sy 1.5
#define Sz 1
#define TIME 50
void Show(int a);
void ellips_pol1(float Kx1,float Ky1,float Kx2,float Ky2,float elX);
void ellips_otr1(float Kx1,float Ky1,float Kx2,float Ky2,float elX);
void func_matrix(float a[str][stl],float b[4][4],float rez[str][stl]);
float perevodX(float x);
float perevodY(float y);
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
int xmax, ymax, i, j;
float x, y ,z , X, Y, tx, ty;
float MAIN[5][4]={{0,0,0,1},{7,0,0,1},{9,3,0,1},{2,3,0,1},{5,2,3,1}};
float PERENOS[4][4]={{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,dZ,1}};
float Q[4][4]={{1,0,0,0},{0,1,0,0},{0,0,0,0},{0,0,0,1}};
float POV[4][4]={{0,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}};
float MAS[4][4]={{Sx,0,0,0},{0,Sy,0,0},{0,0,Sz,0},{0,0,0,1}};
float RESULT_1[4][4],RESULT_2[4][4],RESULT_3[4][4],RESULT_T[4][4];
float IZOMx[5]={0,-3,1,3,1},IZOMy[5]={0,-2.3,-2.3,0,3};
float ugA=55;
char knopka=' ';

ugA=ugA/180*M_PI;
POV[0][0]=cos(ugA);
POV[0][1]=sin(ugA);
POV[1][0]=-sin(ugA);
POV[1][1]=cos(ugA);
Q[2][3]=-1*powl(c,-1);
initgraph(&gdriver, &gmode, "D:\\BORLANDC\\BGI");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
xmax = getmaxx();
ymax = getmaxy();
Show(1);
setcolor(RED);
ellips_pol1(IZOMx[0],IZOMy[0]-elB,IZOMx[1],IZOMy[1]-elB,x);
ellips_pol1(IZOMx[1],IZOMy[1]-elB,IZOMx[2],IZOMy[2]-elB,x);
ellips_pol1(IZOMx[2],IZOMy[2]-elB,IZOMx[3],IZOMy[3]-elB,x);
ellips_pol1(IZOMx[3],IZOMy[3]-elB,IZOMx[0],IZOMy[0]-elB,x);
ellips_pol1(IZOMx[3],IZOMy[3]-elB,IZOMx[4],IZOMy[4]-elB,x);
ellips_pol1(IZOMx[2],IZOMy[2]-elB,IZOMx[4],IZOMy[4]-elB,x);
ellips_pol1(IZOMx[1],IZOMy[1]-elB,IZOMx[4],IZOMy[4]-elB,x);
ellips_pol1(IZOMx[0],IZOMy[0]-elB,IZOMx[4],IZOMy[4]-elB,x);
printf("Ishodnaja figura\n\nstobi na4at` dvizenie\npo ellipsu nazmite
'n'\n");
while(knopka!='n')knopka=getch();knopka=' ';
for(x=0;x<elA+1;x++)
{
Show(1);
ellips_pol1(IZOMx[0],IZOMy[0]-elB,IZOMx[1],IZOMy[1]-elB,x);
ellips_pol1(IZOMx[1],IZOMy[1]-elB,IZOMx[2],IZOMy[2]-elB,x);
ellips_pol1(IZOMx[2],IZOMy[2]-elB,IZOMx[3],IZOMy[3]-elB,x);
ellips_pol1(IZOMx[3],IZOMy[3]-elB,IZOMx[0],IZOMy[0]-elB,x);
ellips_pol1(IZOMx[3],IZOMy[3]-elB,IZOMx[4],IZOMy[4]-elB,x);
ellips_pol1(IZOMx[2],IZOMy[2]-elB,IZOMx[4],IZOMy[4]-elB,x);
ellips_pol1(IZOMx[1],IZOMy[1]-elB,IZOMx[4],IZOMy[4]-elB,x);
ellips_pol1(IZOMx[0],IZOMy[0]-elB,IZOMx[4],IZOMy[4]-elB,x);

delay(TIME);
cleardevice();
}
for(x=elA-1;x>-elA-1;x--)
{
Show(1);
ellips_otr1(IZOMx[0],IZOMy[0]-elB,IZOMx[1],IZOMy[1]-elB,x);
ellips_otr1(IZOMx[1],IZOMy[1]-elB,IZOMx[2],IZOMy[2]-elB,x);
ellips_otr1(IZOMx[2],IZOMy[2]-elB,IZOMx[3],IZOMy[3]-elB,x);
ellips_otr1(IZOMx[3],IZOMy[3]-elB,IZOMx[0],IZOMy[0]-elB,x);
ellips_otr1(IZOMx[3],IZOMy[3]-elB,IZOMx[4],IZOMy[4]-elB,x);
ellips_otr1(IZOMx[2],IZOMy[2]-elB,IZOMx[4],IZOMy[4]-elB,x);
ellips_otr1(IZOMx[1],IZOMy[1]-elB,IZOMx[4],IZOMy[4]-elB,x);
ellips_otr1(IZOMx[0],IZOMy[0]-elB,IZOMx[4],IZOMy[4]-elB,x);

delay(TIME);
cleardevice();
}
for(x=-elA+1;x<1;x++)
{
Show(1);
ellips_pol1(IZOMx[0],IZOMy[0]-elB,IZOMx[1],IZOMy[1]-elB,x);
ellips_pol1(IZOMx[1],IZOMy[1]-elB,IZOMx[2],IZOMy[2]-elB,x);
ellips_pol1(IZOMx[2],IZOMy[2]-elB,IZOMx[3],IZOMy[3]-elB,x);
ellips_pol1(IZOMx[3],IZOMy[3]-elB,IZOMx[0],IZOMy[0]-elB,x);
ellips_pol1(IZOMx[3],IZOMy[3]-elB,IZOMx[4],IZOMy[4]-elB,x);
ellips_pol1(IZOMx[2],IZOMy[2]-elB,IZOMx[4],IZOMy[4]-elB,x);
ellips_pol1(IZOMx[1],IZOMy[1]-elB,IZOMx[4],IZOMy[4]-elB,x);
ellips_pol1(IZOMx[0],IZOMy[0]-elB,IZOMx[4],IZOMy[4]-elB,x);

delay(TIME);
if(x!=0)
{
cleardevice();
}
}
printf("Stobi perejti k persperkivnoj proekcii,\nnazmite 'n'");
//-----------------------------------
while(knopka!='n')knopka=getch();knopka=' ';
clrscr();setcolor(WHITE);cleardevice();
for(x=31;x<640;x=x+koeff)
{
line(x,0,x,ymax);
}
for(y=14;y<480;y=y+koeff) //y=14
{
line(0,y,xmax,y);
}
setcolor(WHITE);
bar(xmax/2-1, 0, xmax/2+1, ymax);
bar(0, 398, xmax, 400);
//-------------------X----------------X
x=dX-308;y=387; //x=dx-285
outtextxy(x, y, "-9");x=x+32;
outtextxy(x, y, "-8");x=x+32;
outtextxy(x, y, "-7");x=x+32;
outtextxy(x, y, "-6");x=x+32;
outtextxy(x, y, "-5");x=x+32;
outtextxy(x, y, "-4");x=x+32;
outtextxy(x, y, "-3");x=x+32;
outtextxy(x, y, "-2");x=x+32;
outtextxy(x, y, "-1");x=x+32;
//------------------------------------
x=dX+4;y=387;
outtextxy(x, y, " ");x=x+32;
outtextxy(x, y, "1");x=x+32;
outtextxy(x, y, "2");x=x+32;
outtextxy(x, y, "3");x=x+32;
outtextxy(x, y, "4");x=x+32;
outtextxy(x, y, "5");x=x+32;
outtextxy(x, y, "6");x=x+32;
outtextxy(x, y, "7");x=x+32;
outtextxy(x, y, "8");x=x+32;
outtextxy(x, y, "9");x=x+32;
//-------------------Y----------------Y
x=dX+4;y=dY+20;
outtextxy(x, y, "4");y=y+32;
outtextxy(x, y, "3");y=y+32;
outtextxy(x, y, "2");y=y+32;
outtextxy(x, y, "1");y=y+32;
outtextxy(x, y, "0");y=y+32;
outtextxy(x, y, "-1");y=y+32;
outtextxy(x, y, "-2");y=y+32;
//------------------------------------
x=dX+4;y=dY-12;
outtextxy(x, y, "5");y=y-32;
outtextxy(x, y, "6");y=y-32;
outtextxy(x, y, "7");y=y-32;
outtextxy(x, y, "8");y=y-32;
outtextxy(x, y, "9");y=y-32;
outtextxy(x, y, "10");y=y-32;
outtextxy(x, y, "11");y=y-32;
outtextxy(x, y, "12");y=y-32;

func_matrix(MAIN,PERENOS,RESULT_1);
//for(x=0;x<4;x++){for(y=0;y<4;y++){printf("%3.1f
",RESULT_1[x][y]);}printf("\n");}
func_matrix(RESULT_1,POV,RESULT_2);
func_matrix(RESULT_2,MAS,RESULT_T);
func_matrix(RESULT_T,Q,RESULT_3);
RESULT_3[3][3]=RESULT_3[3][3]*2;
for(x=0;x<4;x++)
{
RESULT_3[x][0]=RESULT_3[x][0]/RESULT_3[x][3];
RESULT_3[x][1]=RESULT_3[x][1]/RESULT_3[x][3];
}
//--------------------------------------------to4ki
setcolor(YELLOW);setfillstyle(1,YELLOW);

for(x=0;x<4;x++)
{
RESULT_3[x][0]=perevodX(RESULT_3[x][0]);
RESULT_3[x][1]=perevodY(RESULT_3[x][1]);
fillellipse(RESULT_3[x][0],RESULT_3[x][1],3,3);
}
//--------------------------------------------linii
setcolor(RED);
for(x=0;x<3;x++)
{
line(RESULT_3[x][0],RESULT_3[x][1],RESULT_3[x+1][0],RESULT_3[x+1][1]);
}
line(RESULT_3[x][0],RESULT_3[x][1],perevodX(0),perevodY(0));
line(RESULT_3[2][0],RESULT_3[2][1],perevodX(0),perevodY(0));
line(RESULT_3[3][0],RESULT_3[3][1],RESULT_3[1][0],RESULT_3[1][1]);
getch();
closegraph();
return 0;
}
//------------------------------------------------------------------
void func_matrix(float a[str][stl],float b[4][4],float rez[str][stl])
{
int x,y,z;
float temp[4];
for(x=0;x<str;x++){for(y=0;y<stl;y++){rez[x][y]=0;temp[y]=0;}}
for(x=0;x<str;x++)
{
for(y=0;y<stl;y++)
{
for(z=0;z<stl;z++)
{
temp[z]=a[x][z]*b[z][y];
rez[x][y]=rez[x][y]+temp[z];
}
}
}


}
float perevodX(float x)
{
float X;
X=x*koeff+dX-1;
return X;
}
float perevodY(float y)
{
float Y;
Y=fabs(y*koeff-399);
return Y;
}
void ellips_pol1(float Kx1,float Ky1,float Kx2,float Ky2,float elX)
{
float elY,X,Y;
setcolor(RED);
elY=sqrt(4-elX*elX/4);
circle(perevodX(elX+Kx1),perevodY(elY+Ky1)-160,2);
circle(perevodX(elX+Kx2),perevodY(elY+Ky2)-160,2);
line(perevodX(elX+Kx1),perevodY(elY+Ky1)-160,perevodX(elX+Kx2),perevodY(elY+Ky2)-160);}void ellips_otr1(float Kx1,float Ky1,float Kx2,float Ky2,float elX){float elY,X,Y;setcolor(RED); elY=sqrt(4-elX*elX/4); circle(perevodX(elX+Kx1),perevodY(-elY+Ky1)-160,2); circle(perevodX(elX+Kx2),perevodY(-elY+Ky2)-160,2); line(perevodX(elX+Kx1),perevodY(-elY+Ky1)-160,perevodX(elX+Kx2),perevodY(-elY+Ky2)-160);}void Show(int a){int xmax = getmaxx();int ymax = getmaxy();setcolor(LIGHTGRAY); line(xmax/2,0,xmax/2,ymax/2); line(xmax/2,ymax/2,xmax,ymax/2); line(xmax/2,ymax/2,0,ymax);a=a;}
 
M

mlimber

IN said:
This program have some problem, plz help me debug this bug)

#include <graphics.h>

Non-standard. We don't deal with this here. (See
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9.)
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
Non-standard.

#include <math.h>
#include <dos.h>
Non-standard.

[snip badly formatted code]

We aren't here to do your homework for you or to sift through your
bugs. Learn to use your debugger, and ask a specific question related
to the standard C++ language, if you have one.

Cheers! --M
 
R

red floyd

IN said:
This program have some problem, plz help me debug this bug)
[code with no explanation of the problem redacted]

You have an error on line 42.
 
P

phwashington

red said:
IN said:
This program have some problem, plz help me debug this bug)
[code with no explanation of the problem redacted]

You have an error on line 42.
When I first saw your answer I thought you were being glib/funny. Then
I looked at line 42.
 
O

Old Wolf

red said:
IN said:
This program have some problem, plz help me debug this bug)
[code with no explanation of the problem redacted]

You have an error on line 42.
When I first saw your answer I thought you were being glib/funny. Then
I looked at line 42.

Line 42 appears to be fine:
POV[0][0]=cos(ugA);

Perhaps you're referring to line 41 which uses an undefined symbol
(or, to be more practical, a symbol that some implementations
define in contravention of the C++ standard)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top