c语言画简谐振动图像,[求助] 实心小球沿正弦曲线运动
還是把程序貼出來吧 要不 蒼穹大哥會怒的
#include
#include
#include
#define PI 3.14
#define LINECOLOR 7
#define ESC 283
typedef struct
{
int x ;
int y ;
}SITE;
typedef struct
{
SITE s0 ;
SITE s1 ;
SITE s2 ;
SITE s3 ;
}RECTSITE;
int Init() ;
int drawProcess() ;
int moveRectangle(RECTSITE rectSite) ;
int End() ;
int screenMaxx2, screenMaxy2 ;
main()
{
Init();
drawProcess();
End();
}
int Init()
{
int gd = DETECT, gm = 0 ;
initgraph(&gd, &gm, "") ;
screenMaxx2 = getmaxx()/2 ;
screenMaxy2 = getmaxy()/2 ;
}
/*
Len0
s0-------s1
| |
| |Len1
| |
| |
s3-------s2
*/
int drawProcess()
{
RECTSITE rectSite ;
int moveCenterX, moveCenterY ;
int i ;
float LenR, Len0, Len1 ;
float startr, r ;
Len0 = 50 ;
Len1 = 80 ;
LenR = sqrt(Len0*Len0+Len1*Len1) ;
startr = atan(Len1/Len0) ;
moveCenterX = screenMaxx2 ;
moveCenterY = screenMaxy2 ;
rectSite.s0.x = moveCenterX ;
rectSite.s0.y = moveCenterY ;
while(!kbhit())
{
for(r = 0;r <= PI*2;r+=0.0314)
{
rectSite.s1.x = Len0*sin(r)+moveCenterX ;
rectSite.s2.x = LenR*sin(r-startr)+moveCenterX ;
rectSite.s3.x = Len1*sin(r-PI/2)+moveCenterX ;
rectSite.s1.y = Len0*cos(r)+moveCenterY ;
rectSite.s2.y = LenR*cos(r-startr)+moveCenterY ;
rectSite.s3.y = Len1*cos(r-PI/2)+moveCenterY ;
setcolor(LINECOLOR) ;
moveRectangle(rectSite) ;
delay(1000) ;
setcolor(0) ;
moveRectangle(rectSite) ;
if(kbhit())
{
if(bioskey(0) == ESC)
return 0 ;
}
}
}
}
int moveRectangle(RECTSITE rectSite)
{
line(rectSite.s0.x, rectSite.s0.y, rectSite.s1.x, rectSite.s1.y) ;
line(rectSite.s1.x, rectSite.s1.y, rectSite.s2.x, rectSite.s2.y) ;
line(rectSite.s2.x, rectSite.s2.y, rectSite.s3.x, rectSite.s3.y) ;
line(rectSite.s3.x, rectSite.s3.y, rectSite.s0.x, rectSite.s0.y) ;
}
int End()
{
setcolor(4) ;
outtextxy(screenMaxx2, screenMaxy2, "END!") ;
getch() ;
closegraph() ;
}
總結
以上是生活随笔為你收集整理的c语言画简谐振动图像,[求助] 实心小球沿正弦曲线运动的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C#转换Excel表格中的科学计数法数字
- 下一篇: 引用 和指针 ,简单, 一怔见血