分形之二叉树(Binary Tree)
上一篇文章讲的是分形之树(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)的更多相关文章
- [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 ...
- 算法与数据结构基础 - 二叉树(Binary Tree)
二叉树基础 满足这样性质的树称为二叉树:空树或节点最多有两个子树,称为左子树.右子树, 左右子树节点同样最多有两个子树. 二叉树是递归定义的,因而常用递归/DFS的思想处理二叉树相关问题,例如Leet ...
- 二叉树(Binary Tree)相关算法的实现
写在前面: 二叉树是比较简单的一种数据结构,理解并熟练掌握其相关算法对于复杂数据结构的学习大有裨益 一.二叉树的创建 [不喜欢理论的点我跳过>>] 所谓的创建二叉树,其实就是让计算机去存储 ...
- 数据结构-二叉树(Binary Tree)
#include <stdio.h> #include <string.h> #include <stdlib.h> #define LIST_INIT_SIZE ...
- [数据结构]——二叉树(Binary Tree)、二叉搜索树(Binary Search Tree)及其衍生算法
二叉树(Binary Tree)是最简单的树形数据结构,然而却十分精妙.其衍生出各种算法,以致于占据了数据结构的半壁江山.STL中大名顶顶的关联容器--集合(set).映射(map)便是使用二叉树实现 ...
- [LeetCode] Find Leaves of Binary Tree 找二叉树的叶节点
Given a binary tree, find all leaves and then remove those leaves. Then repeat the previous steps un ...
- [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, ...
- [LeetCode] Binary Tree Vertical Order Traversal 二叉树的竖直遍历
Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bott ...
- [LeetCode] Binary Tree Longest Consecutive Sequence 二叉树最长连续序列
Given a binary tree, find the length of the longest consecutive sequence path. The path refers to an ...
随机推荐
- Centos查公网IP地址
[root@syy ~]# curl icanhazip.com 115.29.208.111
- Eclipse中配置Tomcat服务器并创建标准Web目录
Eclipse创建 Java Web 项目,并生成标准的目录结构 file --> New --> Dynamic Web project 填写 Project name (该名称项目的名 ...
- Spring ApplicationContext(五)invokeBeanFactoryPostProcessors
Spring ApplicationContext(六)BeanPostProcessor 产生回顾一下 ApplicationContext 初始化的几个步骤:第一步是刷新环境变量:第二步是刷新 b ...
- python之web开发“三剑客”
# django import django # flask import flask # tornado import tornado
- oracle的常用99条语句
1. select * from emp; 2. select empno, ename, job from emp; 3. select empno 编号, ename 姓名, job 工作 fro ...
- Redis的基操
redis:通常BOLEAN操作类型,操作成功返回1,操作失败返回0 通常如果往设置的key插入值,但是这个key不存在,redis则会创建 向redis里的某个key插入多个值时,值和值之间用空格隔 ...
- Github 快速上手实战教程
一.实验介绍 1.1 实验内容 本次课程讲的是在实验楼的在线环境中,如何使用 Github 去管理在在线环境中使用的代码.配置.资源等实验相关文件,怎样去添加.同步和下拉在远程仓库中的实验文件,以此来 ...
- Bayes’s formula for Conditional Probability
Conditional Probability Example:In a batch, there are 80% C programmers, and 40% are Java and C prog ...
- jquery 特效
http://demo.howtoexe.com/instagram-gravity-gallery/index.html
- 牛客训练三:处女座和小姐姐(三)(数位dp)
题目链接:传送门 思路:数位dp的记忆化搜索模板 从高位向低位枚举,逐位确定每一位的6的个数,dp[i][s]表示处理到第i条边,状态为s时的数字的个数. 注意,要使用long long类型. #in ...