分形之花篮(Flower Basket)

时间:2021-05-09 07:24:10

这一篇展示的图形与上一篇文章分形之皇冠(Crown)很相似。

核心代码:

static void FractalFlowerBasket(const Vector3& vStart, const Vector3& vEnd, Yreal angle, Yreal top, Yreal bian, Vector3* pVertices)
{
Vector3 vSub = vEnd - vStart;
Yreal len = D3DXVec3Length(&vSub); pVertices[] = vStart;
pVertices[] = vEnd; Yreal alfa = atan2f(vSub.y, vSub.x); Yreal a0 = alfa + angle;
Yreal a1 = alfa - angle;
alfa += atanf(top*2.0f); Yreal l = len * sqrtf(0.25f + top*top);
pVertices[].x = vStart.x + cosf(alfa)*l;
pVertices[].y = vStart.y + sinf(alfa)*l;
pVertices[].z = 0.0f; l = len * bian;
pVertices[].x = vStart.x + cosf(a0)*l;
pVertices[].y = vStart.y + sinf(a0)*l;
pVertices[].z = 0.0f; pVertices[].x = vEnd.x - cosf(a1)*l;
pVertices[].y = vEnd.y - sinf(a1)*l;
pVertices[].z = 0.0f;
}

软件截图:

分形之花篮(Flower Basket)

分形之花篮(Flower Basket)

分形之花篮(Flower Basket)分形之花篮(Flower Basket)

分形之花篮(Flower Basket)

分形之花篮(Flower Basket)

分形之花篮(Flower Basket)

分形之花篮(Flower Basket)

分形之花篮(Flower Basket)

从图上看,我学得这东西不该叫花篮,应该叫花圈。

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