level 12
刚刚写了一个演示程序,凑合看吧:
///////////////////////////////////
// 程序名称:旋转演示
//
// 旋转公式: x'=xcosθ-ysinθ
// y'=xsinθ+ycosθ
//
#include <graphics.h>
#include <conio.h>
#include <math.h>
void main()
{
initgraph(640, 480);
setorigin(320, 240);
// 旋转前的点
POINT pSrc[4] = {{-100, -50}, {200, -50}, {200, 90}, {-100, 90}};
// 旋转后的点
POINT pDst[4];
// 循环变量
int i;
for(double pi = 0; pi < 6.28; pi += 0.01)
{
cleardevice();
for(i = 0; i < 4; i++)
{
pDst[i].x = int(pSrc[i].x * cos(pi) - pSrc[i].y * sin(pi));
pDst[i].y = int(pSrc[i].x * sin(pi) + pSrc[i].y * cos(pi));
}
moveto(pDst[3].x, pDst[3].y);
for(i = 0; i < 4; i++)
lineto(pDst[i].x, pDst[i].y);
Sleep(20);
}
getch();
closegraph();
}
2013年01月13日 17点01分



