如何用grasshopper生成斐波那契曲線?

時間 2021-06-04 15:55:38

1樓:

如果有人能知道怎麼把 gh.rectangle2pt 的 warning 弄掉忘告知

Python (Fake) Dynamic Programming Version

"""Provides a scripting component.

Inputs:

x: The x script variabley: The y script variableOutput:

a: The a output variable"""

__author__

="Leo Li"

__version__

="2019.10.11"

import

rhinoscriptsyntax

asrs

import

ghpythonlib.componentsasgh

# define a fibonacci sequencedeffib(i

,ref

={}):ifi

inref

:return

ref[i]

else:if

i==0:

ref[0]

=1return

ref[0]

elifi==

1:ref[1]

=1return

ref[1]

else

:ref[i

]=fib(i-

1,ref)

+fib(i

-2,ref

)return

ref[i]

i=0# init state

# points

existingPoints=

startingPoint=gh

.ConstructPoint(0

,0,0

)existingPoints.(

startingPoint

)# squares

existingSquares=

# arcs

existingArcs=

# directions

directions=[

gh.ConstructPoint(1

,0,0

),gh

.ConstructPoint(0

,1,0

),gh

.ConstructPoint(-

1,0,

0),gh.

ConstructPoint(0

,-1,

0),]# iterating...n=

len(

directions

)while

i

:currentPoint

=existingPoints[-

1]multiplier

=fib(i

)# first time moving pointdx=multiplier

*directions[i

%n][0

]dy=multiplier

*directions[i

%n][1

]dz=multiplier

*directions[i

%n][2

]x,y

,z=currentPoint

movedPoint=gh

.ConstructPoint(x

+dx,y

+dy,z

+dz)# second time moving pointdx=multiplier

*directions[(i

+1)%

n][0]

dy=multiplier

*directions[(i

+1)%

n][1]

dz=multiplier

*directions[(i

+1)%

n][2]

x,y,

z=movedPoint

finalPoint=gh

.ConstructPoint(x

+dx,y

+dy,z

+dz)# add point to the resultexistingPoints.(

finalPoint

)# add square

rec=gh.

Rectangle2Pt

(point_a

=currentPoint

,point_b

=finalPoint

)existingSquares.(

rec[0])

# if i > 0, draw arcifi>0:

arc=gh.

ArcSED

(currentPoint

,finalPoint

,directions[i

%n])existingArcs.(

arc[0])

i+=1

grasshopper在規劃中如何運用?

白玉京 只是在直覺上,覺得gh在做規劃領域應該是有前景的。當然,具體咋做呢,因為本身也不是做建築的只能是大概齊勾勒一些設想。將乙個地塊,分成若干個單元,然後在這些單元裡,根據某種規則,會出現乙個大單元,然後不同的單元賦予不同的形體,有點是地標,有的是普通街區。做了如下的簡單嘗試 1.加裝有乙個單元地...

中醫講極熱生寒。如何用物理學解釋

用物理好像還真解釋不了,或者因為我的水平太低!寒極生熱,熱極生寒,是針對人體病理變化的,而不是說人體生理的。在正常人體中是沒有寒熱變化的,因為人能自我調節。如果你在急診科或者腫瘤科之類的科室,應該能看到人體疾病病變後期這種寒熱的變化,尤其是病情嚴重預後很差的疾病。中醫的寒熱是基於人體症狀歸納總結出來...

如何用文科生可以聽懂的語言解釋 以太 ?

因為以太這個假設本身就十分奇怪 然後才意識到根本沒必要用它,因為你說它有,但是你找不到啊,人類YY出來的 解釋以太這個真沒必要,不存在的解釋個啥 u r my ether 可以翻譯為 你是我的以太 你是我的眼 你是我的乙醚 你迷住了我 你是我的天空 你是我生命中最美好的事物 我一直覺得這是很美的一句...