# Waves at sea

**F**ollowing my previous blog about 3D function graphing, I did another experiment to animate the 3D graphs. In this blog, I used the same 3D function f(x,z) = x*z^3-z*x^3 to generate two sets of heights. Then a **VECTORINTERPOLATOR** (or **VECINT**) was used to animate this 3D graph. It looks to me like a wave on the sea surface. What do you think?

Here is the animated 3D graph for you to have a play. You can press m key in the 3D scene to switch the rendering from point to line to face. I also applied an image texture to make it look more like water. Another **SCALARINTERPOLATOR** (or **SCLRINT**) was used to rotate the image texture so, it looks like the water is running, hopefully.

Below is the Logo program I wrote for this animating 3D graphs.

; Animating ElevationGrid with VectorInterpolator ; By Andy Yeh (2014) CS RESET SETBG 27 ; define the mathematical function to calculate the heights of grid TO fn :x :z OUTPUT (:x*:z^3-:z*:x^3)/1000 END ; start creating objects MAKE "y1 [] ; for grid height set 1 MAKE "y2 [] ; for grid height set 2 FOR [ x -10 10 1 ] [ FOR [ z -10 10 1 ] [ ; make "y fn :x :z QUEUE "y1 fn :x :z QUEUE "y2 fn :z :x ] ] FD 10 WEST 10 ELEGRID MAKE "obj WORD OBJECT "_elegrid SET :obj "xdimension 21 SET :obj "zdimension 21 ; prepare for wave animation TIMESENSOR "ts 5 TRUE MAKE "key [0 .5 1] MAKE "keyvalue [] QUEUE "keyvalue :y1 QUEUE "keyvalue :y2 QUEUE "keyvalue :y1 VECINT "vi :key :keyvalue ROUTE "r1 "ts "fraction_changed "vi "set_fraction ROUTE "r2 "vi "value_changed :obj "set_height ; prepare for texture translation animation SELECT OBJECT SETIT 4 35 ; apply image texture index 4 35 MAKE "ttobj WORD OBJECT "_texTran TIMESENSOR "ts1 3600 TRUE SCLRINT "si :key [ 0 180 360 ] ROUTE "r3 "ts1 "fraction_changed "si "set_fraction ROUTE "r4 "si "value_changed :ttobj "rotation SHOWALL

The idea of this animation is to collect two sets of heights (y1 and y2) then apply to the ElevationGrid. The y1 and y2 lists, as can be seen in line 15 and 16, are inverse of each other (exchanging x and z). The VECINT then took three sets of keyValues as y1 and y2 and then back to y1 to complete the animation cycle, done by the **TIMESENSOR** and 2 **ROUTE** commands. The **SCLRINT** in line 38 generate a scalar value_changed and routed to the TextureTransform node.

What do you think? Does it look like the waves on the sea?

The 3D functions can be used to simulate many natural phenomena. Use the idea in this blog, I may be able to create some sea weeds waving under the sea.... If you have any ideas about using 3D functions to create objects, please share below in the comment area.

**Files**: Sea_surface.x3d Sea_surface.logo

- Andy's blog
- Login or register to post comments
- 4442 reads

## Facebook Comments Box