Charles Petzold on writing books, reading books, and exercising the internal UTM

Recent Entries
< PreviousBrowse the ArchivesNext >
Subscribe to the RSS Feed

Windows Phone 7.5, the Motion Sensor, and Astronomy

October 11, 2012
New York, N.Y.

If you're a Windows Phone programmer, I hope you still read MSDN Magazine because I've been writing a monthly column mostly about Windows Phone programming. Over the past several issues I've been exploring the Motion sensor introduced with Windows Phone 7.5, culminating with a program that lets you hold up the phone to the night sky to identify the planets and constellations you see there:

If you've ever wondered how such a program works, all the source code is downloadable with the article.

This astronomy program was the culmination of several months of columns about programs that obtain and use the phone's orientation in 3D space. I started this exploration in the June issue with Getting Oriented with the Windows Phone Compass, in which I explored the interaction between the phone's Accelerometer (which lets you know which way is down) and the Compass, which lets you know which way is north.

After that column, I gravitated to the Motion sensor, which combines information from the accelerometer and compass and provides a 3D rotation matrix that describes the phone's orientation in 3D space. In Windows Phone Motion and 3D Views, I present an XNA program that lets you turn the phone to view various sides of a 3D object, and in Viewing a Virtual World from Your Windows Phone I show how to view large bitmaps as if you're scanning them through the phone's screen.

After those preliminaries, it was time to focus on my real objective: a program that lets you view the night sky. The necessary preliminaries are Exploring Spherical Coordinates on Windows Phone and the astronomy program itself is in Viewing the Night Sky on Your Windows Phone.


Great application! I wasn't aware of any other night sky apps for windows phone so was excited to try this out. Unfortunately any compass related application doesn't work properly in the southern hemisphere due to a bug in the windows phone API for magnetic declination. So I tried your other Dial Compass sample and found that true north was out by 110 degrees here in New Zealand...Any chance you could poke someone from MS to take a look?

— Jonathan, Sun, 14 Oct 2012 05:25:58 -0400

I have several Windows Phones I use for testing, and a malfunctioning compass is more a rule rather than an exception. — Charles

Why at Visual Studio Windows Phone edition we do need the 30 days licensing, but at Visual Studio Express for Windows 8 we must every 30 days renew developer license? Might it be in future (Service Pack ;) ) it be like in WP edition?

Or vice-verse MS planned 30 days renew licensing in upcoming WP8 too?


— Guest, Sun, 14 Oct 2012 05:18:33 -0400

No idea. — Charles

Thanks for answer Charles.

I suppose that MS explain this moment for MVPs, via temporally NDA or something else, but I see they didn't.

— Guest, Mon, 15 Oct 2012 09:26:04 -0400

Well that's a real shame compass's don't work on windows phones since they are vital to so many applications like yours here. My wife's cheap android phone's compass is accurate to within +- 5 degrees! 110 degrees out is so useless it would be better randomly guessing a direction (oh and its 100% reliably wrong too)!

How are you supposed to align to a star/planet if you should be looking behind yourself? Perhaps each application needs a fudge factor for each device to counter the error in the reading.

— Jonathan, Mon, 15 Oct 2012 19:41:03 -0400

I'm another new southern hemisphere Windows Phone user who has stumbled on this ridiculous bug. Since this major bug has been around for months with no fix or even acknowledgement I'm considering returning my Lumia 800 for a refund now.

— Rob, Fri, 9 Nov 2012 03:39:28 -0500

Hi Charles.

I love all your books( especially Programing For Windows 6e. and Programing WP). I have question, will you have new book about WP8 programing ? I miss XNA in Windows Store. So will you have book covering game programing in C# for Windows 8( Store apps)?

— MrV, Sat, 10 Nov 2012 02:58:49 -0500

I would *love* to write a book about Windows Phone 8 programming, and I would *love* to write a book about DirectX programming for Windows 8 and WP8.

Unfortunately, books such as these are simply not financially feasible. Most books — including those that I write — have very poor sales. Hence, publishers can't pay authors very much money to write these books. Hence, authors have a hard time paying their rent, health insurance, and other expenses.

If people would buy more books, I could write more books. It's as simple as that. — Charles

Hi Charles,

Would your "Programming windows phone 7" be a good starting book for windows phone 8 development or is too outdated?

— John Woods, Sun, 11 Nov 2012 01:50:06 -0500

The book is still fundamentally sound. — Charles

>If people would buy more books, I could write more books. It's as simple as that.

Charlse how about direct speaking with potential readers/buyers on

In one of you books (or in one of yours' blog post) I read that you never ever write your book without editors and correctors, so kickstarter is not for publishers, but if Microsoft Press or O'Reilly make exception for case that you describe and by self posting book theme on kickstarter? (Not realistic scenario, but I don't know, did you or/and publisher ever think about it).

— guest, Sun, 11 Nov 2012 15:18:37 -0500

If people want me to write books in the future, they can buy books that are currently published. By buying books, people invest in me. They help me write more books. Plus, they get a book. This is a much better deal than Kickstarter. — Charles

By the way, today read that Update 1 for VS 2012 is availed, and Desktop C++ app now can targeting for Windows XP. But more imported that in comment I found this:

so people ask that there are no 30 days relogining to Microsoft for develop Windows 8 store app.

Charles can you as MVP support that idea?

— Guest, Wed, 28 Nov 2012 05:00:51 -0500

Recent Entries
< PreviousBrowse the ArchivesNext >
Subscribe to the RSS Feed

(c) Copyright Charles Petzold