| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 401 人关注过本帖
标题:新人求助,快疯了,求大神
只看楼主 加入收藏
bushixiaobai
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2014-7-7
结帖率:0
收藏
已结贴  问题点数:20 回复次数:3 
新人求助,快疯了,求大神
请原谅我把全部都贴上来,调试之后26行m之前差一个;  
没招了,求大神帮忙

#include"graphics.h"                          /*调用图形库函数*/
#include"math.h"                               /*调用数学函数*/
#include"stdio.h"                             /*调用标准I/O函数*/
#define PI 3.141596   
 #include <conio.h>
#define T PI/180
#define NN 36
#define DT PI/NN
#define DIST 0.8
#define R 190
static int n=1;
float t[3];
float s[3][3];
void trans(float t[3],double s[][3])
{
 s[0][0]=cos(t[1])*cos(t[2]); s[0][1]=cos(t[1])*sin(t[2]);
 s[0][2]=-sin(t[1]);
 s[1][0]=sin(t[0])*sin(t[1])*cos(t[2])-cos(t[0])*sin(t[2]);
 s[1][1]=sin(t[0])*sin(t[1])*sin(t[2])+cos(t[0])*cos(t[2]);
 s[1][2]=sin(t[0])*cos(t[1]);
 s[2][0]=cos(t[0])*sin(t[1])*cos(t[2])+sin(t[0])*sin(t[2]);
 s[2][1]=cos(t[0])*sin(t[0])*sin(t[2])-sin(t[0])*cos(t[2]);
 s[2][2]=cos(t[0])*cos(t[1]);
}
void draw(float** m,float da,float db)
float m[3][3],da,db;
 {     
 float f[3],f0 , x0,y0,x1,y1,x2,y2;
    f[0]=R*sin(da)*cos(db); f[1]=R*sin(da)*sin(db);
 f[2]=R*cos(da);
    f0=f[0]*m[0][2]+f[1]*m[1][2]+f[2]*m[2][2];
 if(f0<=0) n=1;
    else
 {
 x0=300.0;y0=165.0;
  x2=(m[0][0]*f[0]+m[1][0]*f[1]+m[2][0]*f[2])+x0;
  y2=(m[0][1]*f[0]+m[1][1]*f[1]+m[2][1]*f[2])*DIST+y0;
  if(n==1) {n=2;x1=x2;y1=y2;}
  else
  {
 line(x1,y1,x2,y2);
   x1=x2;y1=y2;
  }  
 }  
 } main()                                       /*主函数*/
 {
   float i,x,y; float d[3],r[3][3],ta,tb;
 char k;                             /*定义单精度浮点型变量i,x,y*/
   int gdriver=DETECT,gmode=VGAMED,a=1,p=1;             /*定义整型变量gdriver,gmode*/
   initgraph(&gdriver,&gmode,"d:\\tc");     /*定义变量后,初始化图形系统*/
   cleardevice();
   setbkcolor(a);                            /*背景颜色*/
   printf("\n");
   printf("\n");                             /*C 语言图形函数*/
   printf("\n");
   printf(" the following math functions were used in the main function.\n");
   printf("  setbkcolor(int color);\n");     /*  背景颜色*/
   printf(" setcolor(int color);\n");        /*  画笔颜色*/
   printf(" putpexel(x,y,color);\n");        /* 画像素点*/
   printf(" line(x1,y1,x2,y2)\n");           /* 直线函数*/
   printf(" rectangle(xl,yt,xr,yb)\n");;    /* 矩形函数*/
   printf(" arc(x,y,as,ae,r)\n");           /*   圆弧函数*/
   printf(" circle(x,y,r)\n");              /*圆形函数*/
   printf(" ellipse(x,y,as,ae,rx,ry)\n");     /*  椭圆函数*/
   printf("\n");
   printf("\n");                           /* 按任意键开始演示*/
   setcolor(2);
   setlinestyle(0,0,3);
   rectangle(4,4,635,475);                  /*绘制矩形框*/
   getch();
   cleardevice();
   printf("\n");                           /* 模拟手工画图*/
   printf("\n");                          /*  函数曲线图形*/
   setcolor(3);
   setlinestyle(3,3,3);
   rectangle(4,4,635,475);               /*绘制图纸边框*/
   for (i=0;i<=2*PI;i+=PI/99999)
     {
    putpixel(40*i,170-21*i*sin(1.6*i),2);    putpixel(40.3*i,170-22*i*sin(1.6*i),3);
    putpixel(40.6*i,170-23*i*sin(1.6*i),10);
     }   do{
for(i=0;i<=361;i+=1)            
 {
 k=kbhit();
  if(k!=0)break;
  setactivepage(p);
  d[0]=i*T;
  cleardevice();
        trans(d,r);
   for(tb=0.0;tb<PI;tb+=DT)
   {   
n=1;
          for(ta=0.0;ta<2.1*PI;ta+=DT) draw(r,ta,tb);}
          for(ta=0.0;ta<PI;ta+=DT)
    {   
    n=1;
    for(tb=0.0;tb<2.1*PI;tb+=DT) draw(r,ta,tb);
    }
         setvisualpage(p);delay(150);p=1-p;  
  }
 } while(k==0);  
   setlinestyle(0,0,1);
   setfillstyle(1,12);
   fillellipse(320,60,25,25);                    /*绘制太阳*/
   for (x=280;x>=250;x-=0.0001)
    {
    putpixel(x,60,12);                          /*绘制阳光线*/
    }
   for (x=360;x>=390;x+=0.0001)
    {
    putpixel(x,60,12);                        /*绘制阳光线*/
    }
   for (y=24;y>=12;y-=0.0001)
    {
    putpixel(320,y,12);                       /*绘制阳光线*/
    }
   for (y=96;y<=108;y+=0.0001)
    {
    putpixel(320,y,12);                        /*绘制阳光线*/
    }
   setlinestyle(3,0,1);
   setcolor(12);
   for (i=0;i<=2*PI;i+=PI/12)                   /*绘制阳光线*/
    {
       line(320+40*cos(i),60-36*sin(i),320+70*cos(i),60-48*sin(i));
       for (x=0;x<=55555;x+=0.1)
      {
           y=y+x;                                /*延时控制*/
       }
     } for (i=0;i<=2*PI;i+=PI/99999)               /*绘制花朵*/
     {
   putpixel(118-15*cos(4*i)*cos(i),160-15*cos(4*i)*sin(i),14);
   putpixel(118-25*cos(4*i)*cos(i),160-25*cos(4*i)*sin(i),13);
   putpixel(118-35*cos(4*i)*cos(i),160-35*cos(4*i)*sin(i),10);
     }
   for (i=0;i<=PI;i+=PI/99999)
     {
    putpixel(320-315*cos(i),360-95*sin(i),11);         /*绘制拱桥*/
    putpixel(320-315*cos(i),360-96*sin(i),11);         /*绘制拱桥*/
    putpixel(320-315*cos(i),360-97*sin(i),11);        /*绘制拱桥*/
     }
   for (a=70;a<=570;a+=50)
     {
   for (i=0;i<=PI;i+=PI/9999)
     {
    putpixel(a-25*cos(i),360-40*sin(i),11);                                                                                                                                                                                  /*绘制桥*/
     }
     }
   for (x=0;x<=640;x+=0.001)
     {
    putpixel(8*x,380-8*sin(x),9);                /*绘制曲线水流*/
     }
   for (x=0;x<=600;x+=0.001)
     {
    putpixel(10*x,405-10*sin(x),9);               /*绘制曲线水流*/
     }
   for (x=0;x<=560;x+=0.001)
     {
    putpixel(12*x,430-12*sin(x),9);             /*绘制曲线水流*/
     }
   for(x=60;x<=80;x+=0.01)
     {
    ellipse(270,360,180 ,0,160-x,25);
     }
   for (x=0;x<=520;x+=0.001)
    {
    putpixel(8*x,455-8*sin(x),9);                /*绘制曲线水流*/
    }
   setcolor(13);
   setlinestyle(0,0,1);
   rectangle(460,100,620,200);                   /*绘制地图框(矩形)*/
   setcolor(11);
   setlinestyle(0,0,3);
   ellipse(540,150,0,360,77,48);                /*绘制地球(椭圆)*/
   setcolor(10); setlinestyle(0,0,1);
   circle(540,150,46);                           /*绘制经线(圆形)*/
   ellipse(540,100,210,330,45,16);               /*绘制北极圈(椭圆弧)*/
   ellipse(540,200,30,150,45,16);                /*绘制南极圈(椭圆弧)*/
   setcolor(14);
   setlinestyle(3,0,1);
   line(460,150,620,150);                           /*绘制赤道(水平线)*/
   line(540,100,540,200);                           /*绘制经线(垂直线)*/
   setcolor(11); setlinestyle(0,0,1);
   for (i=0;i<=2*PI;i+=PI/300)
     {
   putpixel(590-35*cos(i),50-35*sin(i),11);          /*绘制0.1秒刻度*/
     }
   setcolor(14);
   setlinestyle(0,0,1);
   circle(590,50,2);                                  /*绘制中心轴*/
   setcolor(13);
   setlinestyle(0,0,3);
   for (i=0;i<=2*PI;i+=PI/6)
     {
       line(590+25*sin(i),50-25*cos(i),590+30*sin(i),50-30*cos(i));         /*绘制小时*/
   for (x=0;x<=5555;x+=0.001)
     {
       y=y+x;                                         /*延时控制*/
     }
     }setbkcolor(BLACK);setcolor(GREEN);
    d[1]=30*T; d[2]=10*T; getch();
   closegraph();
}
}
搜索更多相关主题的帖子: include 数学 include 数学 
2014-07-07 22:21
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:7 
目测这段代码大概在Tc下运行
没啥研究价值

DO IT YOURSELF !
2014-07-08 00:13
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:7 
你这个是C程序,给你转到C版。

授人以渔,不授人以鱼。
2014-07-08 11:36
pauljames
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:千里冰封
威 望:9
帖 子:1555
专家分:10000
注 册:2011-5-8
收藏
得分:7 
先明确下你的目的吧

经常不在线不能及时回复短消息,如有c/单片机/运动控制/数据采集等方面的项目难题可加qq1921826084。
2014-07-09 06:15
快速回复:新人求助,快疯了,求大神
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023478 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved