September 2, 2009

Mars vs. The Moon

So I’ve received this e-mail (in French) a couple of times, titled Two Moons in the Sky, saying that on August 27th this year (though the two times I received it were on different years) at 00:30 (precisely, mind you, not during the whole night or for a few nights before and after that date), Mars will be the brightest object in the night sky, as bright (sometimes also as big) as the full Moon, even though it’s 55 million kilometers from Earth, and that it won’t happen again before year 2287!

I mean, WOW!

No, not World of Warcraft. No, not “Wow, Mars will be as bright as the full Moon” either.

Rather, “Wow, I have friends who believe this shit, who believe it enough to forward it to me as a fact, not even to ask me if it’s true.” (I happen to have a teeny, tiny PhD in some branch of Physics. Not many people know that.)

What’s good with this joke is that, by a happy coincidence on the numbers involved, the calculations needed to debunk it can be done in your head. Well, maybe not in your head, but certainly in mine.

See, everybody knows that the Earth is 150 million kilometers away from the Sun. The e-mail tells us the Earth-Mars distance at its shortest will be 55 million kilometers, which happens to be the only correct information in the whole message. This gives us the Sun-Mars distance as 150 + 55 = 205, make is 200 million kilometers.

Now the amount of sunlight received by a celestial object (or any kind of object, really) is inversely proportional to the square of its distance to the Sun, meaning that if you double the distance, it receives four times less light. So the amount of light received by Mars compared to the Moon (which is at the same distance from the Sun than the Earth) is

(Sun-Moon distance/Sun-Mars distance)^2 = (150/200)^2 = 3/4)^2

Let’s keep it this way for now.

Then the amount of light reflected by the planet is proportional to its surface, which is proportional to the square of its diameter. Maybe not everybody knows that Mars (6772 kilometers in diameter) is twice as big as the Moon (3475 kilometers, I told you the numbers involved were convenient), but people know that Mars is “a bit like Earth”, which would make it four times bigger than the Moon, which would be in the benefit of Mars and still work. But let’s stick with the correct numbers. The amount of light reflected by Mars compared to the Moon is therefore

(Mars diameter/Moon diameter)^2 = 2^2 = 4

Finally, the amount of light received by the Earth from each of our objects is, like before, inversely proportional to the square of the distance. Again, everybody knows that the Moon is 384 thousand kilometers away from the Earth. That’s the average distance. The maximum distance is rather 406 thousand kilometers. I’ll round it to 440 thousand kilometers because it’s in the detriment of the Moon and it’s convenient. So the amount of light received by the Earth from Mars compared to the Moon would be (beware the units)

(Moon-Earth distance/Mars-Earth distance)^2 = (440 thousands/55 millions)^2 = (8/1000)^2

Now it might be that the surface of Mars reflects light better than the surface of the Moon. It’s even probable: Mars is red whereas the Moon is black (Don’t believe me? Remember those rocks they took back from there, like exactly forty years ago? Did they look bright white?). But I’ll assume they both reflect light equally so we can compare the numbers with real data in the end. We can make the calculation again with Mars ten times brighter than the Moon later if you want.

So, to sum up, we have:

  • Amount of light received by Mars compared to the Moon: (3/4)2;
  • Amount of light reflected by Mars compared to the Moon: 22;
  • Amount of light received by the Earth from Mars compared to the Moon: (8/1000)2.

Let’s multiply all this (because the light reflected is proportional to the light received from the Sun, and the light received on Earth is proportional to the light reflected):

(3/4 * 2 * 8/1000)^2 = (12/1000)^2 = 1.44/10000 = 1/6944

The light we get from Mars, in the best case ever, is almost seven thousand times less than the light we get from the full Moon. What a surprise! And if we had taken Mars to be as big as the Earth (four times bigger than the Moon instead of two, gives another factor 4 once squared) and ten times brighter than the Moon (i.e. very wrong numbers in its favour), it would still appear 170 times fainter.

Now let’s check this result quickly. The Wikipedia article on apparent magnitude tells us that the magnitude of the full Moon is -12.6 and the maximum brightness of Mars is -2.9. It also tells us that the ratio in brightness between two objects is given by

2.512^x

where x is the difference between the two magnitudes. In our case:

2.512^((-2.9)-(-12.6)) = 2.512^9.7 = 7589

We weren’t far with our seven thousand, given the approximations we made, don’t you reckon?

Do we need to check the claim that Mars can appear as big as the Moon, too? That won’t take long, now that we’re experts in the field. The apparent size of an object in the sky is given by the angle under which you see its diameter. In radians and for such small angles, it’s calculated as diameter/distance. Hey, we happen to have all the necessary data already. For Mars:

alpha_Mars = 6772/55 million = 1.23e-4 rad = 25 arc-seconds

For the Moon:

alpha_Moon = 3475/406000 = 8.6e-3 rad = 29 arc-minutes

That is, Mars appears 70 times smaller than the Moon in the sky.

So next time you see a message that claims such unbelievable things, make a quick mental calculation before forwarding it to everybody. Or even easier, ask yourself if you have ever seen a celestial object that looked bigger than a dot to the naked eye, apart from the Sun and Moon, and check on the Internet. There are sites like Hoax-Slayer (English) or HoaxBuster (French) dedicated to this and checking the validity of such e-mails can be done very quickly.

Next time in this column: why doesn’t the height at which you must throw a grenade to have it explode the moment it touches the ground depend on the weight of the grenade?

August 30, 2009

De-evilising Adium windows

Some developers seem to think that people can’t use a mouse, probably because of their own inability to use one. Therefore they develop features to help us poor crippled users deal with our handicap. That’s very nice of them, except it’s annoying as Hell and insulting.

In particular, I’m talking about the ‘feature’ where, when you move a window close to a screen edge, it sticks to it like a steel stretcher to an MRI. It’s all very nice when that’s what you want to do but first, that’s almost never my case, second when it is, I’m able to do it without help, thank you very much, and third, it makes it almost impossible to position a window a few pixels away from the edge of the screen, which I like to do because it leaves me an access to the desktop.

So we are dealing with a feature designed to help you with something that is not very difficult in the first place, while rendering another, usually simple task very hard to achieve. It’s like replacing the staircase in a building with an elevator that only goes to the third floor. You can still reach the first floor but you have to take the elevator to the third, make a rope out of your neighbour’s bedsheets and climb down the window. And it’s not like the third floor was hard to reach before.

A good rant is no fun without pointing fingers. Here I’m especially talking about Twitterrific and Adium. I don’t use the former anymore (partly for this reason but mostly because of its utter uselessness when it comes to following discussions) and have switched to Tweetie, but I still use Adium regularly. I tried reporting the issue, years ago, suggesting to make it optional, but the developers looked down on me, saying they didn’t want to bloat the preferences with such details. Right, from the makers of an application that has preferences to turn off window shadows or to choose whether tooltips are displayed when in the background.

Granted, you can disable screen edge sticking by holding I don’t know which modifier while you drag the window, but since the feature is useless and annoying, why not make it kick in only when you jump through enough hoops to deserve it, instead of when you’re quietly minding your own business, repositioning your windows like you’ve always done for the past twenty-five years?

Last week I finally got around to patching Adium to get rid of this nonsense. The regular windows are made evil by making them of class AIDockingWindow, which is defined in the AIUtilities framework. AIBorderlessWindow, in the same framework, takes care of evilising the contact list when it’s made border-less. I could have changed the class in Interface Builder, but still would have needed to patch the code for the border-less window, and patching a nib is less robust than patching a source file.

To fix Adium for your own use, please:

  • Download the patch. It was made for Adium 1.3.8 but it will likely work for a few future releases;
  • Download and unpack the Adium sources (Yes, the current release must be downloaded from the Previous Releases page. Just remember we’re dealing with open source people);
  • Apply the patch with patch -p1 < adium-NoDockingWindow-1.3.8.patch from within the adium-1.3.x folder;
  • Build Adium:

    cd Release
    make
    

(Near the end there is some GUI scripting going on to tweak the disk image, better stop working at that moment.)

  • Adium can be found in the Adium_1.3.x-NDW.dmg disk image in Release/build/.
  • Optional: if you use foamee, get me a coffee:

    @ioucoffee @oscherler for de-evilising Adium windows.

    Thanks.

Hope this helps.

Update (5.11.2009): Patching the Makefile too now, updating the instructions.

August 27, 2009

Safari bug report

How to get past Apple’s profanity filters (just in case they have any) in Safari bug reports:

[Edited version in case you have filters. I trust you’ll get the gist of the original.]

When I copy code from a <pre> tag, Safari inserts artificial (they’re not in the page source) non breaking spaces where lines are indented.

[all capitals]This is the most [mean word for “not very wise”] thing to do [lots of exclamation marks][/all capitals] because usually, you have code inside <pre> tags. And compilers and interpreters don’t like it when spaces are replaced by non-breaking spaces, and it gives rise to errors you can’t easily see the origin of, and it’s incredibly [expression that pictures private properties reduced in powder].

I should write a filter that does this automatically.

August 25, 2009

Photography: Buskers Festival

Buskers Festival

I’ve added to my gallery the pictures from the Buskers Festival in Neuchâtel on August 15th, 2009. I love that AF Nikkor 50mm f/1.4D.

July 9, 2009

A note to Mac software developers

  1. A compressed DMG does not need to be zipped, gzipped, binned, sitted or hqxed.

  2. Zipping a DMG is no proper way of dealing with a web server misconfiguration (yes, Wikipedia is wrong, sometimes). Configuring the MIME type to application/x-apple-diskimage or application/octet-stream is.

  3. An uncompressed DMG does not need to be zipped, gzipped, binned, sitted or hqxed. An uncompressed DMG does not need to exist. An uncompressed DMG needs to be converted into a compressed DMG.

  4. A DMG is suposed to be downloaded from a modern computer, not from a VAX. Therefore the file name does not need to be 8.3 fashion or stripped from spaces, capitals or ‘special characters’. If it makes your life easier, replacing spaces with dashes (not underscores) is OK.

  5. It is nice to include the version number in the download file name (separated from the rest by a space or a dash).

If you are a Mac developer and have been directed to this page, it’s probably an invitation to improve the user-experience in the very first phase of your customer’s dealings with your software.

Do not meddle in the affairs of Coding Ninjas, for they are subtle and quick to anger.