上一篇文章讲的是分形之树(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. 03. pt-config-diff

    pt-config-diff h=192.168.100.101,P=3306,u=admin,p=admin h=192.168.100.102,P=3306,u=admin,p=admin pt- ...

  2. Spring 注解(二)注解工具类 AnnotationUtils 和 AnnotatedElementUtils

    Spring 注解(二)注解工具类 AnnotationUtils 和 AnnotatedElementUtils Spring 系列目录(https://www.cnblogs.com/binary ...

  3. 企业类Web原型制作分享-Kraftwerk

    这是一个设计师团队,将数码产品的创意发挥到极致.整个网站采用深黑色背景和图文搭配,网站有很多动画特效,均突出数码产品的质感.网站结合滚动区实现导航栏悬浮效果,用弹出面板实现点击弹出内容等交互效果. 本 ...

  4. oralce的lag和lead函数

    https://www.cnblogs.com/always-online/p/5010185.html

  5. 实现WireCard支付

    实现WireCard支付,暂未完成 WireCardController.cs using System; using System.Collections.Generic; using System ...

  6. ios 内存管理与property copy strong weak assign

    - (void)fun{  NSString* str = [[NSString alloc] initWithString:@"string"];  NSLog(@"% ...

  7. 全球IT经理一致喜爱的ITSM系统、it服务台软件

  8. 693. Binary Number with Alternating Bits

    static int wing=[]() { std::ios::sync_with_stdio(false); cin.tie(NULL); ; }(); class Solution { publ ...

  9. D. Three Pieces(dp,array用法,棋盘模型)

    https://codeforces.com/contest/1065/problem/D 题意 给你一个方阵,里面的数字从1~nn,你需要从标号为1的格子依次走到标号为nn,在每一个格子你有两个决策 ...

  10. Codeforces Round #516 (Div. 2, by Moscow Team Olympiad) D. Labyrinth(重识搜索)

    https://codeforces.com/contest/1064/problem/D 题意 给你一个有障碍的图,限制你向左向右走的次数,问你可以到达格子的个数 思路 可以定义状态为vi[x][y ...