Showing posts with label Projects. Show all posts
Showing posts with label Projects. Show all posts

Sunday, July 19, 2015

Simulating Physics!

I tried do this for a while now and I have to admit it was more challenging than I thought. I had to revise some topics on physics just to get a clear handle on theories I was trying to simulate. Overall, it was a fun project and I am glad it came out just well.

My intentions were to simulate physics based environment where object would be acted upon my real-world-like physical forces. I know there are libraries out there that does this for us and also provide better performance and speed. But, I wanted to try it on my own.

Here's how I divided my work:

1. The Core
The Core package consisted mostly of physical quantities such as Position, Velocity and Acceleration. They mostly had the simple mathematics in them, that did most of the dirty works.

2. The Environment
The environment provides room for existence to the elements and it was my main engine where the elements were added and were acted up. Environment had its own properties like gravity, air frictions and boundary.

This piece of code represents general work in this module:

for element in self.elements:
    if element != selectedParticle:
        element.animate()
    element.draw(self.screen)
    self.handleCollision(element)

3. The Element
Element was my abstract representation of real-world object which had properties like mass, color, velocity, position and many others. Elements were added to the environment and where subjected to forces in the environment.

4. Objects
I started with a Circle, that represented a ball like object, and worked my way up-to simulating square blocks. Circles, besides representing a real-world ball, acted as pressure-points for other objects. Pressure-points were useful because these were the actual points that worked as points for exchanging forces upon collision which simulated all sorts of interesting properties like translation and rotation easily.

For example a bar consisted of two pressure points at either end. This would allow us to easily simulate bar-like properties especially rotation experienced due to difference in direction of force at either end of the bar.






The point of collision besides those pressure points could be interpolated easily. Square had a similar layout. It had these bars as its edges, protecting it from all angles.

4. Collision Handling
Collision Handling was modeled using the principle of conservation of linear momentum combined with law of conservation of energy. There was a small problem I face while implementing this approach to my models. The problem was the behavior of  objects upon interaction while there velocity neared zero. There was only one force acting that time, and it was gravity which was constantly pulling objects downwards. This was a problem, because when the objects were on top of each other, the object would collapse, unrealistically, because they had no force left in them to counteract gravity. There was a simple workaround to the problem, but it was not a wise one. Whenever two object came in contact with one another, a small force(in all four direction) would always be acting to prevent collapsing thus separating objects apart.

This was the model I went with. I am planning to share the code in near future as well. Here's a small video of the program in action:



It's not much, but it was a fun :) Let me know if you have any suggestions or feedback. Thanks!

Monday, October 27, 2014

Triplet Extraction from Sentence [Implementation]

Many sentiment analysis tasks require extraction of sentence triplets, ie. Subject - Verb - Object, from a sentence. While there are many approaches to the problem, I recently stumbled upon a fairly easy-to-implement algorithm in a research paper (http://ailab.ijs.si/dunja/SiKDD2007/Papers/Rusu_Trippels.pdf).

Wednesday, August 13, 2014

Morphological Analyzer for Nepali Text

Morphology is the part of linguistics that deals with the study of words, their internal structure and syntactically their meanings. A Morphological Analysis is the process of providing grammatical information of a word by detecting its morphemes. A morphological analysis generally consists of following information:
Word segmentation
Part-of-speech tagging
Lemmatization

These are the very basics of linguistics which lays ground to many other applications. There are various different tools and resources available for morphology analysis of popular languages such as English, but morphological analysis of Nepali texts had been in a shadow for long. Fortunately, the need of these analysis has slowly been recognized.

Monday, May 19, 2014

Saturday, May 3, 2014

Farty Bird :D

Finally my month-long exam is over and I can finally concerntrate on one or two projects in hand and I will certainly be blogging about it.

The Farty Bird :D
So what's with the "Farty Bird" you may ask? Well, my 11-yr old brother wanted me to make him a game, which he wished to call the "Farty Bird" and he also promised to help me during the development process, the offer I couldn't reject.

Monday, February 17, 2014

Friday, January 31, 2014

Saturday, January 11, 2014

Tuesday, December 10, 2013

Completed my Particle Viewer App

Finally, my "Particle Viewer" Application is complete. I have been working on it for long and it really feels good to see it running. For those who don't know, its a 3D particle analysing tool that is used to study particle behaviour inside a container. The containers are the STL files which are also rendered using the application.

Particle Viewer

Saturday, November 23, 2013

Reflection, Refraction using CubeMapping.

Reflection, Refraction is fairly easy in OpenGL using both Shader and normal OpenGL pipeline. Today I tried both the classical method of Reflection Mapping and also using shaders.
The main objective of today's work was to render shiny Metals and Glass. The shiny metal needed a simple reflection mapping. The result is shown in the figure below:


Friday, November 22, 2013

Setting up Github Home Page.

Today I did a very basic CSS to design my Github Homepage. I am not much of a designer and have only basic CSS skills, so I was preety excited to work on it. Though, there's not much to see, the page is still under construction, I am happy with what I have for now :D 


Wednesday, November 20, 2013

Displaying Excel in Webpage. [Excel2HTML]

Working on my report generation project, today I tried to display Excel data in JSF powered pages using Java. First I looked for existing libraries/extension for Java that would help me display Excel data in HTML. I found a pretty good library too, called the ZKSpreadSheet. Here's the link : zkspreadsheet. It's very powerful, but not exactly what I had in mind.

Snapshot of Excel Display in HTML

Monday, November 18, 2013

Metal Effect using GLSL in OpenGL.

Today I tried to produce a like-metal effect to objects in OpenGL using GLSL. I implemented Phong's Per pixel shading in GLSL on top of a Brushed Metal Texture. I set the metal's material property using references from the internet.

I haven't added reflection (cube mapping) here, as it looks fine and also because its just a simple STL viewing interface.

Here are some of the snapshots:

Thursday, November 14, 2013

Monday, November 4, 2013

Made a Code Viewer For Blogger.

Today, I made a really simple Code Viewer that allows Blogger Template to render Source Code in an effective or rather attractive and readable form. It's not much of a big deal, but I was  looking for a similar plugin for this blog some 2 days ago and realized how simple it is. So, I thought of making one.


Saturday, November 2, 2013

Friday, November 1, 2013

Wednesday, October 30, 2013

Made a Javascript Cleaner.

I am not an expert on Javascript nor I am that familiar with the language, but today I tried to do something that involved Javascript so that I could learn. So I thought to coding a Javascript-Cleaner which would help me understand its sematics on the process :D

Preview