编程论坛's Archiver

cdmalcl 发表于 2007-4-30 18:37

[原创]一个方程实现液体下流效果

<P>#include&lt;stdio.h&gt;<BR>#include&lt;math.h&gt;<BR>#include&lt;graphics.h&gt;<BR>#define PI 3.14<BR>int main()<BR>{<BR>    float i ,j ,x ,y;<BR>    int MAXX2 ,MAXY2;<BR>    int gd = DETECT,gm = 0;</P>
<P>    initgraph(&amp;gd,&amp;gm,"");</P>
<P>    MAXX2 = getmaxx()/2;<BR>    MAXY2 = getmaxy()/2;</P>
<P>    setcolor(15);<BR>    setfillstyle(1 ,2);</P>
<P>    for(j = 0;j &lt; MAXY2*2;j+=40)<BR>    {<BR>        rectangle(1 ,j ,i+39 ,j+21);<BR>        for(i = 0;i &lt; MAXX2*2;i+=40)<BR>        {<BR>            rectangle(i ,j+1 ,i+39 ,j+20);<BR>            floodfill(i+3 ,j+3 ,getcolor());<BR>            rectangle(i+20 ,j+21 ,i+59 ,j+40);<BR>            floodfill(i+23 ,j+23 ,getcolor());<BR>        }<BR>        rectangle(21 ,j+21 ,i+59 ,j+41);<BR>        floodfill(3 ,j+23 ,getcolor());<BR>    }</P>
<P>    <FONT color=#ff0000>for(i = -3*PI-1;i &lt; 0;i +=0.005)<BR>    {<BR>        for(j = -4*PI;j &lt; 4*PI;j += 0.01)<BR>        {<BR>            x = cos(i*2+j)*20+j*30;<BR>            y = sin(i-j*2)*20+i*30*sin(i/2)+sin(x/25)*30;</FONT></P>
<P><FONT color=#ff0000>            putpixel(x+MAXX2 ,y+MAXY2 ,4);</FONT></P>
<P><FONT color=#ff0000>            if(kbhit())<BR>             exit(0);<BR>        }<BR>    }<BR></FONT>    getch();<BR>} <BR></P>

奔跑的鸟 发表于 2007-5-1 20:40

8错,很强大[em17]

hutogo007 发表于 2007-5-2 23:31

非等闲之辈能写得出的..

一笔苍穹 发表于 2007-5-3 20:24

很有意思,加个精,希望以后有更多这样的程序帖上来~~

卧龙孔明 发表于 2007-5-4 08:46

[em17]great!

蔡蔡 发表于 2007-5-8 12:50

高手~~~~我无话说~~~~[em33]

china008 发表于 2007-5-12 08:01

牛[em17][em17][em17][em17][em17]

zj860713 发表于 2007-5-24 18:00

楼主,小弟不太理解上面的这段代码是怎么实现那种作图的,画点函数我知道,你能给我点注释吗?<BR>  <FONT color=#ff0000>for(i = -3*PI-1;i &lt; 0;i +=0.005)<BR>    {<BR>        for(j = -4*PI;j &lt; 4*PI;j += 0.01)<BR>        {<BR>            x = cos(i*2+j)*20+j*30;<BR>            y = sin(i-j*2)*20+i*30*sin(i/2)+sin(x/25)*30;</FONT>
<P><FONT color=#ff0000>            putpixel(x+MAXX2 ,y+MAXY2 ,4);</FONT></P>
<P><FONT color=#ff0000>            if(kbhit())<BR>             exit(0);<BR>        }<BR>    }<BR>我的邮箱<a href="http://www.me860713@163.com" target="_blank" >www.me860713@163.com</A></FONT></P>

yang667455 发表于 2007-6-7 19:12

<P>楼主历害.请问你是怎么想到用<BR>for(j = 0;j &lt; MAXY2*2;j+=40)<BR>    {<BR>        rectangle(1 ,j ,i+39 ,j+21);<BR>        for(i = 0;i &lt; MAXX2*2;i+=40)<BR>        {<BR>            rectangle(i ,j+1 ,i+39 ,j+20);<BR>            floodfill(i+3 ,j+3 ,getcolor());<BR>            rectangle(i+20 ,j+21 ,i+59 ,j+40);<BR>            floodfill(i+23 ,j+23 ,getcolor());<BR>        }<BR>        rectangle(21 ,j+21 ,i+59 ,j+41);<BR>        floodfill(3 ,j+23 ,getcolor());<BR>    }<BR>画出背景,而用<BR><BR>for(i = -3*PI-1;i &lt; 0;i +=0.005)<BR>    {<BR>        for(j = -4*PI;j &lt; 4*PI;j += 0.01)<BR>        {<BR>            x = cos(i*2+j)*20+j*30;<BR>            y = sin(i-j*2)*20+i*30*sin(i/2)+sin(x/25)*30;</P>
<P>            putpixel(x+MAXX2 ,y+MAXY2 ,4);</P>
<P>            if(kbhit())<BR>             exit(0);<BR>        }<BR>    }</P>
<P>画出流体的哪?<BR><BR>我就算能想出程序运行的样子,可却不能想出怎么用数学表达式来表现效果.</P>

wrrlcmnyj 发表于 2007-6-17 16:54

<P>好强呀!</P>[attach]22668[/attach]<BR>

bupo 发表于 2007-8-19 11:05

回复:(cdmalcl)[原创]一个方程实现液体下流效果

<P>我运行这段代码时为什么说"无法打开包括文件:“graphics.h”: No such file or directory"</P>

leopardxp 发表于 2007-8-19 17:53

回复:(cdmalcl)[原创]一个方程实现液体下流效果

这些类似的效果怎么实现?三角函数在类似的图形中有什么使用技巧?

chen7806 发表于 2007-8-20 11:56

我用tc201,编译能通过,执行后没见到什么?

老糊涂 发表于 2007-8-25 19:54

<P>牛~~~~~~~~顶~~~~~~~~!</P>

鍾臣 发表于 2007-9-24 18:09

能不能给个注释啊!!!!!看不懂啊!!!!!!!!

lubin542397 发表于 2007-9-28 10:03

支持,很好的东西学习了

维c 发表于 2007-10-1 15:08

厉害.....

bitcai 发表于 2007-10-6 21:10

我也想要注释 <a href="mailto:zhang2gong@163.com" target="_blank" >zhang2gong@163.com</A> 谢谢

canyue 发表于 2007-10-9 23:27

不是我能看懂的

永夜的极光 发表于 2007-10-10 15:48

[em17][em17][em17]LZ相当的厉害,佩服

页: [1] 2

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.