分形之二叉树(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 ...
随机推荐
- 动态链接库DLL导出函数并导入使用
动态链接库DLL导出函数并导入使用 本文完全参考自<vs2008制作dll笔记,回带值样例>. 首先制作DLL文件,在vs2010中新建Win32控制台项目,选择DLL选项,简历头文件,源 ...
- Laravel Relationship Events
Laravel Relationship Events is a package by Viacheslav Ostrovskiy that adds extra model relationship ...
- Python之paramiko模块
今天我们来了解一下python的paramiko模块 paramiko是python基于SSH用于远程服务器并执行相应的操作. 我们先在windows下安装paramiko 1.cmd下用pip安装p ...
- [C#.Net]C#连接Oracle数据库的方法
首先介绍下开发环境:WIn10 64bit+Visual Studio 2015+Oracle10ClientWin32(只是客户端,如果安装整个数据库也是可以的) 目前了解C#中连接Oracle数据 ...
- HttpMethods(C#.net)
HttpMethods (C#.Net) using System; using System.Collections.Generic; using System.Linq; using Syste ...
- Django的学习(四)———— admin
admin是django自带的一个管理者,由于自带所以直接对admin文件进行一个配置. 一.创建用户: python manage.py createsuperuser 创建合理的用户信息就可以在网 ...
- HTML 内 meta标签
<!-- 是否删除默认的苹果工具栏和菜单栏 --> <meta name="apple-mobile-web-app-capable" content=" ...
- Linux---CentOS 定时运行脚本配置
很多时候我们有希望服务器定时去运行一个脚本来触发一个操作,比如使用七牛的工具上传,如果同步文件里面有新增加一个文件,这个时候我们可以提供定时脚本去完成我们需要的同步命令(七牛的qrsbox工具是自动会 ...
- R入门(二)-对象以及它们的模式和属性
对象以及它们的模式和属性 R操作的实体在技术上说是对象.R的对象类型包括数值型,复数型,逻辑型,字符型和原味型. “原子”型对象:对象的元素都是一样的类型或模式,如逻辑向量和字符串向量. 列表对象:列 ...
- Java 获取最近时间
public static String getStatetime() throws ParseException{ SimpleDateFormat sdf = new SimpleDateForm ...