Archive for August, 2007

Being the Creator of the Universe!

There are various explanations to how life came to be what it is: from the big bang theory, evolution to creation. It would seem that at some point all these attempts at explaining the origin of life reach a point where is there an unknown and I like thinking of that as the creator of the universe (yes, I am deliberately avoiding referring to the almighty with the common name known to everyone). Ever wondered what that primordial state (of high density and temperatures that resulted in the big bang) was? Or perhaps who originated that state in the first place? In essence you might agree that creation explanation of the origin of the universe gets to the originator of that primordial state faster than the big bang theory or perhaps even evolution.

The Bible gives an account of creation in six days and there is no reason to doubt that these six days were not millions of years in the first place: our current understanding of a day is the duration of time the earth takes to rotate once on its axis but at the time of creation there was no earth to talk about let alone the sun.

So, the universe was created by a supreme being in however long it (I don’t know the gender of God) took to create the universe. Are you getting the impression that the creator must be one powerful being: its intelligence must be off the charts and such minor inconveniences such as time and space don’t make much sense to it. Yesterday, tomorrow, today and in this moment and eternal moment can all mean the same thing at the same time or different things at the same time. How about that omnipresence? Here, there, somewhere and everywhere all can be the same place or even different places that are not so different. Wouldn’t it be cool to say something like I am going to THE place called “NOT HERE”?

To be a master of an entire creation (living and non-living, matter and anti-matter and all the other stuff that we still have no clue about) must be one boring experience I reckon. Don’t get me wrong, the power is awesome but there is practically no challenge: there is no difference in the notion of yesterday, today and tomorrow and this means that there is nothing that needed to have been known yesterday and something you are finding out today or perhaps something you will find out in the future. Knowledge about everything is known now or perhaps independent of time: what God knows is not tied to the passing of time or perhaps even more clearly it is not tied to the existence of time.

Each of us, as human beings, celebrate or at least mark the time we came into this world and the various events that mark key milestones in our struggle through life. We don’t know what will happen tomorrow but we look forward to tomorrow based on faith and more often than not (at least for those who have lived long enough), we forget what we have experienced in the past and for the now and here, our limitations as beings that possess material aspects mean that we can not experience a moment in its complete entirety so that we can say that we have experienced a second in its entirety: we have blinked and looked at the same time! Our shackles to temporal and physical limitations define the basis of our experience as human beings and perhaps without these limitations life, as we know it, would have much different and even more complicated meaning. Oh, don’t forget that after all these we still hope (at least for those who believe in its existence) to continue living forever (be it in heaven or in hell).

Energy can neither be created nor destroyed: if we, as human beings, are made of matter and and form (soul) and it is acceptable to assume that both are made of energy then the possibility of life after death is not so remote. It just boils down to transferring these forms of energy (matter which invariably decomposes and well the soul, as a form of energy, can’t just cease to be) into other forms of energy.

Leave a comment

Language Integrated Query (LINQ) for Java

One of the much talked about and hyped enhancements in the latest release of Microsoft’s .NET Framework is the Language Integrated Query (LINQ) that is included with languages like C# 3.0 and Visual Basic .NET 9.0. Several new features of the upcoming Visual Studio 2008 code name Orcas leverage and make it much easier to take advantage of LINQ. The theoretical basis of LINQ means that it was only a matter of time before it appeared on other languages and/or platforms.

LINQ represents a more natural way of marrying the relational and OO paradigms in such a manner that both can be supported with the tools that are available to developers today, with additional updates. IBM is working on JLINQ (Java Language Integrated Query) according this article and this is an excellent development though Microsoft did beat them to market with this feature. At this point, it seem JLINQ is an Eclipse-based component which means that you can’t take advantage of it from other Java IDEs like Netbeans. Additional information about JLINQ are scanty at the moment but it would be useful to have an idea of how it relates to the Java language and platform.

1 Comment

Basic Table Tennis Game Sample Code: Ball Animation

The original post about Basic Table Tennis Game Sample Code has generate a lot of interest to an extend that I am now considering producing a more complete code sample. I have most of the aspects of the table tennis game working but since it is a project of my computer graphics unit that is yet to be marked, I am not in a position to reveal all and/or specific details of my implementation. However, for now I can pick out a specific aspect of my working, including the background research I did to get the part working. That explains what your expectations should be for this post.

In the game you have a ball which needs to move between the opposite ends of the table. I suggested that all the various aspects of the game are rectangles (assuming a square is a rectangle with the length and width being of the same magnitude). Keep in mind that this game is basic which means that it is not meant to implement the specific details and/or requirements of a real world table tennis game though that would be an interesting challenge in itself but for now it shall be left for yet another day. The ball, in its motion, needs to be confined to the boundaries defined by the table. For the objective of this post, we need to get the ball moving using OpenGL.

Animation in OpenGL

The books I have read about OpenGL describes it as a state engine which in my understanding means that OpenGL maintains a specific state of the graphics that it renders and any changes are made to the state as a whole and not a single part of it. OpenGL makes use of buffers in rendering graphics on the screen. You have a choice of using single buffer which does not work for animation or double buffer which is what is preferred for animation. Here is how it works with the double buffer: you render a series of graphics on to one of the buffer and this buffer is shown on the screen. In order to achieve animation, you render another image (with changes in the position of specific elements of the image rendered in the first buffer) on to the second before which is then swapped with the first buffer. You use the GLUT function glutInitDisplayMode() to specify your buffer preference (GLUT_DOUBLE OR GLUT_SINGLE).

OpenGL uses callback mechanisms which means that you “tell” OpenGL which function you want to be called when a particular event of interest occurs. Generally the function/method that realizes animation in your application is passed on to the glutIdleFunc(). When your application enters GLUT events loop by calling glutMainLoop(), the function specified in glutIdleFunc() is called repeatedly and this is the best place to cause changes in the image that you display on the screen.

The sample code below does the initial rendering of the image as well as subsequent changes to the original image. This code sample builds on this tutorial here.

float x = 0.0;
float y = 0.0;



int no_pts = 25;

float radius = 0.17f;

glColor3f(0.9f, 0.9f, 0.2f);
for (int i = 0; i < no_pts; i++) {
    float angle = (2 * PI* i) / no_pts;
    glVertex2f(x + radius * cos(angle), y + radius * sin(angle));

x += 0.009;


This are what your includes look like:

#include <math.h>
#include <GL/glut.h>

 The math.h include is needed for the mathematics of calculating the sine and cosine of the angle and of course glut.h gives you your graphics rendering functions. The initial x and y coordinates of the center of the ball are provided as global variables (they are not inside the function) – we don’t want these values to change (e.g. by resetting them to 0.0 at the start or end of the call to drawBall. However their values can be increased or decreased.

To have your animation run, you need to hook your function into OpenGL; recall glutIdleFunc? If you are using the tutorial link provided in this post, you can go ahead and replace every call to renderScene with a call to drawBall.

Note the following calls in the animation code sample:

  • glClear
  • glPushMatrix
  • glPopMatrix
  • glutSwapBuffers

Next time, I will post a sample that includes code to ensure that the ball doesn’t go beyond the boundaries of the table.