D3TRANSLATE

xtran ytran ztran

DOS SVGACC圖形開發庫函式
原型 extern void far d3translate (int points, int xtrans, int ytrans, int ztrans, D3Point far *inary, D3Point far *outary)
輸入 numpoints - 被平移的點數
xtrans - 沿X軸平移的距離
ytrans - 沿Y軸平移的距離
ztrans - 沿Z軸平移的距離
inary - 指向包含待平移點數組的D3Point型指針
輸出 無返回值
outary - 指向包含平移後點數組的D3Point型指針
用法 D3TRANSLATE提取inary中的三維點並且將它們沿每個軸平移指定的象素點。結果通過outary返回,outary可與inary共用一個空間。此函式假定outary已合適分配.
例子
/*
* shows d3translate works
*/
#include <stdlib.h>
#include <conio.h>
#include "svgacc.h"
D2Point plot&#91;8&#93;;
void drwcube(void);
void main(void)
{
int vmode,i,dummy;
ProjParameters proj;
D3Point tcube&#91;8&#93;;
D3Point cube&#91;8&#93; = { { 100,-100, 100},
{ 100,-100,-100},
{ 100, 100,-100},
{ 100, 100, 100},
{-100,-100, 100},
{-100,-100,-100},
{-100, 100,-100},
{-100, 100, 100}};
vmode = videomodeget();
if (!whichvga() || (whichmem() < 512))
exit(1);
res640();
proj.eyex = -1040;
proj.eyey = -600;
proj.eyez = -1200;
proj.scrd = 1700;
proj.theta = 30;
proj.phi = 45;
for(i=0;i<=400;i+=8)
{
d3translate(8,i,i,i,cube,tcube);
dummy = D3PROJECT(8,&proj,tcube,plot);
drwcube();
sdelay(2);
drwcube();
}
for(i=400;i>=0;i-=8)
{
d3translate(8,i,i,i,cube,tcube);
dummy = d3project(8,&proj,tcube,plot);
drwcube();
sdelay(2);
drwcube();
}
drwcube();
getch();
videomodeset(vmode);
}
void drwcube(void)
{
int j;
for(j=0;j<=2;j++)
DRWLINE(2,10,plot&#91;j&#93;.x,plot&#91;j&#93;.y,plot&#91;j+1&#93;.x,plot&#91;j+1&#93;.y);
drwline(2,10,plot&#91;3&#93;.x,plot&#91;3&#93;.y,plot&#91;0&#93;.x,plot&#91;0&#93;.y);
for(j=4;j<=6;j++)
drwline(2,10,plot&#91;j&#93;.x,plot&#91;j&#93;.y,plot&#91;j+1&#93;.x,plot&#91;j+1&#93;.y);
drwline(2,10,plot&#91;7&#93;.x,plot&#91;7&#93;.y,plot&#91;4&#93;.x,plot&#91;4&#93;.y);
for(j=0;j<=3;j++)
drwline(2,10,plot&#91;j&#93;.x,plot&#91;j&#93;.y,plot&#91;j+4&#93;.x,plot&#91;j+4&#93;.y);
return;
}

相關詞條

熱門詞條

聯絡我們