D2ROTATE

DOS SVGACC圖形開發庫函式
原型  extern void far d2rotate (int points, int xorigin, int yorigin, int ang, D2Point far *inary, D2Point far *outary)
輸入  numpoints - 被旋轉的點的個數
xorigin, yorigin - 旋轉中心
angle - 相對旋轉中心旋轉的角度
inary - 指向包含被旋轉點的D2Point型數組
輸出  無返回值
outary - 指向旋轉後的點數組
用法  D2ROTATE提取inary指定的二維點並且按照xorigin和yorigin將它們旋轉指定的角度。結果通過outary返回,outary可與inary共用一個空間。正的角度使螢幕上的圖形順時針旋轉,即從X軸正向向Y軸正向旋轉。此函式假定outary已合適分配。
例子
/*
* shows d2rotate works
*/
#include <stdlib.h>
#include <conio.h>
#include "svgacc.h"
D2Point tri[3];
D2Point trio[3];
D2Point tri2[3];
void drwtri(void);
void ertri(void);
void main(void)
{
int vmode,i;
vmode = videomodeget();
if (!whichvga())
exit(1);
if (whichmem()<512)
exit(1);
res640();
trio[0].x = 0;
trio[0].y = 0;
trio[1].x = -80;
trio[1].y = 60;
trio[2].x = 80;
trio[2].y = 60;
drwtri();
for(i=0;i<=360;i+=2)
{
d2rotate(3,0,0,i,trio,tri);
drwtri();
sdelay(2);
ertri();
}
drwtri();
getch();
videomodeset(vmode);
exit(0);
}
void drwtri(void)
{
d2translate(3,320,240,tri,tri2);
drwline(1,10,tri2[0].x,tri2[0].y,tri2[1].x,tri2[1].y);
drwline(1,10,tri2[1].x,tri2[1].y,tri2[2].x,tri2[2].y);
drwline(1,10,tri2[2].x,tri2[2].y,tri2[0].x,tri2[0].y);
return;
}
void ertri(void)
{
d2translate(3,320,240,tri,tri2);
drwline(1,0,tri2[0].x,tri2[0].y,tri2[1].x,tri2[1].y);
drwline(1,0,tri2[1].x,tri2[1].y,tri2[2].x,tri2[2].y);
drwline(1,0,tri2[2].x,tri2[2].y,tri2[0].x,tri2[0].y);
return;
}

相關詞條

熱門詞條

聯絡我們