Statistics

Total Posts: 34
This Year: 0
This Month: 0
This Week: 0
Comments: 160


RSS 2.0

Recent Posts


On this page....

Recap from Øredev 2008
A very unpleasant awakening...
The Running Mate - The geometry calculations

Archives

 Full Archives By Category
 2007 Calendar View

Categories


Admin

Sign In

Acknowledgments

DasBlog Theme Design by: Tom Watts
E-mail: Send mail to the author(s)
Theme Image by: dreamLogic

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

 Tuesday, November 25, 2008

Oredev200px.png

Last week, I visited the Øredev conference. I had a gread time and since this is the forth time I attend the conference, I can see how much it has grown from the first year in 2005. Back at this first conference in 2005 I presented myself together with Magnus on the topic of AJAX which was a bit of a hype at the time. I don't know why I did not even blog about this then but sometimes I am a lazy blog writer... :( Anyways, seeing all these great speaker it does trigger an enthusiasm to get back into the game. We'll see, maybe next year I'll make a shot at present something at some conference. Certainly Øredev would be my first choice. If they would let me in again... :-)

This year the conference was for a whole week. Two days with workshops and courses and three days with regular conference sessions. I visited the 3 days only this time. Although I probably did not manage to always pick the topic that suited me the best from those available, I think I still got a little something out of everything.

The topic of the conference was "Share Knowledge" and I think this is certainly true and a well chosen phrase. But most of all, for me, it is about getting the inspiration to dig into new fields of interest. Most, if not all speakers are very dedicated about their own topics of interest and I believe all of them spend a share amount of their own spare time to become as knowledgeable as they are within theses areas. This is the essence of passion I think. That you volunteer to walk the extra mile in order to stay on top of things and in control. Naturally this brings with a certain amount of enthusiasm in the air that is easy to grasp and feel. So, to me, the importance of this visit boils down to this important sentence: 

It becomes easier to remember that it is fun and rewarding to stay passionate about your work after a visit to Øredev.

This is a simple statement but in essence it often means that you will pick up a work related book after work or sit down in front of the computer once again after an already finished 8 hour session during the regular work day. An easy thing to say, but less simple to achieve. But if you are passionate about something it definitly becomes a lot easier. Essentially:

Passion is what drives us to become better at what we do.

Another nice thing about Øredev is that it there are many cross-discipline tracks. So it is easy to slip into the Java track, or the Testing track for instance when you feel the curiousity of a topic. There were 12 different tracks to choose from this year so I think it was quite easy to find something interesting somewhere. Naturally, there were sessions that collided making me bring out the dice, but video recordings of sessions are coming up I hear. So this parapgrah basically brings on the next important punch liner:

Øredev makes it possible to think a bit more outside the box you tend to place yourself in after weeks and weeks of regular work.

I find it a bit hard to retell which sessions I attended and what I thought about them. Basically since it would be a book writing that I never would finish. But I do say that the absolute highlight for me this conference was to see and hear Robert C. Martin speak. His book Agile Software Development, Principles, Patterns and Practices has meant a lot to me as a software developer. It has completely revised the way I think about code and the importance of making a good design. There were a lot of quite famous people on the conference so I'll just skip the remaining name dropping here and instead urge you to view the excellent program selector (as already linked to above).

Oh, one more thing definitely worth mentioning:  Øredev did support this year builing schools in Africa via UNICEF which I think was an honorable thing to do. I bought a brick at the conference and I encourage you to do the same. It is probably never too late to be a hero. :-) 

Last but not least:
Mucho thanks to the Øredev team that pulled this togheter once again this year! Looking forward to next years conference already!

 

Tuesday, November 25, 2008 6:20:47 PM (GMT Standard Time, UTC+00:00)
 Tuesday, November 18, 2008

This morning I woke up to a real nightmare. Yesterday I had set the alarm on my mobile phone to wake me up at 6.30 in the morning as usual. I knew when doing this that I probably would suffer a bit waking up since I went to bed way too late. But what the heck, it is only sleep, my last train of thought went before going to sleep. Oh, did I pay for this a couple of hours later!

Since my girlfriend wasn't getting up as early as me I had been particularly careful to set the alarm to use an increasing volume. Also I turned off the phone battery vibrator since this tends to make the whole room vibrate when the alarm rings, which even wakes up our cat Disa who usually sleeps at my feet.

Before I go on and tell you about my nightmarish wake up, I'll tell you about a previous experience with another brand from this particular mobile phone manufacturer. That mobile phone screamed out with a terrible melody whenever the battery was getting low. In most cases, this is probably a good thing since you really want to make sure this never happens. But with this particular mobile phone, it was not configurable to turn this feature off. So naturally, the alarm woke us up in the middle of the night on a number of occasions.

Eventually I managed to learn that phones' user pattern to take the battery out before going to sleep. Or even better, plug in the electric charger... Anyways, I think most people would value sleep over the mobile phone not running out of battery.

So, back to my devilish wake-up this morning. At 6.30 this morning the mobile phone alarm started ringing at a low volume as should be. Unfortunately the alarm went off during the wrong time of my sleep cycle so I was really dead tired with most of my brain neurons still sound asleep. I also woke up finding that my left arm was missing. I could not find it anywhere.

As the sound of the alarm screamed louder and louder, I slowly realised that my arm was gone because I could not move it. It was completely lame. I did not feel it anymore.

This can happen if you sleep with the arm in a weird position for a long time. It will wake up again and becoming fully functional after a couple of minutes of free dangling time. So I actually did not panic. Yet.

So that leaves me with one arm and a tenth of my normal brain power to turn off the phone. Piece of cake you would think?

A regular alarm clock usually has one big “turn-off-alarm button” that is easy to find. This morning I realized that there is a reason for this. In my delirious dreamy state, I started pushing all the buttons all at once on the phone with my functional hand. But nothing happened. Instead the alarm started to ring louder and louder. With a steady arising panic I begun to realize that the alarm would never ever again be turned off. I would have to live the rest of my days with this noise ringing louder and louder in my ears.

So I fumbled on in my quest to turn the damn thing off rushing out of the room, stumbling over poor Disa who for a second managed to scream louder than the phone. Perhaps if I poured water on top? (on phone, not cat!) The electronics probably doesn't like this so that would probably work.

Fortunately, my brain power was slowly booting up again so I never fulfilled my idea. Instead my one hand remembered the old trick and after lots of struggling (one hand!), I managed to pull the plug out of the sound by removing the battery.

Phew! Silence! Finally!

But the screaming alarm was still reverberating in my head with anguishing anxiety. And I knew that my girlfriend was probably lying in her bed cursing me and only me for this! Well I curse the phone in turn!

Ok, so having woken up a bit and sitting here at breakfast with my beloved cop of coffee, again being able to hold it with two hands, I think I realized what went so terribly wrong this morning. Firstly, I now grasp that I sometimes never will learn how to turn the alarm off the ordinary way. Especially not so with one tenth of my brain power and one arm at my disposal. Secondly, for some reason the phone key lock is sometimes not lifted when the alarm goes off. This is clearly a software bug since normally, one only has to puch any button to turn the alarm off. Devastating bug I would say... And if it is not a bug and if there is a logical explanation to it, well even worse. If I find this to be the case, I might even reveal what brand of mobile phone it is in this blog post.

Some thoughts on the future of mobile phones

Mobile phone companies have started to talk a lot lately about turning the mobile phone into a generic all-in-one toolkit; kind of like a Swiss army knife. Keys, credit cards, you name it. I would love for this to happen. But I also would love the phone software developers to think in turns of how these devices are actually used in each scenario. Why is there a big button on the alarm clock and how can this be simulated better and always work on a mobile phone?

These type of questions, I think is always extra important to ask for product manufacturers. And particularly so when they are to support a new functionality that it originally was not designed to support. As in simulating an alarm clock when you are in fact a mobile phone.

Naturally, looking back at this morning I laugh about my desperate attempts to turn the alarm off. But I also think that I never will buy a mobile phone from this particular manufactorer again. But then again. Perhaps I will. I am usually less cranky after I have finished my morning cop of coffee.

Tuesday, November 18, 2008 6:58:41 AM (GMT Standard Time, UTC+00:00)
 Sunday, November 02, 2008

This blog post is part of a series that start here.

I have already descrived what the Running Mate is and why I would like to build such a thing. Now, it’s time to get my hands a bit dirty with the mathematical theory that’s needed for this. I would not say that it is an advanced mathematics, but it is definitly a fun applicability since it is really easy to see and understand the purpose and need for the mathematic formulas.

So here’s my 10 km run again. Let us focus on small area of this run: the square that the red arrow points at:

If we enlarge this square area, it would look something like this:

As you can see, I’ve painted some blue stars on the map and high-lighted the road with a black line. The blue stars signify the GPS points that my running mate is picking up with the help of the satellite(s). I don’t know how often these coordinates actually come, but naturally, I will not be able to get the exact track of my run. By drawing a line between the coordinates we will se how the running path looks like according to the PGS system. Here is another image high lighting the coordinates with their straight lines between them in an X-Y graph instead:

 

Calculating the distance between these stars in this graph is simply a matter of utilizing the Pythagorean Theorem. I honestly think that no matter how rusty your math knowledge becomes, this formula will forever stick in your head:

z2 = x2+y2,

z is evidently being the sought distance between two of the stars in my graph. So in order to withdraw the distance between the second and the third coordinate, the formula becomes:

z2 = (x3-x2)2+(y3-y2)2

Calculating all distances between all coordinates on the map gives us the total distance which is exactly what shapelink.com did for me when I utilised their service to draw my run on a map. Basically, I gave them the coordinates by clicking on the map and they drew the lines in between these coordinates and calculated the total distance of the run.

But we are still not at where I want to be: getting the current time comparison of each spot to a previous run. And this is where the fun begins.

The difficult part here would be to compare different coordinates from different races with each other. Naturally, the coordinates will not be on the exact same place as the previous coordinate. This image will illustrate this:

Here I have high-lighted a second race coordinate with red stars. As you can see I did not run the exact same spots as I did the last time I ran the race. The deviation shown is most likely larger than what would be in reality considering that the track I run on is quite narrow. But nevertheless, I obviously have to take this into account when comparing the coordinates.

Naturally each coordinate also has an associated timestamp. As I see it, finding the coordinates that are closest to each other in order to calculate the difference between the two timestamps can be done in at least two different ways. Let us start with the easiest one.

Algorithm: Finding the closest coordinate

So, as this image shows, we have to calculate the distance (d1, d2, and d3) for each red coordinate to all blue coordinate and pick the one that is the closest to the red coordinate. The needed calculation is basically just a matter of using the Pythagorean Theorem again a number of times, so it is a piece of cake really.  

In the example in this image, the d3 distance is obviosly the shortest one so this coorrelating blue coordinate is selected as the one to compare against the red coordinate. The difference in timestamp between these two coordinates would give you the desired result for the Running Mate application. If we don't need  a more accuracy result, this is where we would stop.

However, of course we want more accuracy, so let us move on to the more interesting algorithm.

Algorithm: Interpolating the time

As you might have gathered, the previous algorithm is not particularly accurate when the number of coordinates is low for a run. If the number of coordinates approaches infinity (as mathematicians do love to state) the result would indeed be good. But if merely a few coordinates would have been used for the whole track, naturally this first algorithm just doesn’t cut it. This is when time interpolation is needed.

In this image we are focusing on two of the blue coordinates, B1 and B2, that lies closest to one of the red coordinate, R1. Basically, we want to find the V (as in Virtual) coordinate in order to find the time interpolation between the B1 and B2 coordinate. All we have to do is to calculate the ratio of the distances between the coordinate V and the B1 and B2 coordinates. This ratio will give us the needed number in order to calculate a new blue time stamp at which the virtual V coordinate is located.

So in theory, this algorithm seem to boil down to the following steps:

  1. Find the two blue stars that are closest to the red star.
  2. Find the coordinates of the virtual coordinate V.  
  3. Calculate the ratio of the distances between coordinate V and the two closest blue coordinate.
  4. Calculate the virtual timestamp of coordinate V using the ratio found in step 3.
  5. Compare the timestamp for the red coordinate with the new virtual timestamp for the coordinate V.

The only difficulty here really lies in the second step of this algorithm, i.e. finding coordinate V. So let us concentrate on the information we do know, i.e. the known variables. Consider the following image:

Here, d1 is the distance between B1 and R1, d2 similarly between R1 and B2, and finally d3 being the distance between B1 and B2. Ok, these distances are not known, but we do know that if we have the coordinates, we can easily calculate the distances using … yes you guessed it: the Pythagorean Theorem. So we can consider these distances as known.

Ok, next would be to calculate the angle α at the B1 coordinate. Knowing all distances d1, d2, and d3 in this triangle we can utilize the Law of cosines:

d22  = d12 + d32  - 2d1d3cos(α)

The only unknown variable here is the α angle which a bit of algebra magic solves for us.

So when we have α, we can calculate the distance dv, i.e. the distance between B1 and V coordinates with the following basic trigonometry formula:

Cos(α) = dv  / d1.

Again, a bit of algebra gives us dv and you know what? We are actually home safe now with this knowledge. Basically we now know the ratio in distance V between B1 and B2. Now all we have to do is to apply that ratio to the timestamp of B1 to get V coordinates virtual timestamp.

I have not yet had the time to implement the second “interpolating the time” algorithm in my Running Mate code demo as available at Codeplex, but when I have I will delete this sentence and add a comment about it.

Sunday, November 02, 2008 1:54:50 PM (GMT Standard Time, UTC+00:00)