Happy Birthday

Birthday Cake by Will Clayton

Happy Birthday, Blog. Jaa, genau heute von fünf Jahren gab es auf diesem Blog den ersten Blog-Eintrag. Seit dem haben genau 673 Einträge das Licht der Welt erblickt. Das sind 134,6 Einträge pro Jahr oder 0,37 Einträge pro Tag. Aber wen interessiert das? Jetzt wird erst mal gefeiert. :D

24.Juni 2011

Watson Fail

Watson fails to recognize a simple Linux command

20.Juni 2011

iDad

iDad.jpg

(via Cult of Mac)

16.Juni 2011

Microsoft Update für Mac

Icon für Microsoft AutoUpdate

Auch auf dem Mac bietet Microsoft für seine Produkte – z.B. Office 2011 – ein Update-Programm an: “Microsoft AutoUpdate” (offizielle Schreibweise). Wer danach jedoch in seinem Anwendungen-Ordner sucht, wird nicht fündig. Statt dessen findet man das Programm im Hilfe-Menü unter “Auf Updates überprüfen”.

Direkt-Link zur Microsoft Hilfe

9.Juni 2011

Chuck Norris and the OSI network stack


Chuck Norris has only one OSI level – Physical

(Hint)

1.Juni 2011

So hätte Apple den C64 vorgestellt

YouTube Preview Image

C vs. C++


C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg.

– Bjarne Stroustrup, developer of the C++ programming language

16.Mai 2011

Email Address

Me: “What email are you using?”

Client: “Windows”

Me: “No that’s… ok, what does the last part of your email say?”

Client: “HTML”

Me: “What? No that’s… still not it. Look, when someone asks you for your email what do you give them?”

Client: “My business card”

11.Mai 2011

Rectangle Intersection Test (with C#)

For a software project I needed to check whether two rectangles intersect (or overlap). What made my problem complicated was that one of the rectangles could be rotated. While this problem seems to be trivial (to a human being), it’s not that simple to implement. It took me a while to find the right answer.

Intersecting Rectangles

Now, the solution to this problem is called a separating axis test. Basically this means: If I can find an axis (read: line) that separates both rectangles, then they don’t intersect/overlap. (Actually this works for any convex polygon; see below) Of course, if the two rectangles don’t intersect, there are undefinitely many possible separating axes. Fortunately we can use the edges of each rectangle as axes and testing all of the is sufficient.

An axis separating two rectangles

I won’t get into the details of this algorithm here – it’s sufficiently good described in the article mentioned above – but basically you check for each point on which side of the separating axis it is. If all points of the rectangle A are on one side and all of rectangle B are on the other side, then we’ve found a separating axis.

Here’s the implementation of the method testing where a single edge (represented by points x1 and x2) is a separating axis:

/// <summary>
/// Does axis separation test for a convex quadrilateral.
/// </summary>
/// <param name="x1">Defines together with x2 the edge of quad1 to be checked whether its a separating axis.</param>
/// <param name="x2">Defines together with x1 the edge of quad1 to be checked whether its a separating axis.</param>
/// <param name="x3">One of the remaining two points of quad1.</param>
/// <param name="otherQuadPoints">The four points of the other quad.</param>
/// <returns>Returns <c>true</c>, if the specified edge is a separating axis (and the quadrilaterals therefor don't 
/// intersect). Returns <c>false</c>, if it's not a separating axis.</returns>
bool DoAxisSeparationTest(Point x1, Point x2, Point x3, Point[] otherQuadPoints) {
  Vector vec = x2 - x1;
  Vector rotated = new Vector(-vec.Y, vec.X);

  bool refSide = (rotated.X * (x3.X - x1.X)
                + rotated.Y * (x3.Y - x1.Y)) >= 0;

  foreach (Point pt in otherQuadPoints) {
    bool side = (rotated.X * (pt.X - x1.X) 
               + rotated.Y * (pt.Y - x1.Y)) >= 0;
    if (side == refSide) {
      // At least one point of the other quad is one the same side as x3. Therefor the specified edge can't be a
      // separating axis anymore.
      return false;
    }
  }

  // All points of the other quad are on the other side of the edge. Therefor the edge is a separating axis and
  // the quads don't intersect.
  return true;
}

This method is then called for each edge of each rectangle. If the method returns true, the actual intersection test method can return “not intersecting”. If the method returns false for all edges, the rectangles intersect.

test-app.png

I’ve created an C#/WPF example implementation (under FreeBSD license) that you can download and experiment with.

Rectangle Intersection Test Project (for Visual Studio 2010)

Remarks: The algorithm above works for every convex polygon. Instead of four times two edges you then have n times m edges. For concave polygons, however, this algorithm doesn’t work because there may be no separating axis although two concave polygons don’t intersect (see image).

Problem with concave polygon
9.Mai 2011

Motherboard City

Motherboard City
5.Mai 2011

Windows System Sounds

YouTube Preview Image

2.Mai 2011

Super Mario Portal

27.April 2011

Microsoft Epic Fail – Eine Odyssee

Manchmal nervt Programmieren einfach. Da hat man folgende Zeile in C++ (bääääh):

PathOption test = mQ1Settings->WorldDir;

Versucht man diese mit Visual C++ 2010 zu kompilieren, stürtzt der Compiler ab. WTF?

Ok, kann ja mal passieren. Also danach gegoogelt. Zu dem Problem gibt es auch schon einen Bug-Report bei Microsoft. Allerdings meint der Verantwortliche dazu:

I can confirm that this is a bug in our compiler. This crash is unfortunate, but … blablabla …, we believe that this is not critical to fix in the next release.

Ein Compiler-Fehler ist “not critical”???

Nach diesem Statement folgt dann noch:

We will keep this bug in our database and will reconsider it for future releases.

Aja. Deshalb hat der Bug-Report auch den Status “Geschlossenes als nicht lösbar”. Klingt natürlich total danach, dass man sich damit später noch mal befasst.

Na gut. Zum Glück gibt es ja die Möglichkeit, seinen eigenen Senf zu dem Bug-Report abzugeben. Dafür muss man sich zwar registrieren, aber einen Account bei Microsoft’s Bug-Tracker könnte man ja evtl. häufiger gebrauchen ;)

registrieren.png

Also schnell auf “Registrieren” geklickt, irgendwelchen AGBs zugestimmt, und dann das:

registrieren-fehler.png

WTF? Das ganze noch zwei Mal probiert, mit dem gleichen Ergebnis.

Schon sichtlich genervt, gebe ich der Sache noch eine Chance. Zum Glück kann man ja Microsoft “hierüber einen Fehlerbericht” senden. Also klicke ich auf den Link, mit der Erwartung, dass Microsoft jetzt über diesen Fehler benachrichtigt wurde. Aber Pustekuchen!

msdn-forum.png

Ich lande in einem MSDN-Forum (mit dem viel-sagendenden Namen “MSDN, TechNet, and Expression Profile and Recognition System Discussions”).

Jetzt reicht’s mir. Wie oft will mich Microsoft denn noch auf eine andere Seite weiterleiten?? Ich wette, ich kann mich auch im MSDN-Forum nicht registrieren (hab ich allerdings nicht probiert). Dann darf ich am Ende einen Bug-Report (Forum) über einen Bug-Report (Microsoft’s Bug-Tracker) über einen Bug-Report (C++ Compiler) schreiben? Nein Danke!

Und dabei wollte ich doch einfach nur programmieren. Danke, Microsoft!

Update (22.6.2011): Das Problem besteht immer noch. Und ich habe inzwischen das Forum ausprobiert; wie erwartet tritt der Fehler hier auch auf, d.h. ich kann nicht mal einen Fehlerbericht im Forum schreiben. Das ist echt ne schwache Leistung, Microsoft!

25.April 2011

Robot Trust

YouTube Preview Image

21.April 2011

Heaven

Tetris Heaven

(via xkcd)