五角星的坐标(DirectX)

来源:互联网 发布:chart.js饼状图百分比 编辑:程序博客网 时间:2024/05/17 00:03

 #define PI 3.1415926

#define lenth 250 //左边距
float ANGLE=PI/180;
int  R=150;
int r=R*sin(18*ANGLE)/cos(36*ANGLE);

 

int x[6],y[6],X[6],Y[6];
 for(int i=0;i<5;i++)
 {
  X[i]=lenth +R*cos((90+i*72)*ANGLE); /* 计算出大圆上的五个平均分布点的坐标*/
  Y[i]=lenth -R*sin((90+i*72)*ANGLE);
  x[i]=lenth +r*cos((54+i*72)*ANGLE); /* 计算出小圆上的五个平均分布点的坐标*/
  y[i]=lenth -r*sin((54+i*72)*ANGLE);
 }

///////////////////////////////////////////////////////////////////////////////////////////////////

CUSTOMVERTEX cvVertices[] =
   {
    { 250, 250,0.0,1.0,D3DCOLOR_XRGB(255, 0, 0)},
    {  x[0],y[0],0.0,1.0,D3DCOLOR_XRGB(255, 0, 255)},
    {  x[1],y[1],0.0,1.0,D3DCOLOR_XRGB(0, 255, 0)},
    {  X[0],Y[0],0.0,1.0,D3DCOLOR_XRGB(0, 0, 255)},
    { 250, 250,0.0,1.0,D3DCOLOR_XRGB(255, 0, 0)},
    {  x[1],y[1],0.0,1.0,D3DCOLOR_XRGB(255, 0, 255)},
    {  x[2],y[2],0.0,1.0,D3DCOLOR_XRGB(0, 255, 0)},
    {  X[1],Y[1],0.0,1.0,D3DCOLOR_XRGB(0, 0, 255)},
    { 250, 250,0.0,1.0,D3DCOLOR_XRGB(255, 0, 0)},
    {  x[2],y[2],0.0,1.0,D3DCOLOR_XRGB(255, 0, 255)},
    {  x[3],y[3],0.0,1.0,D3DCOLOR_XRGB(0, 255, 0)},
    {  X[2],Y[2],0.0,1.0,D3DCOLOR_XRGB(0, 0, 255)},
    { 250, 250,0.0,1.0,D3DCOLOR_XRGB(255, 0, 0)},
    {  x[3],y[3],0.0,1.0,D3DCOLOR_XRGB(255, 0, 255)},
    {  x[4],y[4],0.0,1.0,D3DCOLOR_XRGB(0, 255, 0)},
    {  X[3],Y[3],0.0,1.0,D3DCOLOR_XRGB(0, 0, 255)},
    { 250, 250,0.0,1.0,D3DCOLOR_XRGB(255, 0, 0)},
    {  x[4],y[4],0.0,1.0,D3DCOLOR_XRGB(255, 0, 255)},
    {  x[0],y[0],0.0,1.0,D3DCOLOR_XRGB(0, 255, 0)},
    {  X[4],Y[4],0.0,1.0,D3DCOLOR_XRGB(0, 0, 255)}
    
   };

////////////////////////////////////////////////////////////////////////////////////////////////////

  g_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
  g_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 4, 2);
  g_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 8, 2);
  g_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 12, 2);
  g_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 16, 2);

原创粉丝点击