贴上源码
float cube[8][3]={{-15,-15,-15},{-15,15,-15},{15,15,-15},{15,-15,-15},{-15,-15,15},{-15,15,15},{15,15,15},{15,-15,15}};//立方体坐标
int lineid[25]={1,2,2,3,3,4,4,1,5,6,6,7,7,8,8,5,8,4,7,3,6,2,5,1};//记录点之间连接顺序
float *matconv(float *a,float b[3][3]){//计算矩阵算法
float res[3];
int i;
for(i=0;i<3;i++){
res[i]=b[i][0]*a[0]+b[i][1]*a[1]+b[i][2]*a[2];
}
for(i=0;i<3;i++){
a[i]=res[i];
}
return a;
}
void rotate(float *obj,float x,float y,float z){//旋转这个向量
float rz[3][3]={{cos(z),sin(z),0},{sin(z),cos(z),0},{0,0,0}};
float ry[3][3]={{0,0,0},{0,cos(y),sin(y)},{0,sin(y),cos(y)}};
float rx[3][3]={{cos(x),0,sin(x)},{0,0,0},{sin(x),0,cos(x)}};
matconv(matconv(matconv(obj,rz),ry),rx);
}
|