猫史档案馆


【柏林噪声】1维柏林噪声研制成功!

用户:柏林噪声柏林噪声查看:4 回复:3 评论:4 创建时间:2020-11-05T20:01:58


center_image

1维柏林噪声原理:

在x轴上的各个坐标取一个随机y,

并存入列表中,

利用三角函数cos平滑这些值。

emotion_编程猫_加油

原理看似简单,

但是实现起来确实不容易,

本人在Python中花了好几天时间,

终于搞完了……

(尹子后人)

import turtle as t
import random
import math

List=[]
for i in range(0,9):
    List.append(random.randint(-100,100))
t.hideturtle()
t.speed(0)
t.penup()
t.goto(-200,List[0])
t.pensize(10)
t.pendown()
for i in range(1,9):
    if(List[i]<List[i-1]):
        k=0
        for j in range(314):
            k+=0.01
            t.goto(t.xcor()+50/314,List[i-1]+(math.cos(k)-1)/2*(List[i-1]-List[i]))
    else:
        k=3.14
        for j in range(314):
            k-=0.01
            t.goto(t.xcor()+50/314,List[i-1]+(math.cos(k)+1)/2*(List[i]-List[i-1]))
t.done()


回复

上一页1 页 / 共 1下一页
LeecLeec

这位学霸能不能说点能听懂的?

点赞0


评论


Mellin_AmpMellin_Amp

傅里叶?emotion_doge

点赞0


评论


imgainary_numberimgainary_number

挖.

点赞0


评论