本文介绍了在Haskell中实现Koch Snowflake的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我试着学习Haskell,稍微发现它很难,我正在Koch Snowflake和Sierpinski Triangle工作。



欢迎任何代码或建议。



/ b>

解决方案

  1. 计算以飞机为中心的三角形的点。
  2. 在三角形的每个点上,计算三分之一大小的三角形的点,然后向上(沿水平中间翻转)。
  3. 将每个三角形传递给第2步,将结果再次传递到第2步,依此类推。

  4. 再次完成所有操作,颠倒过来。

这应该给你一个(列表)三角形列表。现在在屏幕上画出这些三角形,以达到您认为合理的深度。

I was looking at this on the Wikipedia Page and was wondering if anyone has a working implementation of this.

I'm trying to learn Haskell, finding it slightly difficult and am working on the Koch Snowflake and Sierpinski Triangle.

Any code or suggestions welcome.

Thanks

解决方案
  1. Calculate the points of a triangle centered in the plane.
  2. At each point of the triangle, calculate the points of a triangle one-third its size, and the other way up (flipped along its horizontal middle).
  3. Pass each triangle to step 2, pass the results of that again to step 2, and so on.
  4. Do all that again, upside down.

That should give you a list of (lists of) triangles. Now draw these triangles on the screen to the depth that you think is reasonable.

这篇关于在Haskell中实现Koch Snowflake的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 03:11