驻波合成

驻波合成

因为一些原因,缺失部分代码:

#include
#include
#include

#include 
//#include

//**************皮一下*************************************************
#include
#pragma comment (lib,”winmm.lib”)
///////////////////////////////////////////////////////////////////////

#define WIN_LENGTH 1200
#define WIN_HEIGHT 800
#define PI 3.14159
#define XO 50//坐标开始
#define X_X (WIN_HEIGHT/4)//三个x轴间距

void screen();
void MouseMessage();

MOUSEMSG msg = { 0 };//鼠标消息
HWND hwnd;

int speed = 10;

typedef struct
{
double y;
double a;
double w;
double v;
double w1;
}COEF;

COEF F1 = { 0, 100, 6 * PI / 1000 ,1,0 }, F2 = { 0,100,6 * PI / 1000,1,0 };
// y1=a1*cos(w1*(t-x/v1)+f)+w11 y2=a2*cos(w2*(t+x/v2)+f)+w22

int main()
{
initgraph(WIN_LENGTH, WIN_HEIGHT, 1);

PlaySound(L”海草舞 – 刘君池子.wav”, NULL, SND_LOOP | SND_FILENAME | SND_ASYNC | SND_NODEFAULT);

setbkcolor(WHITE);
double t, x, f;

screen();
//setbkmode(0);
//settextcolor(RED);
settextstyle(10, 10, L”宋体”);

f = 0;

for (t = 0; 1; t +=speed)
{
screen();
setorigin(0, 0);
outtextxy(200, 50, L”变频”);
outtextxy(400, 50, L”变速”);
outtextxy(600, 50, L”变幅”);

for (x = 0; x<1200 - XO; x += 0.5) { setorigin(XO, X_X); 
F1.y = F1.a*cos(F1.w*(t - x / F1.v) + f) + F1.w1;
 putpixel(x, F1.y, GREEN);
 setorigin(XO, X_X * 2); 
F2.y = F2.a*cos(F2.w*(t + x / F2.v) + f) + F2.w1; 
putpixel(x, F2.y, RED); 
setorigin(XO, X_X * 3);
 putpixel(x, F1.y + F2.y, BLUE);
 } Sleep(100); MouseMessage(); 
} getchar(); return 0;
 } void screen() { cleardevice(); 
setcolor(BLACK);
 setorigin(XO, 0); 
line(0, X_X, WIN_LENGTH, X_X);
 line(0, X_X * 2, WIN_LENGTH, X_X * 2); 
line(0, X_X * 3, WIN_LENGTH, X_X * 3); 
line(0, 0, 0, WIN_HEIGHT); 
} void MouseMessage() { int result;
 msg = GetMouseMsg();
 switch (msg.uMsg) { case WM_LBUTTONDOWN: FlushMouseMsgBuffer();
 if (msg.x > 190 && msg.x < 240 && msg.y>40 && msg.y < 60) { hwnd = GetHWnd();
 result = MessageBox(hwnd, L"是否变频?", L"提示", MB_ICONINFORMATION | MB_OKCANCEL);
 if (result == IDOK) { MessageBox(hwnd, L"请在控制台输入", L"提示", MB_OK);
 printf("请输入频率(0.3—5):\nv1:");
 scanf("%lf", &F1.v); printf("\nv2:"); scanf("%lf", &F2.v);
 getchar(); 
} } else if (msg.x > 390 && msg.x < 440 && msg.y>40 && msg.y < 60) { hwnd = GetHWnd(); 
result = MessageBox(hwnd, L"是否变速?", L"提示", MB_ICONINFORMATION | MB_OKCANCEL); 
if (result == IDOK) { MessageBox(hwnd, L"请在控制台输入", L"提示", MB_OK); 
printf("请输入速度(1—500):\n"); scanf("%d", &speed); getchar();
 } } else if (msg.x > 590 && msg.x < 640 && msg.y>40 && msg.y < 60) { hwnd = GetHWnd();
 result = MessageBox(hwnd, L"是否变幅?", L"提示", MB_ICONINFORMATION | MB_OKCANCEL);
 if (result == IDOK) { MessageBox(hwnd, L"请在控制台输入", L"提示", MB_OK);
 printf("请输入振幅(1—50):\na1:"); 
scanf("%lf", &F1.a); printf("\na2:");
 scanf("%lf", &F2.a); 
printf("请输入上下浮动(0—50):\nw1:");
 scanf("%lf", &F1.w1); 
printf("\nw2:");
 scanf("%lf", &F2.w1); getchar(); } } } }


因主题原因,在示例代码中,有部分
C
C
0 条回复 A 作者 M 管理员
    所有的伟大,都源于一个勇敢的开始!
欢迎您,新朋友,感谢参与互动!欢迎您 {{author}},您在本站有{{commentsCount}}条评论