OpenGL Program: Earth with Moon Rotating around Sun

My other son had a practical training at Fraunhofer IGD. He wrote an OpenGL/C++ program in Windows where one views the earth rotating around the sun, thereby with its rotating moon, see picture below.



I ported this program to Gtk/Linux. You’ll find the code in openglSunEM.c. The link between Gtk and OpenGL is realized by GtkGlExt. On Ubuntu you have to install libgtkglext1-dev.

openglSunEM can either be called with or without textures using command line flag “-t”. Typing ESC stops the program.

The main geometric transformation is handled in drawGLScene(): draw sun, draw earth, draw moon (which rotates around the earth, which in turn rotates around the sun). The speed of rotation can be increased or decreased with the arrow keys (GDK_KEY_Up, GDK_KEY_Down), one can zoom in or out (GDK_KEY_I, GDK_KEY_O).

The whole animation can be rotated like an arcball, its implementation being in ArcBall2.c.


Number of Combinations for German Tax Id

I was asked by a colleague of mine how many combinations are possible for the German tax id. The German tax id is built entirely from eleven digits. Its specification is given in Pruefziffernberechnung, see Steueridentifikationsnummer in the German Wikipedia. Every person reported to live in Germany is assigned one tax id, even babies and children. 20 years after the death of a person the number can be recycled.

Continue reading

CPU Usage Time Is Dependant on Load

I wanted to write a short benchmark for my son to demonstrate that the AMD Bulldozer 8 core CPU is better than a 6 core CPU from AMD when computing with integers. So I wrote a short C program to compute a recurrence relation using integers only, see C code below. When I ran this program on one core, then two cores, then three cores, and so on, I was a little bit surprised to see that the CPU usage time grew. Indeed, it grew quite significantly: from 20 to 60% up! Once all cores of the CPU are used then the CPU usage does no longer increase. In this case it does seem to have reached its equilibrium.

The AMD CPU is a FX 8120, 3.1GHz. For comparison I used an Intel i7-2640, 2.8GHz, 4 core CPU.

Continue reading