Search Projects

Saturday, June 30, 2012

Mini Project on Bellman-Ford algorithm using OpenGL


Descriptions : The Bellman-Ford algorithm also known as Ford-Fulkerson algorithm is based on the principle that is intuitively easy to understand. Each node A knows the shortest path to node Z, then node A can determine its shortest path to Z by calculating the minimum cost.
Each node connected to another node with a cost, now when the packet flows through a path it result some cost to the network . To minimize the cost of network communication Bellman-Ford algorithm is implemented and the packet flow to the path which costs less in the communication. 

Working Principle
       
               First  we draw the nodes and connecting lines by passing co-ordinate values to a GL_LINES .It will draw the network and connections of the network. The shortest path is calculated by using Bellman-Ford algorithm using the following formula-
1.Initialization
                                             Di=∞; for all i≠ d                                 (3.1)
                                             Dd=0                                                     (3.2)
            2.Updation
                                             Di=minj{Cij+Dj}                                              (3.3)
Repeat step 2 until no more change occur in iteration.

To draw the packet we pass the co-ordinate values to the GL_QUAD. Now to move the packet from one node to another node we draw the packet at different points of co-ordinate using for loop. The loop will make the polygon in the certain color specified from the starting co-ordinate to the end with the incremented value. Now we cover the part of the long polygon which is generated in the loop using the same co-ordinate values and loop coloring with black. The black color cover the previous color and this makes the sense for the movement of the packet. Similar thing is done for all the packet movement

Usages : 
Mouse interaction : Click on the node to choose the node from where the shortest distance is to be measured. Click on quit block to exit the program.
Key board : The program will ask after every node select, showing the shortest path if you wan to continue or not press y to continue press n to exit the program.

Download : Project Code

Friday, June 22, 2012

OpenGL mini project on Traffic signal

Descriptions : As we know, the traffic signals direct the flow of traffic with the exemption of signals with turning arrows which should be compulsory in accord with each other.Traffic signals helps us to drive our vehicles in a safer manner lowering the risk of accidents, if properly followed.

In this Project simulation, we are implementing  Traffic Signal. We have three lights in the signal Red , Green and Orange. Each light have some meaning . Red means stop , Green means go, Orange means ready to go.
Same method we implemented in our project which used in real life .We have used this traffic signal in a cross road to avoid misshapening. When there is green signal it means vehicle can move or run on the road but if this green signal turnoff  and the red signal is turn on then its indicate the driver to stop his vehicle and same time signal allows some other side vehicle to cross the road. But if the vehicle is in the middle of cross or vehicle have cross the signal then there is no meaning of red light for the driver. When we press button R then red light will glow and all vehicles are stop n when we press Y button then  yellow light will glow and all vehicles ready to go .When  we press button G  green light will glow and then vehicle start  moving.  

In this project we have written a loadBMP function to load bitmap images. Bitmaps take up a lot of space compared to image formats, like .PNG, but I chose to use bitmaps because they are relatively easy to load into format that we need. Take a look at imageloader.h. This gives us the basic idea of what loadBMP does. (The actual code for loadBMP is in imageloader.cpp.) Given a filename, it returns an Image object, which contains the width and height of the image, as well as the array pixels, which stores the pixels' colors in the format we want. 


Usages : As mentioned above.

Download : Project code
                    road image
                    image loader.cpp
                    image loader.h