首页 > 代码库 > 分形之皇冠(Crown)

分形之皇冠(Crown)

皇冠分形曲线

核心代码:

static void FractalCrown(const Vector3& vStart, const Vector3& vEnd, Vector3* pVertices){    Vector3 vSub = vEnd - vStart;    Yreal len = D3DXVec3Length(&vSub);    pVertices[0] = vStart;    pVertices[6] = vEnd;    Yreal alfa = atan2f(vSub.y, vSub.x);    Yreal a0 = alfa - YD_REAL_PI/6;    Yreal a1 = alfa + YD_REAL_PI/6;    Yreal l = len/3/cosf(YD_REAL_PI/6);    pVertices[1].x = vStart.x + cosf(a0)*l;    pVertices[1].y = vStart.y + sinf(a0)*l;    pVertices[1].z = 0.0f;    pVertices[2].x = vStart.x + cosf(a1)*l;    pVertices[2].y = vStart.y + sinf(a1)*l;    pVertices[2].z = 0.0f;    pVertices[4].x = vEnd.x - cosf(a0)*l;    pVertices[4].y = vEnd.y - sinf(a0)*l;    pVertices[4].z = 0.0f;    pVertices[5].x = vEnd.x - cosf(a1)*l;    pVertices[5].y = vEnd.y - sinf(a1)*l;    pVertices[5].z = 0.0f;    pVertices[3] = (vStart + vEnd + pVertices[1] + pVertices[5])*0.25f;}

软件截图:

软件下载地址:http://files.cnblogs.com/WhyEngine/Fractal.7z

分形之皇冠(Crown)