Ripple wave
This is my first water ripple experiment. I found a function on Youtube and had a quick experiment. The ripple effect is not perfect but could be a good start for whoever is interested to refine it.
Below is the Logo program.
; Water Ripple By Andy Yeh (2015) ; original function from: ; https://www.youtube.com/watch?v=JrzgE7p-xnU ; z=(cos(0.5sqrt(x^2+y^2)-6n)/(0.5(x^2+y^2)+1+2n), n={0...10} CLEAN HOME RESET CT SETBG 30 ; define the mathematical function to be plotted TO fn :x :z :w OUTPUT COS(:w*SQRT(:x^2+:z^2))/(0.5*(:x^2+:z^2)+1)*10000 END ; start collecting heights MAKE "height [] FOR [ x -30 30 1 ] [ FOR [ z -30 30 1 ] [ MAKE "y fn :x :z 0 QUEUE "height :y ] ] ; start creating FD 30 WEST 30 ELEGRID MAKE "obj WORD OBJECT "_elegrid SET :obj "xdimension 61 SET :obj "zdimension 61 SET :obj "height :height TIMESENSOR "ts 10 TRUE MAKE "key [ 0 .1 .2 .3 .4 .5 .6 .7 .8 .9 1 ] MAKE "value [] QUEUE "value :height FOR [ w 0.01 1 0.1 ] [ MAKE "height [] FOR [ x -30 30 1 ] [ FOR [ z -30 30 1 ] [ MAKE "y fn :x :z :w QUEUE "height :y ] ] QUEUE "value :height ] VECINT "vi :key :value ROUTE "r1 "ts "fraction_changed "vi "set_fraction ROUTE "r2 "vi "value_changed :obj "set_height
Please leave a comment below and let me know if you can help improve it.
- Andy's blog
- Login or register to post comments
- 4104 reads