Plotting algebraic surfaces using Mayavi

00_postFigureWho says math is not beautiful? Anyone who doubts the beauty in math must check out algebraic surfaces.

An implicit functions has the form:

F(x,y,z, ...)=c

where, c is an arbitrary constant.

For example, the implicit equation of the unit circle is x^2 + y^2 = 1  and the equation x^2 + y^2 + z^2 = 1  describes a sphere of radius 1.

An algebraic surface is described by an implicit function F(x,y,z) = c . It may be rendered using Mayavi by evaluating the expression F(x,y,z)-c=0  on a regular (specified) grid, and then generate isosurface of contour value equal to 0.

Here are some examples of algebraic surfaces plotted using Mayavi:

I wrote a quick function called implicit_plot for plotting algebraic surfaces using Mayavi. The most important argument to the function is of course the expression  F(x,y,z)-c=0 as a string. It is probably not the best function, but the idea is to show how to plot implicit surfaces. The code snippet is included at the end of this post. Suggestions for improvement are always welcome.

Continue reading

Advertisement

My experience of the edX’s Computer Graphics course

StanfordDragonSmallMy interest in computer generated images and animation goes back to when I was in my 9th grade. Our computer teacher (Miss. Banurekha) wanted me and my dear friend Siddharth Choraria to participate in an inter-school computer graphics competition. I wasn’t any computer rock-star, but she had seen my pencil-sketches on the class notice board and thought that we do something useful. Of course, Siddharth  was a brilliant student and we worked well together.

We spent several days and nights on the project. We had decided to portray a short story about the inevitable effects of war on human society. After I drew each scene on a graph paper, we manually transferred the co-ordinates (of the best-fit lines approximating the curves in the image) to the computer and drew on it using GW BASIC. There was no concept of key-framing, so we redrew each frame repeatedly, changing only the portions required for creating the animation. We also had no idea that we could use matrices multiplications to transform objects in CG.

Since then I have been very interested in computer graphics. However, I never really took the deep plunge to explore the CG world. So, when the opportunity to learn modern computer graphics from one of the world’s best known professors of CG, Prof. Ravi Ramamoorthi, came in the form of a MOOC course (Foundations of Computer Graphics BerkeleyX), I just couldn’t resist. My main motivation for the course was not only to make pretty (CG) pictures, but also to learn 3D geometry used in CG, ray-tracing and OpenGL so that I could use them in other areas such as computational imaging, scientific computation and visualization. I also wanted to know how people create photo-realistic effects.

Continue reading