Category Archives: programming

Rendering a Gigapixel Buddhabrot (Part One)

This is a followup to my What is a Buddhabrot anyway?-post where I only described the mathematical backgrounds of the Mandelbrot Set and its relationship to Buddhabrot renderings. This post will describe how I actually created the images.

As described in the linked article above one needs to find such points for which the Mandelbrot iteration becomes unbounded. Then one draws each point of such an unbounded iteration, repeats that for lots of other points and gets a Buddhabrot.

While the words sound easy enough, there are certain problems: how does one know that an iteration becomes unbounded when unbounded basically means that “it never ends up somewhere”. And then how do we find those interesting points and moreover lots of them within a lifetime?

Luckily it has been found out that if the continued iteration results in points that are farther than 2 units away from the origin of the coordinate system, that this iteration is unbounded. That means that if we started with a point that leads to an unbounded iteration we will sooner or later know it and can stop iterating.
However, if we started with a point that leads to a bounded iteration it will never lead to points farther than 2 units away from the origin and if we don’t stop using some other criterion we will have an infinite loop. This other criterion is quite simple: set some maximum iteration count and whenever you exceed it consider the iteration bounded and thus not interesting for the Buddhabrot rendering.
Read more »

MySQL: From Differences to Gains and Losses

The problem with blogging solutions specifically for one person is that he comes back and asks for more 😉 Luckily this time it’s easier!

What we got: a simple table with one column whose values describe a difference of some kind. That is we got one column called difference, that has negative or positive (or 0) numbers.
What we want: we’re looking for the most simple and performant way to update two other columns from that difference one: if the difference was positive, this value is to be updated into a gain column. If it is negative, then the positive value (the absolute value) is to be updated into the loss column.

Read more »

Rankings in MySQL – global ranks and local ranks within subsets

I was asked by someone to help him figuring out how to calculate and store rankings in an SQL relation. There are already some resources on the web that show how to calculate rankings with MySQL but the specific problem today has two more facets to it:

  • don’t calculate a single rank of one item but update all ranks of all items in one query
  • not only calculate the global rank of each item but also the rank of each item within some subset it is part of

Read more »

Writing the first Android App: Guess-the-Number Game

Having installed the Android SDK and getting to work the Hello-World-Sample, it’s time to write the first app that isn’t just written down from some tutorial website.

I chose a simple number guessing game, as it was the first piece of code I can remember to have written ever. It was part of the users manual of the Commodore 64 my brother bought back in the time when 8 bits ruled the world 🙂

Screenshot of the finished number guessing game

The reader of this mini tutorial should be familiar with Java and at least the “Hello, World” tutorial I refered to in an earlier post.

Read more »

Installing the Android SDK on Windows and saying Hello to the Android world

Having owned an Android device for more than a year I never found the time (and motivation) to start developing for the Android plattform. With holidays ahead I thought I finally might find the time and with some ideas in the head motivation wasn’t far. So here are my experiences of installing the Android SDK and getting to run the traditional “Hello World” application:
Read more »

Calculating an intercept course to a target with constant direction and velocity (in a 2-dimensional plane)

For some game idea I worked on a bit some time ago I needed a bit of maths. Luckily all that was needed was taught at school and with a bit of thinking (and trying) it all worked out:
diagram of a moving object to be intercepted by a projectile

Let’s consider an object at point A moving with the constant speed vector \vec{v}. At point B we got the ability to fire a projectile with speed s. Where do we have to aim at to hit the object with our projectile? In other words: what is the location of point I or what would be the vector \vec{x}?

Now let us derive the necessary maths and put it into code… (requires understanding of vectors and quadratic equations)

Read more »