0hc.net Menu
Home Overview
About Menu
Impressum

Branch

require 'tk' class Draw def transform(abb) @xlinks[@stufe] = @a[abb] * @xlinks[@stufe+1] + @b[abb] * @ylinks[@stufe+1] + @e[abb] @ylinks[@stufe] = @c[abb] * @xlinks[@stufe+1] + @d[abb] * @ylinks[@stufe+1] + @f[abb] @xrechts[@stufe] = @a[abb] * @xrechts[@stufe+1] + @b[abb] * @yrechts[@stufe+1] + @e[abb] @yrechts[@stufe] = @c[abb] * @xrechts[@stufe+1] + @d[abb] * @yrechts[@stufe+1] + @f[abb] @xoben[@stufe] = @a[abb] * @xoben[@stufe+1] + @b[abb] * @yoben[@stufe+1] + @e[abb] @yoben[@stufe] = @c[abb] * @xoben[@stufe+1] + @d[abb] * @yoben[@stufe+1] + @f[abb] zeichne() end def verzweige() @stufe -= 1 (1..@vfa).each {|i| transform(i)} @stufe +=1 end def zeichne() verzweige() if @stufe > 1 TkcLine.new(@canvas, @links+@xlinks[1], @wl-@ylinks[1], @links+@xrechts[1], @wl-@yrechts[1]).fill('black') TkcLine.new(@canvas, @links+@xrechts[1], @wl-@yrechts[1], @links+@xoben[1], @wl-@yoben[1]).fill('black') TkcLine.new(@canvas, @links+@xoben[1], @wl-@yoben[1], @links+@xlinks[1], @wl-@ylinks[1]).fill('black') end def amz(i) x = [] (1..i).each {|j| x[j]=0} return x end def initialize @fsize = 800 root = TkRoot.new { title "MVKM Iteration" } @canvas = TkCanvas.new(root) @canvas.height(@fsize) @canvas.width(@fsize) @canvas.pack @stufe = 8 @vfa = 3 @xlinks = amz(@stufe+1).dup @xrechts = amz(@stufe+1).dup @xoben = amz(@stufe+1).dup @ylinks = amz(@stufe+1).dup @yrechts = amz(@stufe+1).dup @yoben = amz(@stufe+1).dup @a = amz(@vfa).dup @b = amz(@vfa).dup @c = amz(@vfa).dup @d = amz(@vfa).dup @e = amz(@vfa).dup @f = amz(@vfa).dup @links = 50 @w = @fsize-100 @wl = @w + @links @xlinks[@stufe] = 0 @ylinks[@stufe] = 0 @xrechts[@stufe] = @w @yrechts[@stufe] = 0 @xoben[@stufe] = 0.5*@w @yoben[@stufe] = @w @a[1] = 0.387; @a[2] = 0.441; @a[3] = -0.468 @b[1] = 0.430; @b[2] = -0.091; @b[3] = 0.020 @c[1] = 0.430; @c[2] = -0.009; @c[3] = -0.113 @d[1] = -0.387; @d[2] = -0.322; @d[3] = 0.015 @e[1] = 0.2560*@w; @e[2] = 0.4219*@w; @e[3] = 0.4000*@w @f[1] = 0.5220*@w; @f[2] = 0.5059*@w; @f[3] = 0.4000*@w zeichne() end end Draw.new Tk.mainloop
0hc.net    © 2001-2014 Harald Wolfsgruber