Povray in Euler Math Toolbox

EMT can do a lot of 3D plots, but it is not an OpenGL application. This means that it has restrictions concerning hidden surfaces and intersecting objects. But if you install Povray you can do a lot more. Note that you need to put the path to the installation into your system path, or set the „povengine“ variable as described in the tutorial about Povray in EMT. In this tutorial you will find a lot of examples to get you started. Combining EMT with Povray is a fascinating application of EMT.

The first simple function is pov3d(). This function is similar to plot3d(). Here is an example.

>load povray
 Functions to generate Povray files for the open Raytracer. 
>pov3d("x^2+y^3",axiscolor=red,angle=20°, ...
>  look=povlook(red,0.2),level=-1:0.5:1,zoom=3.8);


As you see, you can use an expression, set angles, zoom, and levels just as in plot3d(). The new parameter is „look“, which makes the plot a transparent red. The output will cast shadows from the light source. Moreover, there is a coordinate axis. You can control all that in the plv3d() function.

The graphics is not in the graphics window, but in the text window, just like inserted graphics from EMT. Moreover, the graphics file is in the working directory of EMT. By default, this is the directory „Euler“ in your user directory („C:\Users\Name\Euler“). By default, it is a 450×450 PNG.

But you can do much more in EMT with Povray. EMT can handle Povray is by Povray objects stored as Povray commands in strings. For some large objects files are used. If you generate a Povray scene with these objects, you need to start the generator with povstart() and finish with povend(). That command will also start the Povray program. Here is an example.

>x=0:0.02:1; y=x'; z=x*y; vx=-y; vy=-x; vz=1;
>cl=povdisc([0.5,0.5,0],[1,1,0],2); ...
>writeln(povintersection([mesh,cl],povlook(red))); ...
>writeAxes(0,1,0,1,0,1,d=0.015); ...


Let me explain the commands one by one.

First, we start the new scene with povstart(). This generates a Povray file in the user directory. It does also set the camera angle, the point to look at, and the camera zoom. It can set a lot more. You need to read the documentation for Povray in EMT for more information.

We now generate objects. The povtriangles() functions generates a file containing the description of a mesh and a string containing the Povray command for this mesh. The string „mesh“ simply contains „object { mesh1 }“.

We then generate more strings containing commands for Povray objects. E.g., cl is a disk which is later used to intersect the green surface with in height 1/2.
   cylinder { <0.492929,0.492929,0>, <0.507071,0.507071,0>, 2
    texture { pigment { color rgb <0.470588,0.470588,0.470588> }  } 
    finish { ambient 0.2 } 

The function difference() then is a command computing the difference of the mesh „mesh“ and the disk „cl“.

   difference { 
   object { mesh1 }
   union { cylinder { <0.492929,0.492929,0>, <0.507071,0.507071,0>, 2
    texture { pigment { color rgb <0.470588,0.470588,0.470588> }  } 
    finish { ambient 0.2 } 
   cylinder { <0,0,0.24>, <0,0,0.26>, 2
    texture { pigment { color rgb <0.470588,0.470588,0.470588> }  } 
    finish { ambient 0.2 } 
    texture { pigment { color rgb <0.470588,0.470588,0.470588> }  } 
    finish { ambient 0.2 } 
    texture { pigment { color rgb <0.0627451,0.564706,0.0627451> }  } 
    finish { ambient 0.2 } 

We use writeln() to write this string to the Povray file which has been opened in EMT with the open() command. That is the main trick to generate Povray scenes in EMT.

Finally, povend() generates the file. This time, we specify a larger image which can be found in the user directory of EMT.

There is a lot more you can do with this combination of EMT and Povray. In fact, you can do everything, Povray is capable of. You may need to define new functions for this. Have a look at the tutorial and the visit the links at the end for more examples.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.