Even more 3D effects

In the last version I improved the 3D plot shading and added some nice 3D effects. Bellow is the plot of the function

f(x; y) = cos(x) + cos(y) + cos(x·y/3)/2 + cos(√(x2 + y2)·2)/2

with the “Rainbow” color scale and the “Shadows” option on:

What is new is the specular light effect (the little shiny reflections). I also replaced the Gouraud shading procedure with the Phong one. It improved the image quality  without any noticeable impact on the speed (surprisingly). Since the light is distant and the view is isometric, I use the Blinn–Phong shading model. Instead of calculating the reflection vector for each vertex, it calculates the halfway vector between the viewer and light-source. It is performed once for the whole model, and that is why it is faster.

In general, there is additional overhead for generating the Html output, converting the image to base64 and rendering the Html into the “Output” window. However, as long as it takes much less than a second for all of it, the speed is not of a big concern.

The new and enhanced version of Calcpad 3.2 was released. Besides other improvements, we added some nice visual effects for 2D plotting.

In general, you can use Calcpad to plot functions of two parameters f(x; y), by the \$Map command:

`\$Map{f(x;y) @ x = a : b & y = c : d}`

The result is displayed as a 2D contour map. For example, let us take the function:

`f(x; y) = cos(x) + cos(y) + cos(π/2*sqr(x^2 + y^2))`

The \$Map command will produce the following image:

The left one is without shadow effects. Different values of the function are represented by the respective colors. Blues are the lowest and reds are the highest. However, you need to have quite a rich imagination to figure out how the surface actually looks. That is why we added a 3D shadows effects. On the right side, you can see the same image, but with shadows. The light here comes from North-West direction. Now it looks much more natural and it is easier for the human eye to perceive the shape.

The shading is calculated using the dot product of the normal vector to the surface by the vector of the light.

There are also other plotting options available:

You can select among different color scales:

If you select “smooth” (gradient) scale, you will get the following image:

Instead of having contours, now the colors flow smoothly from one to another. That is because the color of each pixel is calculated individually based on its value.