The code below comes close. Maybe this can get you started. Update: notice the amount of error equals the last offset size.
quadkey: 03200320023
0 offset: 10018754.1713946 lod 0
3 offset: 5009377.08569731 lod 1
2 offset: 2504688.54284866 lod 2
0 offset: 1252344.27142433 lod 3
0 offset: 626172.135712164 lod 4
3 offset: 313086.067856082 lod 5
2 offset: 156543.033928041 lod 6
0 offset: 78271.5169640205 lod 7
0 offset: 39135.7584820102 lod 8
2 offset: 19567.8792410051 lod 9
3 offset: 9783.93962050256 lod 10
Mercator: x -9363230.21682095, y 4001631.30478555
error x 9783.78317905217 y-9783.69521445315
Here's the code:
private void BingTest()
{
const double EarthRadius = 6378137;
string qdkey = "03200320023";
double x = 0;
double y = 0;
double offset = EarthRadius * Math.PI / 2.0;
Debug.Print("quadkey: {0}", qdkey);
for (int i = 0; i < qdkey.Length; i++)
{
string s = qdkey.Substring(i, 1);
Debug.Print("{0} offset: {1} lod {2}",s, offset,i);
switch (s)
{
case "0": x -= offset; y += offset; break;
case "1": x += offset; y += offset; break;
case "2": x -= offset; y -= offset; break;
case "3": x += offset; y -= offset; break;
default: throw new Exception("bad quadkey");
}
offset *= 0.5;
}
// compare with expected result
double x0 = -9373014;
double y0 = 4011415;
Debug.Print("Mercator: x {0}, y {1}", x, y);
Debug.Print("error x {0} y{1}", x - x0, y - y0);
}