# 3D function with ElevationGrid

• Sharebar

I have been thinking about 3D graphing using ElevationGrid for a while and finally got time to demonstrate here. Previously, I have blogged about 3D plotting and ElevationGrid, This blog is simply taking the same maths function f(x,z) = x*z^3-z*x^3 in the 3D plotting blog and apply to the ElevationGrid object.

Let's play around this 3D graph first. (Hint: You may press m key to switch rendering from point to line to face)

And here is the Logo program:

As can be seen in the Logo program, I have included a few 3D functions for you to try. You can comment out line 8 and uncomment any from line 9-16 to try. Feel free to change the function and enjoy the surprise you get. If any, please share below in the comment area or post your own blog.

In VRMath2 Editor, you can create an ElevationGrid using ELEGRID command. By default, you will get a 10 by 10 grid on X-Z plane with random heights in Y. In line 20 and 21, I used FOR command to create a 21 by 21 grid. The x and z are ranging from -10 to 10 with a step of 1. y was then calculated in line 22 calling to the FN procedure, then QUEUE into the height list in line 23.

Because of the grid height collected is 21x21, therefore, line 29-30 changed the default 10x10 grid to 21x21 and set height to the collected height list.