Monthly Archives: April 2011

“Escaping the matrix” or “How to use the Win32 Swiss Ephemeris DLL from C#/.NET”

1:00 AM. Sleepless. Pondering. Up for dill pickles.

Repeatedly, I’m experiencing vivid symptoms of progressive intellectual pregnancy.
And it’s true. I’m bearing the idea of creating an astrological tool of my own, so I’d like to share the birth experience with you.
Well, at least the pains. ^^

Recently, I found a very extensive code library for computing planet positions. It’s called Swiss Ephemeris and it’s available right here.

The library is written in one of my favorite programming languages, namely C++.
Ohhh yes. Good old C++. No frills, just beauty. ROAR.

In spite of all the love for platform independent low-level languages and puristic coding style, I’d like to create a flashy front-end for my tool, so I’m gonna use C# on the .NET platform with loads and loads of pretty flashy *bling-bling* WPF functionality *bling-bling*.

Like the idea?
Yes? Come closer, then. All we need to do is escape “the matrix”. The cozy, safe environment of the .NET virtual machine, that is.

The Matrix (Source: DeviantArt, mrfu709851)

The first step outside of the matrix is to declare C# function wrappers which specify the entry points of the Win32 library:

        static extern void swe_set_ephe_path(char* path);

The second step is to declare an unsafe class that contains all the methods which encapsulate all of the extern function calls:

    public unsafe class SwissEphemerisWrapper
      public void SetEphemerisPath();

The third step is to create a fixed scope if we need to pass parameters outside of the matrix:

        public void SetEphemerisPath()
            fixed (char* path = ".\\sweph\\ephe")

Done. Took the red pill.

Read the Disclaimer, if you dare.


Embarking on a journey

I don’t know where I come from, I don’t know where I go.
I have started a journey and I simply cannot turn around and go back, act as though nothing had happened.

I cannot make the things undone that I did. I cannot make the things unseen that I saw. Whatever I felt, it has been graved into my heart.

Every journey starts with a single step. It doesn’t even need to be a step forward.
It can also be a step backwards or even better: A step inside.

I step inside to discover the beauty of me.
I take a step backwards to see the beauty of others.

There are so many white spots left on the map of my soul.
Quietly, I’m embarking on a journey to discover them… and to fill them out with their true colors.

A few days ago on IRC