我有与Koch Snowflake和堆叠/队列有关的任务。问题是我们这里的许多人都无法弄清楚赋值中给出的伪代码“提示”是什么意思。有人可以帮忙吗?
http://web.cs.mun.ca/~rod/W12/cs2710/assign/a5/assign5.html
Add the initial segments, L.add(seg1) ... L.add(segN)
while not L.isEmpty()
seg = L.remove()
if seg is smaller than the minimum segment size then
draw seg, no new segments are created
else
create four new segments according to
the rules for Koch snowflakes
add these new segments to L
最令人困惑的部分是“如果seg小于最小段大小”...不确定我需要比较什么来写这个。
答案 0 :(得分:2)
最小段大小显然是算法的可配置参数,用于指定绘制雪花的精细细节级别。
答案 1 :(得分:1)
段是一个线段:来自你的纪录片:
“细分是一个代表线段的类”
因此它将在屏幕上绘制一条线 你应该首先看看科赫雪花的外观如何:http://en.wikipedia.org/wiki/Koch_snowflake
现在更容易理解:“
如果seg小于最小段大小,那么
这是一个所谓的“断裂条件”,这意味着线条足够小,应该在屏幕上绘制。 (否则它将被细分,请参阅上面的Wiki链接。)