AlgebraMaster

Modern C++ 创造非凡 . 改变世界

导航

Delaunay triangulation

1,先花个圆: detail模式执行。

#define XY 0x00
#define XZ 0x01
#define YZ 0x02
#define pi 3.1415926
#define close 0x01
#define unclose 0x00


vector center = {1,0,0};
float r = 1;

void drawCicle(vector center;float r;int segments;int PLANE;int isClose)
{

    for(int i=0;i<segments;i++)
    {   if(PLANE == XY)
        {
            float x = r * cos(2 * pi / segments * i) + center.x;
            float y = r * sin(2 * pi / segments * i) + center.y;
            vector p = set(x,y,0);
            addpoint(geoself(),p);
        }
        else if(PLANE == XZ)
        {
            float x = r * cos(2 * pi / segments * i) + center.x;
            float z= r * sin(2 * pi / segments * i) + center.y;
            vector p = set(x,0,z);
            addpoint(geoself(),p);
        }
        else
        {
            float y = r * cos(2 * pi / segments * i) + center.x;
            float z= r * sin(2 * pi / segments * i) + center.y;
            vector p = set(0,y,z);
            addpoint(geoself(),p);
        }
    }
   if(isClose)
   {
       int aprim = addprim(0,"poly");
       for(int i=0;i<segments;i++)
       {
            addvertex(geoself(),aprim,i);
       }
   }
    
}

drawCicle(center,r,120,YZ,close);
View Code

 

2,花外接圆:

 

 

 

 

.

posted on 2017-10-18 14:52  gearslogy  阅读(423)  评论(0编辑  收藏  举报