上一篇文章讲的是分形之树(Tree),这一篇中将其简化一下,来展示二叉分形树的生长过程。

核心代码:

static void FractalBinaryTree(const Vector3& vStart, const Vector3& vEnd, Yreal angle, Yreal branch_c, Vector3* pVertices)
{
Vector3 vSub = vEnd - vStart;
Yreal len = D3DXVec3Length(&vSub);
Yreal alfa = atan2f(vSub.y, vSub.x); Yreal branch = len*branch_c; pVertices[] = vEnd;
pVertices[].x = pVertices[].x + branch*cosf(alfa - angle);
pVertices[].y = pVertices[].y + branch*sinf(alfa - angle);
pVertices[].z = 0.0f; pVertices[] = vEnd;
pVertices[].x = pVertices[].x + branch*cosf(alfa + angle);
pVertices[].y = pVertices[].y + branch*sinf(alfa + angle);
pVertices[].z = 0.0f;
}

软件截图:

最后的图形很像一棵花菜吧。

二叉树有两个控制参数,分叉的角度与子树的长度。通过调节这两个参数,可以得到不同的图形:

最后这个图形与列维(levy)曲线很像

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

分形之二叉树(Binary Tree)的更多相关文章

  1. [Swift]LeetCode968.监控二叉树 | Binary Tree Cameras

    Given a binary tree, we install cameras on the nodes of the tree. Each camera at a node can monitor  ...

  2. 算法与数据结构基础 - 二叉树(Binary Tree)

    二叉树基础 满足这样性质的树称为二叉树:空树或节点最多有两个子树,称为左子树.右子树, 左右子树节点同样最多有两个子树. 二叉树是递归定义的,因而常用递归/DFS的思想处理二叉树相关问题,例如Leet ...

  3. 二叉树(Binary Tree)相关算法的实现

    写在前面: 二叉树是比较简单的一种数据结构,理解并熟练掌握其相关算法对于复杂数据结构的学习大有裨益 一.二叉树的创建 [不喜欢理论的点我跳过>>] 所谓的创建二叉树,其实就是让计算机去存储 ...

  4. 数据结构-二叉树(Binary Tree)

    #include <stdio.h> #include <string.h> #include <stdlib.h> #define LIST_INIT_SIZE ...

  5. [数据结构]——二叉树(Binary Tree)、二叉搜索树(Binary Search Tree)及其衍生算法

    二叉树(Binary Tree)是最简单的树形数据结构,然而却十分精妙.其衍生出各种算法,以致于占据了数据结构的半壁江山.STL中大名顶顶的关联容器--集合(set).映射(map)便是使用二叉树实现 ...

  6. [LeetCode] Find Leaves of Binary Tree 找二叉树的叶节点

    Given a binary tree, find all leaves and then remove those leaves. Then repeat the previous steps un ...

  7. [LeetCode] Verify Preorder Serialization of a Binary Tree 验证二叉树的先序序列化

    One way to serialize a binary tree is to use pre-oder traversal. When we encounter a non-null node, ...

  8. [LeetCode] Binary Tree Vertical Order Traversal 二叉树的竖直遍历

    Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bott ...

  9. [LeetCode] Binary Tree Longest Consecutive Sequence 二叉树最长连续序列

    Given a binary tree, find the length of the longest consecutive sequence path. The path refers to an ...

随机推荐

  1. centos6.5 yum安装postgresql9.3

    rpm -ivh http://download.postgresql.org/pub/repos/yum/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-2.n ...

  2. 拖拽文件实现无刷新上传,支持2G文件

    客户端 用HTML5:jQuery File Upload http://blueimp.github.io/jQuery-File-Upload/basic-plus.html API https: ...

  3. ubuntu下使用fstab挂载硬盘时,属于root,如何把它改为属于一个用户的(如sgjm)

    http://zhidao.baidu.com/link?url=xnakfVD16EtunTSt3wBm153DyqHnXN3FSPO1E_2SpVmM5bmEIwICLA0N6zN85_ioQ3f ...

  4. 企业IT资产管理功能大全

  5. syslog系统日志、事件日志分析、EventLog Analyzer

    syslog系统日志.事件日志分析.EventLog Analyzer Eventlog Analyzer是用来分析和审计系统及事件日志的管理软件,能够对全网范围内的主机.服务器.网络设备.数据库以及 ...

  6. 22.上传app一些相关问题

    1.截取上传的各个屏幕尺寸 1.按最大尺寸截取,快捷键 command+s 2.在模拟器上截取 3. 截图 iphone4 : 640x960 或者 960x640 phone5    640 x 1 ...

  7. ios 数组和字典

    一.数组.  数组只能存放对象类型的数据  2.数组中的对象是有序的 (index)     (一)可变数组   NSArray:NSObject  不可变数组 作用:容器类 存放的是对象类型的数据, ...

  8. 2018.10.25 bzoj4517: [Sdoi2016]排列计数(组合数学)

    传送门 组合数学简单题. Ans=(nm)∗1Ans=\binom {n} {m}*1Ans=(mn​)∗1~(n−m)(n-m)(n−m)的错排数. 前面的直接线性筛逆元求. 后面的错排数递推式本蒟 ...

  9. Java翻转数组的方法

    java的api没用翻转数组的工具类,只能自己写了. int [] testIntArr = {1,2,3}; //翻转数组 for (int i = 0; i < testIntArr.len ...

  10. Router pipeline

    from 2013-HPCA-Breaking the On-Chip Latency Barrier Using SMART book_Principles and Practices of Int ...