Monday, May 19, 2008

This is how I look when I'm forcibly woken up...


Dee Snider, from "Twisted Sister".

An awesome heavy-metal band of the 80s, never-mind their make-up. ;-)

(That's a guy in the picture, BTW. That's Dee Snider).

Saturday, May 17, 2008

The Lore of the Inverse Square Root function


This one is for all the 3D geeks!

I had posted some useful optimizations for Graphic programmers earlier, and one of the optimizations I had suggested was one I saw in the Quake 3 source code, which performs the inverse square root, i.e 1 / sqrt(x). In 3D Graphics, the question of who came up with the 'magic' constant
0x5f3759df continues to be a question that 3D geeks still seek to answer! Most attribute it to the legendary programmer John Carmack, the man behind the Quake, Doom and all id Software Game Engines. However there are several other people attributed to it, and John himself refused to take claim for the creation of the constant in the mail:

-----Original Message-----
From: John Carmack
Sent: 26 April 2004 19:51
Subject: Re: Origin of fast approximated inverse square root

At 06:38 PM 4/26/2004 +0100, you wrote:

>Hi John,
>
>There's a discussion on Beyond3D.com's forums about who the author of
>the following is:
>
>float InvSqrt (float x){
> float xhalf = 0.5f*x;
> int i = *(int*)&x;
> i = 0x5f3759df - (i>>1);
> x = *(float*)&i;
> x = x*(1.5f - xhalf*x*x);
> return x;
>}
>
>Is that something we can attribute to you? Analysis shows it to be
>extremely clever in its method and supposedly from the Q3 source.
>Most people say it's your work, a few say it's Michael Abrash's. Do
>you know who's responsible, possibly with a history of sorts?

Not me, and I don't think it is Michael. Terje Matheson perhaps?

John Carmack

Why this is so important could be understood by the fact that Chris Lomont, a professor at Purdue took up the task of deriving that constant by mathematical means for the initial approximation of the Newton Raphson method (that the magic code uses), and his 'mathematically and theoretically' brilliant approximation constant turned out to perform WORSE than the constant found in the Quake III source code. So the question that arises is how John Carmack, or the author who originally wrote the code managed to figure out the magic approximation. That could be pretty useful I think for designing other fast mathematical functions.

So this article on Beyond3D.com does a great job of tracing down the original author, or atleast a major contributor, after a great deal of digging around. Check it out:
Origin of Quake III's Fast Inverse Sqrt()

Thursday, May 15, 2008

The Creativity-Killer : Office life


Don't get me wrong. Its not because I'm really unhappy at the fact that my vacations are getting ruined as I have to "WORK" in the office 10 hrs a day everyday (read) but truly a realisation that I came about due to this effort.

The "office life" destroys your creativity, forcing you to do continually work piecemeal on mostly dumb projects that you know will never revolutionize anyone's life, but basically does the routine that people need. Yes, this kind of routine work has to be done by someone, but if you're like me, you will not be the one to get stuck in this zombie culture of waking up in the morning, slaving for 10 hours, and then returning towards late evening, too tired to do anything but slouch on a chair drinking tea and writing about how dumb you feel. One simply doesn't have the time or energy to think about ANYTHING else after returning from office. All one seeks to do is to relax and sleep soon. Gotta sleep early.. office in the morning remember? In short, even if you are good, the routine office life will bring you down to its levels of mundaneness and dumbness and make you feel generally really stupid and out of touch.

This is the typical routine every office worker follows, and my statements are meant for those select few who desire to break away from the system and be different. If you are fine with serving people's routine needs, that is perfectly genuine too. Do not mistake me. I am talking about those people who can be intensely creative, know that they can do better things for people, have confidence in themselves that they can create things that will make better and revolutionize the life of others as well as theirs. The first casualty when you get stuck in the drill of conventional life is your sense of Independent thinking.

A matter of bread and butter, some would say. True. You've gotta do what you've gotta do. However, when there is an opportunity, grab it. Risks are meant to be taken, some big and some small. When you have the chance to some radically better stuff, do it. I have been in IEEE Students' Chapter for the past two years, and was the Secretary at last count. But I felt that it was time to move on and do other things, even though I appeared to have a very good chance at the top job. However, it was a risk nevertheless, leaving IEEE to get back the time to do bigger things, develop new ideas that could potentially be the next big things. I feel I can do it. So risk I must. Risk the general "social standing", risk the chance of not having any work to channel one's energies. This is an example of a small risk, almost negligible. But the basic point does not change. If you want to be different, don't get stuck in any kind of routine. One must follow for a while, and move on to other things to remain fresh and dynamic.

Tuesday, May 13, 2008

The coming ages of immersive gaming?


Just found this interesting looking article about the possibilities offered by immersive large-display systems. Check this out:

Wall-sized, multi-touch 'Missile Command' -- every gamer's fantasy

To quote a few catchy phrases:

"A gentleman named Steve Mason has created a large-scale version of the game that can be played by hand using multiple contact points. The result? Extreme awesomeness." Lol! ;-)

There's a flash video on that page that demonstrates players playing the game live.

I've posted this here, as this has gotten me thinking again about the trends that games will follow in the coming few years. Yes, this particular wall-display system noted above is not really "immersive", but in all essence, I would get completely immersed in such a game! Wouldn't you? ;-) Don't get me wrong, I'm not calling the above game display system "immersive"!

Having been involved in a lot of personal game-development projects, I find it extremely fascinating to note that we are indeed moving closer and closer to the age of true Virtual Reality, where the technology blurs the barriers between what we really believe to be "real", and what we don't. I for one would be the first to question what we indeed are, returning to the age old question of "why are we here?", and "HOW are we here and conscious about it?". Anyhow, the concept of Virtual Reality really raises a lot of interesting questions- technical, business-related, ethical, psychological and philosophical.

More on this soon. Promise.

9 hr 45 minutes a day. 6 days a week. 33 days.

That's the duration of my summer internship. There goes my vacation, can see it fleeing away while I sit in the office.

Have a confidentiality agreement with them, don't want to talk about them anyway. My poor vacation...

Monday, May 12, 2008

Yet another 'Airport Blues' saga


This time around, hanging around Bangalore's Great Airport, I discovered some harsh truths of life. Life is like the Cafe Coffee Day Espresso that you get at the Bangalore Airport. You do not ever get what you wanted, its hideously expensive, it has no sugar, is black and really awful. Stirring it up makes no difference really, ultimately you end up with the same old stuff and its better to drink it up in one quick gulp than one prolonged struggle and bitter taste. And it always tasted better in the good ol' days.

I can say without doubt that THAT was simply the worst coffee I ever had in my life, and saying that would be a gross understatement. I was waiting to pick up my mom, and due to a series of (un)fortunate events ended up reaching the Airport really quickly, and an hour and half early. Bangalore Airport is seriously not the best place to hang out, and they take great pains to maintain and further that reputation. No chairs or waiting lounges at the Arrivals gate. Just one Cafe Coffee Day outlet with smirking faces serving you bad coffee. So I managed to find a seat in the Departures section, and then was sprayed all over with insecticide. The stupid bugger chose to make his grand entry right at the moment I sat down, and sprayed those fumigated kerosene-like smelling fumes all over me, and the people all around me too. Luckily its meant only for mosquitoes and small insects, not animals.

Oh, and I am alive, kicking and have finally returned back to this blog.
Auf Weidersehen!

PS: I speak German now.

PPS: I simply cannot understand how people manage to drink Black Coffee! My theory is that people find themselves awakened by sipping Black Coffee because each sip is so horrible and bitter that it shocks them awake. That's how I stayed awake for 1.5 hours at the airport, and just managed to finish half of my coffee (which was originally half a cup anyway). Gruesome really.

Friday, January 04, 2008

Basic “Google Suggest”-like script

Recently while working on the Google Project, I was messing around with AJAX and figuring out how JSON works etc, so I decided to implement the much talked-about “Google Suggest” thing myself just to test my JSON and AJAX techniques. Turns out it indeed is really simple in concept and implementation, except that the amount of “bells ‘n whistles” you can add is endless.

“Google Suggest” in 5 easy steps:
1. Capture the onkeydown events of the text-box where the person is typing
2. Send the text typed to a server-side script (in ASP, PHP, Perl or any language you prefer). This you could do by passing the server script URL with the typed text to inline frames or XMLHttpRequest suiting your taste and requirements.
3. The server side script will search the database table for entries whose text starts with the text presently in the front-end textbox.
4. This list can be converted to a JSON object, or an XML feed or plain inline-frame javascript etc and will be received back by the client
5. The client will display the received list in a floating DIV or container below the textbox and permit the user to select an entry from that list by either arrow keys or mouse clicks.

So in my script, I wrote this Google Suggest-like tool that would read names from a database and display them as we type.

This code is really elementary with loads of features missing, and lots of optimizations possible. I wrote this script in like 2 hours in the dead of night so wasn’t thinking about lots of goodies and optimizations.

Download the ZIP file: Auto-suggest names

Minimum Requirements: ASP 6.0+ support, Microsoft Access 2000, IE 5.5+, FF 1.5+.

I’ll list out some things that can be added to this code of mine:

1. Add mouse handlers to the drop-down menu to enable mouse clicks on suggestions
2. Improve the elementary keyboard support it gives to include responses to several other keys
3. Optimize the feedback process to the server by inserting a “delay” before sending the typed value to the server-side script. That is, instead of sending the text “immediately” on “every” key-press, wait after a keypress for a second or two and see if the person stops typing. If the person hasn’t entered anything for, say, two seconds then send the text over to the server for searching. This will reduce the load on the server as its obviously wiser to wait for the user to atleast tell the client what he/she has to say before jumping off to suggestions. This is done by Google too.

I’ll add some more suggestions as I think of some more.