码迷,mamicode.com
首页 > 其他好文 > 详细

分形之皇冠(Crown)

时间:2014-10-17 14:58:38      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   ar   sp   div   2014   

皇冠分形曲线

核心代码:

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;
}

软件截图:

bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

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

分形之皇冠(Crown)

标签:style   blog   http   color   os   ar   sp   div   2014   

原文地址:http://www.cnblogs.com/WhyEngine/p/4020577.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!