To illustrate the meaning of a Curved Spacetime I have created a number of matlab programs related to curved surfaces. Many of these programs are completely general and can be useful in other contexts.

Matlab to Povray

I have written a converter (a matlab script) that creates a PovRay file from a matlab generated three dimensional scene. PovRay is a free raytracer available online, at The converter is called rjmat2pov.m and is very simple to use. After running your matlab script to create a three dimensional image, type rjmat2pov('filename'), at the matlab prompt, and you will get a povray file called filename.pov that you may render as any other povray file. What rjmat2pov does is that it finds all the visible surface elements in the matlab scene, and divides them into the natural triangles that they are made of and makes a PovRay mesh2 object out of them. The colors and reflection properties are also translated although the translation of the reflection properties is rather approximate (different types of reflection properties are used). Any light sources are also translated from the matlab scene to the povray scene. There is plenty of room for improvement of this code. Unless there are very many surface objects and large colormaps it should work just fine however. Below, the converter and five necessary subfunctions are downloadable. Right-click the links and choose Save Link Target As ...


Put these in your matlab directory (or somewhere else in the matlab path) and you should be good to go. There may however be bugs in the program that I do not know of, and I take no responsibility for any problems that may arise through the use of this converter.

Matlab library

Below is a link to my current matlab directory of functions. Most of these functions are related to illustrations of surfaces. In particular the function "putonsurf" is useful for giving an appearance of a painted line on a base surface. There are 80 functions in the library (including the above linked files concerning Povray). Inserting these files into your own matlab directory (in the matlab path), and typing "help functionname" at a matlab prompt, will give you a description of the function "functionname". I however make no claims about the completeness of these descriptions.


Here is a link to a so called "tarred" version of the above linked matlab directory, which allows for downloading the library and the files therein as a single file.


While to the best of my knowledge all of the programs work fine, I take no responsibility for any problems that may arise through the use of these programs.

Matlab example

A short matlab code utilizing the putonsurf command can be found here. It produces the following image: