Functions to generate Povray files for the open Raytracer.
The Povray interface of Euler generates Povray files in the home directory of the user, and calls Povray to parse these files. The default file name is current.pov, and the default directory is eulerhome(), usually c:\Users\Username\Euler. Povray generates a PNG file, which can be loaded by Euler into a notebook. To clean up these files, use povclear().
You need to load this file with "load povray".
Moreover, you need to install Povray, and put the "bin" subdirectory of Povray into the environment path, or set the defaultpovray variable with full path pointing to "pvengine.exe".
The pov3d function is in the same spirit as plot3d. It can generate the graph of a function f(x,y), or a surface with coordinates X,Y,Z in matrices, including optional niveau lines. This function starts the raytracer automatically, and loads the scene into the Euler notebook.
Besides pov3d, there are many functions, which generate Povray objects. These functions return strings, containing the Povray code for the objects. To use these functions, start the Povray file with povstart(). Then use writeln(...) to write the objects to the scene file. Finally, end the file with povend(). By default, the raytracer will start, and the PNG will be inserted into the Euler notebook.
The object functions have a parameter called "look", which needs a string with Povray code for the texture and the finish of the object. The function povlook() can be used to produce this string. It has parameters for the color, the tranparency, the phong etc.
Note that the Povray universe has another coordinate system. This interface translates all coordinates to the Povray system. So you can keep thinking in the Euler coordinate system with z pointing upwards.
For vectors you can use a instead of [a,a,a], and povx=[1,0,0] etc.
function povrgb (c:integer, transparent=0) Color in rgb from for Povray This function returns a string containing a color definition for Povray using "color rgb <r,g,b>". If transparent>0, "rgbf" will be used instead of "rgb". The function works for the 16 Euler colors or colors generated with rgb(r,g,b). See:
povlook (Povray with Euler)
function povxyz () Coordinates for Povray. Note that Povray coordinates are different from Euler coordinates. The horizontal plane is x-z in Povray, and x-y in Euler. This function takes care of that tranformation. With one real argument a the vector [a,a,a] is written. Also the functions povx, povy, povz can be used for the coordinate axes, and povc for the coordinate center.
function povx () := [1,0,0];
function povy () := [0,0,1];
function povz () := [0,1,0];
function povc () := [0,0,0];
function writeCamera (aspect:positive number=1, anaglyph=0) Camera for Povray. This function need not be used directly. Use povstart instead. The current view is used to position the camera. To change the view use the view() function, or the zoom(), viewangle(), or viewheight(), viewdistance() service functions. The camera looks at the current center. To change this use the center() function. aspect : The image is assumed to be square. If not, change the aspect. anaglyph : If this is not zero the scene will be tilted with the default anaglyph separation times the anaglyh value. This is used in pov3d and povanaglyph See:
povstart (Povray with Euler),
pov3d (Povray with Euler),
povanaglyph (Povray with Euler)
function writeAxis (t1:number, t2:number, delta:real vector=none, d:number=0.02, c:integer=gray, axis:integer=1, add:number=0.1) Axis for Povray Creates an axis in form of an arrow. This functions is used in pov3d to create all three axes. Since pov3d packs the scene into the unit cube, and scales the function, there is a translation vector delta. t1, t2 : left and right end of the axis delta : translate the axis using this vector (in Euler coordinates) d : thickness of the axis c : color of the axis axis : which axis 1=x, 2=y, 4=z add : additional length exceeding t1 an t2 on both sides See:
pov3d (Povray with Euler)
function writeAxes (xmin=-1,xmax=1,ymin=-1,ymax=1,zmin=-1,zmax=1, delta:real vector=none, d:number=0.02, c:integer=gray, add:number=0.1) Write an axis System. The function expects the start and the end of each axis. For the other parameters see writeAxis. See:
writeAxis (Povray with Euler)
function writeGlobal (c:integer=white, gamma=1.4) Write the global header. This is called automatically with povstart(). Sets the ambient light color and the assumged gamma.
function writeBackground (c:integer=white) Write the background for the scene. This is called automatically with povstart(). Sets the background color.
function writeLight (v:real vector=[2,3,4], c:integer=white, .. distance=none, shadow=true, fade=0) Write the light source. This is called automatically with povstart(). The light source is in direction of the vector v. The distance of the light source is the distance in view (which is the distance of the camera), but at least mindist, if d ist not set. shadow=false (<shadow) produces no shadow in the scene.
function povray (filename=none, width:index=450, height:index=450, .. aspect:positive number=1, exit:integer=true) Start the Povray process. By default, this is called in povend(). Start the Povray program. The program name is in the global variable defaultpovray. The default filename current.pov in the user home directroy is used if file==none. exit=false allows to keep the Povray window open. Euler will wait, until you close it. filename : The filename to be used (without .pov)
function povopen (filename) Open the povray file for writing. This is called in povstart(). Do not forget to close it before you use the file. The povend() function closes the file automatically. See:
open (Euler Core)
function povscalexyz (x,y,z) Scale x,y,z to fit into a unit cube. Return {x,y,z,f,cx,cy,cz} where f is the factor used, and cx,cy,cz is the new center of the coordinate system. See:
pov3d (Povray with Euler)
function povscalef (x,y) Scale x,y to fit into a unit square. See:
povscalexyz (Povray with Euler)
function povscalez (z) Scale z to fit into [-1,1]
function povload (file=none, anaglyph=false) Load the Povray image into the Notebook. By default, this is called in povend(). file : If none, use defaultfile
function povstart (file=none, zoom=none, distance=none, angle=none, height=none, light:real vector=[2,2,4], lightcolor=white, background=white, aspect=1, shadow=true, center=[0,0,0], fade=0, anaglyph=0) Start a Povray scene. This function opens the file, and sets the scene, including light, camera and background. zoom, distance, angle, height : Change the view locally in this function. The angle is measured from the negative y-axis, as in plot3d() and view(). The height is from the x-y-plane. Both angles are in radians. Use angle=30° to convert. light, lightcolor : A vector to the light source and the color of the light. background : The background color aspect : The aspect ration of your window. For square images use 1. Note that you need the same aspect in povend(). shadow : A flag for shadows. center : The point, where the camera looks at. The camera itself is determined by the view. fade : If nonzero, fading with this exponential rate is used. The fading distance is the distance from the light to the center. See:
povend (Povray with Euler),
view (Euler Core),
view (Basic Plot Functions),
view (Maxima Documentation)
function povend (file=none, povray=true, w=450, h=450, aspect=1, exit=true, imgload=true) End a Povray scene Closes the scene file. By default, the Povray process will start, and the image will be loaded into the notebook. w,h,aspect : In combination determine the aspect ratio of your scene. Note that you need the same aspect as in povstart(). exit : If false, the Povray window will not close automatically. imgload : If false, the image will not be loaded. See:
povstart (Povray with Euler)
function povanaglyph (scene:string, file=none, zoom=none, distance=none, angle=none, height=none, light:real vector=[2,2,4], lightcolor=white, background=white, aspect=1, shadow=true, center=[0,0,0], fade=0, w=450, h=450, aspect=1, exit=true, imgload=true) Create a red/cyan anaglyph Create an anaglyph with a scene, which is generated in the function scene. The Povray command runs twice, and generates two png files in the user directory. The parameters combine povstart and povend See:
povstart (Povray with Euler),
povend (Povray with Euler)
function povlook (color=green, transparent=0, ambient=none, .. phong:real=none, phongsize:real=100, .. reflection=none, diffuse=none) Texture and finish of an object. Returns a string containing the Povray code for this texture and finish. color : the color of the object. Use one of the Euler colors, or rgb(). transparent : If nonzero, the color will be transparent. ambient : The amount of ambient light to be used. phong, phontsize : If nonzero, a shining finish will be used. reflection : Makes the object reflect other objects. See:
rgb (Basic Plot Functions)
function povl () := povlook(args(1));
function writeTriangleMesh (x:real, y:real, z:real, look:string="", xv:real=none, yv:real=none, zv:real=none, simple:integer=false) Mesh object with triangles Write a mesh object for the surface with coordinates x,y,z. The surface is formed of 4 trangles for each rectangular segment, connecting the corner to the avarage midpoint of the 4 points. The evaluation of x,y,z follows the matrix language of Euler. If normal vectors are present, the functions used two triangles in each matrix element, but adds the vectors to the scene. Note that this function does writeln to the output file. If you need an object use povtriangles(). See:
povtriangles (Povray with Euler)
function povtriangles (x:real, y:real, z:real, look:string="", xv:real=none, yv:real=none, zv:real=none, simple:integer=false, include=false) A mesh object Mesh objects are formed of hundreds of triangles. They cannot be stored in Euler strings. So this function write either to an include file and returns a #include statement. Or it writes to the scene file, and #declares an object there. Then it returns an object. Usually, it is not necessary to use an include file. For a description of the triangle mesh and the normal vectors, see writeTriangleMesh(). See:
writeTriangleMesh (Povray with Euler)
function povbox (P1: real vector, P2: real vector, look="") A box with these two corners. The box parallel to the axes. If you need rotated box, use an object containing the box, and the rotation parameter.
function povcylinder (P1: real vector, P2: real vector, r: number, look:string="", open:integer=false) A cylinder with these two ends and radius
function povdisc (P: real vector, v: real vector, r:number, d: number=none, look:string="") A disc with center, normal and radius If d==none the disc used the pointsize for its thickness.
function povintersection (v:string vector, look:string="") Intersection of the objects in v v : a vector of string, containing the objects.
function povunion (v:string vector, look:string="") Union of the objects in v v : a vector of strings, containing the objects.
function povmerge (v:string vector, look:string="") Merge of the objects in v Merging removes the inner boundaries v : a vector of strings, containing the objects. See:
povunion (Povray with Euler),
povintersection (Povray with Euler)
function povdifference (v1:string, v2: string, .. look:string="") v1 minus v2
function povcone (P1: real vector, r1: number, .. P2: real vector, r2: number, look:string="") A cone with these two ends and radii.
function povsphere (P: real vector, r: number, .. look:string="") A sphere with midpoint and radius.
function povplane (P: real vector, d: number, .. look:string="", clippedby:string=none) A plane with a'.v=d, a=[x,y,z]. Note that the plane is really a half space, unless it is clipped. For clipping use any full object.
function povpoint (P: real vector, .. look:string="", size:number=none) A point The size will be the radius of the sphere. By default it is the defaultpointsize.
function povsegment (P1: real vector, P2: real vector, .. look:string="", size=none) A line segment between the two points
function povarrow (x: real vector, v: real vector, look:string="", d:number=none) An arrow d : The thickness of the arrow. By default, this is the defaultpointsize
function povdefine (a:string, b: string) Declares an object in Povray Sometimes, you wish to define an object in Povray, not in an Euler string. You can later use the objet by name. You can also define other things, like finishes in Povray.
function xrotate (a) := " rotate "+deg(a)+" *x "
function yrotate (a) := " rotate "+deg(a)+" *z "
function zrotate (a) := " rotate "+deg(a)+" *y "
function povobject (a:string, look:string="", .. translate=none, rotate=none, scale=none) Pov object scale : A vector or a scaler to stretch the object. If a vector is used its coordinates are the factors in each of the three directions. rotate : The rotation parameter. This can be a vector, which contains the rotations around the x, y, and z axis in this order. The values must be in radians. Usually, you want to use the functions xrotate(a), yrotate(a), zrotate(a), which return strings. These strings can be concatenated for the rotation parameter. translate : A vector for the translation.
function povsurface (f:string, look:string="", container:string=none, .. maxgradient=5, open=true) Implicit surface The surface is defined by f(x,y,z)=0. f : Contains the formula f. Povray uses a different syntax for mathematical functions. E.g., pow(x,2) must be used instead of x^2. Please refer to a Povray manual. The file functions.inc is #included in povstart(). maxgradient : If 5 is too low and the surface looks ugly, use a higher value at the cost of increased time. open : If false, the cube will be filled between the surface and the cube. Effectivly the set wherer the function <=0 will be visible. container : A box containing the surface. Default is povbox(-1,1).
function povclear () Remove all temporary Povray files.
function pov3d (x, y=none, z=none, xmin:number=-1, xmax:number=1, ymin:number=-1, ymax:number=1, r:number=none, n:index=40, file=none, axis:integer=7, look:string=none, axiscolor:integer=gray, zoom=none, distance=none, angle=none, height=none, light:real vector=[2,3,4], lightcolor=white, background=white, povray=true, w=450, h=450, shadow=true, center=[0,0,0], fade=0, xv:real=none, yv:real=none, zv:real=none, niveau:real vector=none, dniveau=0.02, niveaulook:string=none, add=none, loadimg=true, anaglyph=false, fscale=true, scale=true) Multi-purpose function to plot 3D in Povray pov3d("f(x,y)") : plots a function pov3d(x,y,z) : plots a surface given by x,y,z xmin,xmax,ymin,ymax : range x and y n : resolution for x and y r : alternatively radius for quadratic or polar plots cx, cy, cz : center for r file : used, if not the defaultfile="current" (without .pov) color : color of the plot axis : 1,2,4 or sum of these for x, y, z axis axiscolor : color of axis zoom, distance, angle, height : see view() light : direction vector to the light source lightcolor : color of the light background : color of the background povray : if true, the Povray program is called w, h : size of png aspect : if not 1 w=aspect*h loadimg : if false, the image is not loaded into the notebook. See:
view (Euler Core),
view (Basic Plot Functions),
view (Maxima Documentation)