鱼C论坛

 找回密码
 立即注册
查看: 2265|回复: 2

斐波那契数列相关问题

[复制链接]
发表于 2017-11-30 14:49:53 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 kio 于 2017-11-30 14:49 编辑

原文参考
http://www.zhihu.com/question/24470349
http://jsfiddle.net/njed27nf/
2222.png
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2017-11-30 14:49:54 | 显示全部楼层
  1. #coding=utf-8
  2. import rhinoscriptsyntax as rs
  3. from math import sqrt,pi,cos,sin
  4. width = 70
  5. height = 70
  6. nbr_circles = 250
  7. phi = (sqrt(5) + 1) / 2 - 1 # golden ratio
  8. golden_angle = phi * 2 * pi # golden ngle

  9. lg_rad = width * .45;
  10. lg_area = lg_rad ** 2 * pi

  11. sm_area = lg_area / nbr_circles  # Area of our little circles,if they filled the space entirely
  12. sm_rad = sqrt(sm_area / pi)  # This is related to the equation area = pi r squared
  13. fudge = 0.5  # Fudge factor, since our circles don't actually fill up space entirely.
  14. adj_sm_diameter = sm_rad * 2 * fudge
  15. cx = width / 2
  16. cy = height / 2


  17. for i in range(1,nbr_circles):
  18.     angle = i * golden_angle
  19.     cum_area = i * sm_area
  20.     spiral_rad = sqrt(cum_area / pi)
  21.     x = cx + cos(angle) * spiral_rad
  22.     y = cy + sin(angle) * spiral_rad
  23.     #print(x,y)


  24.     #rs.AddCircle((x,y,0),1)
  25.     rs.AddPoint(x,y,0)
复制代码


最终完成了.
005415q5is7s1f1vc8ezsy.jpg
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-11-30 16:07:58 | 显示全部楼层
牛逼,我只知道输出不大于1000斐波那契数列,你居然还可以画出来!
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-12-26 04:27

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表