Robert Eisele
Engineer, Systems Architect and DBA

Calculate the intersection point of two Lines

Given two lines \(L_1\) and \(L_2\), how is it possible to calculate the point \(P\) of intersection of these two objects? Like always, set the equations of the objects involved equal and solve for the parameters. For the two lines this means:

Calculate the Tangent Line of a Circle

Given a circle with it's center point \(M\), the radius \(r\) and an angle \(\alpha\) of the radius line, how can one calculate the tangent line on the circle in point \(T\)? The trick is, that the radius line and the tangent line are perpendicular. This means, that their dot-product must be zero.

How to write a PHP Daemon

PHP is a language primarily used by web developers, but even these have problems which have to be scheduled to background processes, like sending newsletters, analysing stats, or simply maintaining the database. The most common way to solve this, is abusing crond for almost everything. When things are getting more complicated, like running jobs every 10 seconds people get really creative like blocking the execution or whatever silly custom.

Improving Interval Conditions

Checking if a certain number \(x\) falls into a given range between \(a\) and \(b\) is a quite easy task:

Calculate the intersection points of two Circles

How can you find the intersection points of two circles, given by the two center points and their radii? More formally: Given two circles with their center points \(\vec{A}\) and \(\vec{B}\) and their radii \(A_r\) and \(B_r\), we want to find the points \(\vec{P}_1\) and \(\vec{P}_2\) which represent the intersection points of both circles. Obviously, there can be one, two, infinity or no intersections at all, namely when one circle is completely within the other or the areas of the circles does not overlap. One way would be to formulate the two circles as their circle-formulas, subtract them and work out the x and y values. Quite simple, but needs a lot of calculations if you want to keep it fully parameterizable. Here is a different way:

Store a tag-cloud in MySQL

There was a time when tag-clouds were the thing for website owners to fancy oneself. These clouds are mostly gone, but seen from the perspective of how to implement such a thing, one can learn quite a lot, especially with large amounts of links. Anyway, imagine you publish some articles on your website, which are stored in a table "post" and you want to to add tags to every post in order to print a tag-cloud.

Simultaneously set and delete bit flags in a database

Imagine, we store bit-flags in a database as integers and want to update the bit-set by simultaneously deleting and updating the bits. An expression like this can quickly become unhandy. However, I wanted to make this solution pretty and after some tinkering I came up with a quite nice solution.