【问题标题】:What is the logic of this fractal? [closed]这个分形的逻辑是什么? [关闭]
【发布时间】:2013-03-26 07:33:55
【问题描述】:

我正在为学校做一个项目,需要粗略地重现这个分形(在 BGI 中):

我一直在为中等大小的三角形寻找放置逻辑,因为它们必须被绘制到 for/while 循环中。 (我画了主要的三角形,并在它的每一边画了一个圆圈。)

感谢任何想法!

【问题讨论】:

  • 鉴于左侧的几个随机点,它看起来模糊地基于迭代函数系统
  • 系数看起来有点错误,因为它几乎具有 D3 对称性。
  • 除非有人找到一种通用方法来逆向工程分形,否则恐怕这个问题过于本地化
  • 结果不必完全像这样(我已经将大圆圈正好放在三角形边的中间)。

标签: c++ logic


【解决方案1】:

绝对是 IFS。 IFS 分形使用递归。它就像一个树形结构,其中每个分支都可以有侧分支,而这些分支又可以有自己的较小侧分支。在(类似 C 的)伪代码中,它看起来像:

draw_triangle(vector2d pos, float scale, int depth)
{
  if (depth < MAX_DEPTH) return;

  /* actual graphics code for the triangle goes here.. use pos and scale */

  /* compute center positions for circles side1_pos, side2_pos, etc... */

  draw_circle(side1_pos, 0.5*scale, depth+1);
  draw_circle(side2_pos, 0.5*scale, depth+1);
  draw_circle(side3_pos, 0.5*scale, depth+1);
}

draw_circle(vector2d pos, float scale, int depth)
{
  if (depth < MAX_DEPTH) return;
  /* actual graphics code for the circle goes here.. use pos and scale */

  /* compute center positions for triangles side1_pos, side2_pos, etc... */

  draw_triangle(side1_pos, 0.5*scale, depth+1);
  draw_triangle(side2_pos, 0.5*scale, depth+1);
  draw_triangle(side3_pos, 0.5*scale, depth+1);
}

【讨论】:

    猜你喜欢
    • 2011-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-29
    • 2012-05-05
    • 2010-11-29
    • 2020-05-22
    • 2019-07-01
    相关资源
    最近更新 更多