Timekeeping on other worlds – Days

A sidereal day is the time it takes the planet to do a full 360 degree revolution around its axis. It is influenced by nutation, tides and the gradual slowing of a planet’s rotation. When a distant star is in a particular location in the sky, the next sidereal day it is in the same location again.

A solar day is the time from a sun’s highest point in the sky to the next time the sun is at its highest point in the sky. The solar day can be longer or shorter than a sidereal day and is influenced by the orbit of the planet around the sun. The more elliptical the orbit is, the more the length of a solar day varies across the year. On Earth the solar days are approximately four minutes longer than the sidereal days, and in a year there is one more sidereal day than there are solar days. On Venus a solar day is shorter than a sidereal day because the planet has retrograde rotation.

Our current clocks use multiples of 12: 5 times 12 seconds in a minute, 5 times 12 minutes in an hour, 2 times 12 hours in a day. Twelve is easy to work with because it has many divisors. (Also the reason that there are 12 inches in a foot, 12 ounces in a troy pound and 12 pence in the old British shilling.) Therefore we should prefer the duodecimal system on other planets instead of the decimal system.

I propose a way of keeping daytime.

A planet with one sun

We humans like daylight very much, so we tend to count our days in solar days, or sols. Let’s define an hour as 1/24th of a day, and a minute as 1/60th of an hour, irrespective of how long a day on that planet actually is. Most planets are in a solar system with only one sun, so then it is logical to define a day on that planet as equal to a solar day, or sol (with some exceptions which I’ll talk about below). On any day for any position on the planet, on 12:00 (on a 24-hour clock) the sun is at its highest point in the sky for that sol.

This definition of hours and minutes means that the length of both hours and minutes depends on the planet you’re at. In fact, since a sol does not have a fixed length, the length of both hours and minutes not only varies from planet to planet, but also from day to day. This is also true on Earth. In practice this day to day difference in length is not big enough to matter, but over the course of a year the length of a sol on a planet with a highly elliptical orbit will fluctuate by several hundred seconds.

The second is a time unit that has now been defined independently of any planet’s rotation using the radiation of a cesium 133 atom. While it is nice that we generally assume that 60 seconds fit a minute, in our daily lives the smallest relevant time scale that matters are minutes. I propose to keep the defined length of a second constant (just like it is now) and just measure the length of a sol minute in those constant seconds.

This means that even on Earth an average minute is just a little bit more than 60 seconds long. An average Martian minute would be 61.6 seconds long.

There are of course also planets that have sols that are no where near an Earth day in length. For example Venus has a sol of approximately 224.7 Earth days. A human would not be able to wait that long before going to sleep, so such sols need to be adjusted to match our sense of time. I propose that this adjustment is made by dividing the sol into segments of 12 days. On Venus, a sol would be divided into 10 segments of 12 days, resulting in a day (thus 24 hours) with minutes of 58.4 seconds long. The number of segments is chosen such that the length of a day is closest to an Earth day (as that’s the time unit humans need for their biological clock).

For a planet that spins rapidly, we do the opposite: a day is divided into one or more segments of 12 sols.

A planet with no sun

There are stray planets flying around all the time. They were once flung out of a solar system and now don’t orbit any star. The only day that has any relevance to such planets is the sidereal day. So I propose to use the same time specification for sunless planets, substituting the sol by the sidereal day.

A planet with multiple suns

Although rare, there exist solar systems that have planets with multiple suns. In this case I propose we pick one (for example the brightest, closest, or the biggest) and use the solar day relative to that sun for measuring the length of a day. If the suns are sufficiently close together and far away, it doesn’t really matter which one you pick. If the suns are far apart, then daylight varies from day to day such that there is no simple way to define a day anyway.

Posted in Thoughts | Leave a comment

Apple’s not-so-bright future

I don’t own or use many Apple products. In fact, I only own an iPod Nano and therefore use iTunes. I thought Apple products have always been popular and very stylish, perfected and easy to use. Then I read the book Steve Jobs by Walter Isaacson, and the moral of the story was that while Steve Jobs was impossible to work with, he was the one that ensured the stylishness, perfection and ease of use of Apple’s products.

Then I happened to stumble across this article on stuff.tv which lists the top 6 biggest Apple blunders of all time: Pippin, Hockey puck mouse, Apple Maps, Newton, Twentieth Anniversary Macintosh and Apple QuickTake. It occurred to me that all of the listed mistakes (except for the hockey puck mouse) were made in a time when Steve Jobs didn’t work at Apple. Either between 1985 and 1997 because he was forced out of the company, or after his death in 2011.

If Apple Maps is any indication of the stylishness, perfection and ease of use we can expect from Apple in the future, then I reckon it won’t be a very bright future for Apple.

Posted in Thoughts | Leave a comment

User-defined conversions to and from arrays in C#

Today while writing a custom Array<T> class, I found that it is even possible to define custom conversions to and from array types in C#. This will make working with my custom array class a lot easier.

public sealed class Array<T>
{
    // ...

    public static explicit operator T[](Array<T> array)
    {
        return array.innerArray;
    }

    public static implicit operator Array<T>(T[] array)
    {
        return new Array<T>(array);
    }
}
Posted in C# | Leave a comment

Liquid democracy

In a democracy, all eligible citizens have an equal influence in the decisions that affect their lives. In the times of the ancient Greek, when a decision needed to be made about something that concerns the common people, then it would be announced from the top of a hill. People that were interested gathered at the bottom of the hill and discussed the issue. At some point everyone present and eligible is asked to vote. Each person can cast exactly one vote in favor or against a proposed solution. The solution that has the most proponents would be executed. This system of democracy is called a ‘direct democracy’, due to the direct influence of the people on the decisions.

Nowadays, people are way too busy to concern themselves with all this decision making. Also, the issues at hand are more complex than in ancient Greek times, and many people feel that they do not know enough about the subjects to be able to cast a meaningful vote. Therefore, in most democratic countries, each eligible citizen chooses a single person, a politician, that devotes her time to understanding the issues and making these complex decisions on behalf of the voter. Who these politicians are, is decided at each election. However, between elections citizens have no influence on any decisions. This is called a ‘representative democracy’, due to the influence of the people through their representative politicians.

Personally, I am in favor of a third kind of democracy that lies between a direct democracy and a representative democracy. In this system, an eligible citizen can cast a vote on any issue that arises and interests them. But this is not required. For example, when the citizen does not have the time or expertise to cast a meaningful vote, or does not concern herself with the issue, then she may pass her vote on to someone else. Someone who might have more time to investigate the issue, or who has more knowledge on the subject. This person may then cast those votes on behalf of those who passed their votes to her. Or this person may pass those votes along to another person, for example a politician. In the end, all votes in favor or against a solution are cast and the majority decides. If however, you want to cast a vote yourself instead of letting your representative do it, you may do so at any time. This is called a ‘liquid democracy’. People that don’t care or do not have the time or expertise can let other people decide for them, just like the politicians in a representative democracy. However, if someone wants to cast her own explicit vote on the subject, she can do so, just like in the direct democracy of ancient Greece.

Thanks to the internet, is it easier than ever to learn about the issues at hand and to be able to cast a vote. But if one wants to pass her vote along, the internet can also be of great help.

Posted in Thoughts | Leave a comment

Project X

september 2012: Merthe Weusthuis maakt voor haar zestiende verjaardag een verjaardagsevenement aan op Facebook. Hoewel het evenement beperkt was tot vrienden, was de optie om genodigden hun vrienden te kunnen laten uitnodigen niet uitgeschakeld. Een vriend van een vriend van Merthe nodigde 500 vrienden uit, waarna het aantal uitgenodigden de spuigaten uit begon te lopen. Een dag later hadden 3500 mensen al via Facebook laten weten aanwezig te zijn. Toen Merthe haar event ging verwijderen, werden er door derden evenementen aangemaakt onder de naam ‘Project X Haren’ waarin men werd opgeroepen naar Haren te komen voor Merthe’s verjaardag.

Uiteindelijk stonden er meer dan 25.000 uitnodigingen over en meer dan 2500 mensen hadden aangegeven te komen. De gemeente Haren begon allerlei maatregelen te nemen, en die maatregelen kwamen in het nieuws. Hierdoor werden steeds meer mensen bekend met Project X Haren en kwamen er uiteindelijk op vrijdag 21 september duizenden mensen per trein en auto naar Haren. Een deel hiervan begon te rellen, vernielen en plunderen naarmate de nacht vorderde, en de politie en ME kregen het niet in de hand. De volgende ochtend bleek er voor honderdduizenden euro’s aan schade, de Albert Heijn geplunderd, veel gewonden, enkele zwaargewonden en een oudere man mishandeld. En nu rijst de vraag: was dit de schuld van Merthe, of van Facebook?

Allereerst is het natuurlijk niet de schuld van Merthe. Zij wist niet van te voren dat een vriend van een vriend voor haar verjaardag al z’n 500 vrienden ging uitnodigen, die op hun beurt ook weer mensen uitnodigden. Zelfs al had ze bewust een open uitnodiging gemaakt en iedereen opgeroepen om te komen, dan kan je haar hooguit kwalijk nemen dat er dan geen plaats, voorzieningen of beveiliging voor de grote groep mensen is. Als dan de gemeente op de valreep dat moet regelen kost dat geld.

Facebook is, net als Twitter, een snel online sociaal medium waarmee grote groepen mensen bereikt kunnen worden. Dat Facebook het wel heel makkelijk maakt om ongewild veel genodigden te krijgen op een evenement is bekend, en het enige dat Facebook kwalijk kan worden genomen. Het mobiliseren van grote groepen mensen is niets nieuws, en dat het via Facebook (of Twitter, of het internet in het algemeen) kan gebeuren is dus ook niet speciaal. Het gebeurde al via oproepen in gebedsgebouwen, op mededelingenborden, via kranten en e-mail. Als Dan Brown in één van z’n boeken meldt dat er iets speciaals te doen is op 21 december 2012 in de Tuilerieën van Parijs, dan zouden allemaal mensen zich daar verzamelen.

De gemeente Haren daarentegen is niet zo slim geweest door steeds maar mededelingen te doen. Straatnaamborden verwijderen, noodverordening, politie achter de hand houden, een voetbalveld aanwijzen; elke mededeling zorgde voor aandacht in de media. Op een gegeven moment was Project X Haren ook bekend bij mensen die het niet via Facebook hadden gehoord.

Ik denk dat veel mensen die ‘ja’ hadden gezegd op één van de Facebook-events uiteindelijk niet zouden zijn gekomen, en dat de meeste mensen die wel kwamen opdagen er waarschijnlijk gewoon iets gezelligs van hadden gemaakt. Maar door alle media-aandacht werden er veel meer mensen gemobiliseerd dan anders, en daartussen zitten altijd mensen die kwaad in de zin hebben. En natuurlijk zijn de relschoppers in de eerste en voornaamste plaats verantwoordelijk voor wat er die dag in Haren gebeurde.

Posted in Thoughts | Leave a comment

C# – Switching on types

Many programming languages have it, and many people would like to see this in C#: the ability to do switch on types. While the following example is far fetched and shows bad programming practices, if it would ever be implemented, I’d expect it to look like this:

class A { string Name { get; } }
class B : A { string LongName { get; } }
class C : A { string FullName { get; } }
class X { public string ToString(IFormatProvider provider); }
class Y { public string GetIdentifier(); }

public string GetName(object value)
{
    switch typeof(value)
    {
        case C: return value.FullName;
        case B: return value.LongName;
        case A: return value.Name;
        case X: return value.ToString(CultureInfo.CurrentCulture);
        case Y: return value.GetIdentifier();
        default: return value.ToString();
    }
}

Notice how the case C and case B have to be specified before case A, as the code would match the first. This is against the definition of switch in C#, which states that the order of the cases does not matter. A generalization of this concept and its problems are discussed in this rather old MSDN blog post by Peter Hallam.


However, it is likely that you’d want to use just such a type switching construct in your code. Instead of writing a whole string of if-statements, you can do this by using this static class I wrote:

public static class TypeSwitch
{
    public static Switch<TSource> On<TSource>(TSource value)
    {
        return new Switch<TSource>(value);
    }

    public class Switch<TSource>
    {
        private TSource value;
        private bool handled = false;

        internal Switch(TSource value)
        {
            this.value = value;
        }

        public Switch<TSource> Case<TTarget>(Action<TTarget> action)
            where TTarget : TSource
        {
            if (!handled)
            {
                var sourceType = value.GetType();
                var targetType = typeof(TTarget);
                if (targetType.IsAssignableFrom(sourceType))
                {
                    action((TTarget)value);
                    handled = true;
                }
            }

            return this;
        }

        public void Default(Action<TSource> action)
        {
            if (!handled)
                action(value);
        }
    }
}

Download the full, commented source

The example at the start of the post will be written like this:

public string GetName(object value)
{
    string name = null;
    TypeSwitch.On(operand)
        .Case((C x) => name = x.FullName)
        .Case((B x) => name = x.LongName)
        .Case((A x) => name = x.Name)
        .Case((X x) => name = x.ToString(CultureInfo.CurrentCulture))
        .Case((Y x) => name = x.GetIdentifier())
        .Default((x) => name = x.ToString());
    return name;
}
Posted in C# | Leave a comment

Solution: Windows Live Movie Maker will not export movie with .wmv video clip in it

The problem

Recently I had a problem with Windows Live Movie Maker on Windows 7 x64 where it would refuse to export a movie that had a .wmv video clip in it. I successfully exported that video clip from Movie Maker before, and it consisted of only .avi and .mod video clips. Using that clip in my new movie seemed to go all fine, but when trying to export it to a video file, I got the following errors:

Sorry, your movie can’t be saved. Find any missing files or remove the unusable items from your project, and then try again. Error: 0xC945002D

Do you want to remove ’028.AVI’ from the project? The file might be corrupted or in a format that Movie Maker doesn’t recognize. Error: 0xC945002D

The solution

I was not able to remove this error for now and ever. But I was able to get Windows Live Movie Maker to export my movie. This is how I did it:

  1. Download and install Freemake Video Converter. Be sure not to install any of the advertising toolbars and things.
  2. Convert the .wmv file that you want to use in your video to an .avi file, using this tool. The default settings worked just fine for me.
  3. Open your Movie Maker project file (the .wlmp file) with your favorite plain text editor (such as Notepad++).
  4. Look in the MediaItems section and replace the path pointing to the .wmv file with the new path of the .avi file.
  5. Save the file. Open it in Movie Maker and try exporting it again. It worked for me, without having to slice my clip again.

In my Movie Maker project file, the MediaItems section looked like this:

<MediaItems>
    <MediaItem id="1" filePath="C:\Clips\MyClip.wmv"
      arWidth="1920" arHeight="1080" duration="13.994" />
</MediaItems>

And after step 4, it looked like this:

<MediaItems>
    <MediaItem id="1" filePath="C:\Clips\MyClip.avi"
      arWidth="1920" arHeight="1080" duration="13.994" />
</MediaItems>

Good luck!

Posted in Solutions | 19 Comments