Friday, June 27, 2014

Waves on a water surface

This project was sent to me by a student in belgaum via FB. It was his end sem project.
The crux of the code is in the function fnc()...
// variable stp is initialized to 1 hence the mesh is having 300 horizontal and vertical lines
// MAX is 300
// for every intersection of x , y
// rpl and nrm are two arrays with ripple values of the mesh and the normal to the wave

void fnc()
{
int i,j;
double x,y,z,w;

w=-MAX*stp/2.0;    // this works out to -150

for (i=0;i<MAX;i++)    // i varies from 0 to 299
{
y=w+(double)i*stp;       // this y varies from -150 to 150

for (j=0;j<MAX;j++)     // j varies from 0 to 299
{
x=w+(double)j*stp;       // this x varies from -150 to 150

z=2.0*sin((x*x+y*y-phase)/100.0);   // this is the sin wave which gives this mesh its wavey nature
                                         // for more refer=> Link
rpl[i][j][0]=x;
rpl[i][j][1]=y;
rpl[i][j][2]=z;       // z is the height field or the height of the wave
}
}
}

Here is the snapshot.

Here is the code.

I had modified the code and took this snapshot where the mesh is being drawn using line strip.

Modification Snapshot:

Hawk Eye

This project by ramachandra and rakshit is about animating motion of the ball going and hitting the wicket.

Here are the snapshots:




Here is the code. Remember this is a c++ project. It runs on Ubuntu platform with opengl libraries added.

Sinking Ship

Namratha and sweekruthi worked on this existing project. The modification done to the sinking ship project that has been done is the ice berg becomes two pieces... both the pieces move down and sink.

Here are the snaps:
Moving....
 Collison....

 Pieces of iceberg and ship sinking....


I just want to add something to explain how this pieces of ice cube and their rotation was achieved.

Here is the code which does the trick.
/* TO DRAW ICEBERG */
void ice()
{
    glPushMatrix();
    glTranslated(450,50,0.0);
    glScaled(10,10,0);
    glColor3f(0.0,1.0,1.0);
    if(c>0)                          // This flag is used to indicate if ice berg is
    {glPushMatrix();          // intact or split into two after collision
    glTranslated(0,x,0);      //move the ice bergs down all the while rotating them.
    glPushMatrix();
    glTranslated(7,2,0.0);
    glRotated(-x,0,0,1);      // clockwise for the right piece.
    glTranslated(-7,-2,0.0);
    glBegin(GL_POLYGON);
        glVertex2f(7,2);
        glVertex2f(8,3);
        glVertex2f(11,18);
        glVertex2f(12,19);
        glVertex2f(12,3);
        glEnd();
        glPopMatrix();
        glPushMatrix();

        glTranslated(12,3,0.0);
        glRotated(x,0,0,1);           // anti clock wise for the left piece.
        glTranslated(-12,-3,0.0);
        glBegin(GL_POLYGON);
        glVertex2f(12,3);
        glVertex2f(12,19);
        glVertex2f(17,18);
        glVertex2f(18,3);
        glVertex2f(19,3);
        glEnd();
        glPopMatrix();
        glPopMatrix();
    }
    else                                 // if ice berg is intact draw one piece
    {                                     // without any transformations
        glBegin(GL_POLYGON);
            glVertex2f(7,2);
            glVertex2f(8,3);
            glVertex2f(11,18);
            glVertex2f(12,19);
            glVertex2f(12,3);
            glEnd();
            glBegin(GL_POLYGON);
            glVertex2f(12,3);
            glVertex2f(12,19);
            glVertex2f(17,18);
            glVertex2f(18,3);
            glVertex2f(19,3);
            glEnd();
    }
    glPopMatrix();
}
The variable c is global and it is set in the display function
like this...
    if(b>250)
    {

        c+=10;
        display3();

    }
Here is the complete code.

Simulation of Train

Kudos to Kusuma V(1CE11CS025)... This is her original creation. I have been trying to get adsense work on this blog but they have issues with plagiarized content. So am trying to post original projects of our students.

There are three trains which move on a track. The wheels rotate and they all move one after the other out of view.

Here are a few snapshots.



Here is the link to the code.

Thursday, June 26, 2014

A few Project Ideas - Computer Graphics and Visualization - VTU

Its June,2014 and past the peak traffic to my blog. I'm just writing a post to list a few project ideas that may strike me in the next few minutes. I have one already in mind so will start the list of ideas right away...

1) Furniture Arrangement App:
I have moved to a new home and having quite a few choices to make. I have to arrange furniture in the limited space of about a couple of hundred square feet. Knowing the dimensions of the various items like the sofa, dining set, wardrobe, cot and tables i just am unable to think all possibilities in which i could arrange them. If an interactive app using which a user could move around the objects like furniture to see how much space is occupied or remaining un-utilized would really be helpful.
Also you may make a project for measuring how many buses may enter and leave a bus station like magestic. For that you need to create a top view of the magestic bus stand and represent buses as rectangular boxes something similar to furniture and then implement translation of the boxes along with certain rules to avoid collision, governing their speed and taking care of exigencies like pedestrians walking past. Similar software can be made for airports too.
There is a beautiful theory of NP problems behind this simple app. The technique to enumerate all permutations of furniture in a room may yield an optimum solution. It is not possible to arrive at this solution in any other way(other than exhaustive search).
Read more: https://www.quora.com/What-is-the-most-interesting-math-problem-you-have-seen-recently?ch=10&share=da9a9076&srid=Cmht

2) Animating a Simulation:
After having handled the subject of system simulation and modeling twice and knowing the fact that animation and simulation can be great tools to design systems, I suggest these kind of projects to sixth semester students of VTU. I feel sorry to have suggested something that such students will study in eighth semester. Here is a sub-list of all the simulation/animation projects that one may possibly implement.
a) Single channel queue of either packets in a network or customers arriving at a server/bank teller. Some inputs such as IAT distribution or service time distribution may be input.
Here is a sample image of how the output might look(taken from google images)
b) Multiple channel queue of

customers such as in able/baker problem. Again the distributions may be input.
c) Simulation of a Simple Linear Digital Circuit: Updation of voltages and currents across a circuit such as a counter may be tried.
d) Simulation of an Inventory System such as refrigerator or newspaper. The inventory may be shown as a collection of items or a stack of newspapers.

3) Realization of Widgets:
Several widgets such as button, slide, knob or drop down list may be implemented by the students himself. The output may have all of these in a single screen.

4) Polymesh editor:
A rudimentary polymesh editor which is explained in the text book by edward angel may be improved to edit positions of individual points.

5) Animating Vodafone Zoozoos:
This is a project on my wish list. I know how they made the ZooZoos and if a program generates the animations they will look robotic.


I hope to keep adding to this list of ideas and it may grow to a large size. A good student may be able to implement these on his own.