Bastian Molkenthin - Sunshine2k

arrow Articles

Here is an overview of my articles which cover various topics. It's mainly a summary because many of the these articles are also linked from elsewhere on my site.




arrow Programming / Algorithm articles

Overview:


arrow Math / Theory articles

Overview:





arrow Programming / Algorithm articles

A practical approach to write a simple JSON parser yourself

Date : December 2022

Description :
Article that describes the implementation of a JSON parser, based on the generic tokenizer library. It contains a short introduction to the JSON file format and proceeds with the description of the parser and its data model.

View article online



Writing a simple generic tokenizer

Date : January 2022

Description :
Article that describes the implementation of a generic, versatile tokenizer that can be used as base for development of own tokenizers and parsers. It explains the imlementation of the generic tokenizer library as well as its usage in detail.

View article online



Vector reflection at a surface

Date : March 2021

Description :
Article that describes the reflection of a vector at a surface. It provides a detailed mathematical derivation and description of the formula. A Typescript implementation (with source code) visualizes the approach.

View article online



Understanding and implementing a simple big (unsigned) integer library

Date : August 2020

Description :
Article describing a simple implementation of an (unsigned) big integer library with the most important arithmetic operatons. C# source code with different implementation variants including test cases for download.

View article online



Sample implementation of C memory functions

Description :
Article about example implementations of the C dynamic memory management functions malloc(), free, realloc() and calloc(). C source code of the two implementation variants including test cases for download.

View article online



Understanding and implementing fixed point numbers

Date : April 2017

Description :
Article about implementing a fixed point number class and the main arihmetic operations. C# source code and a basic javascript implementation available for download.

View article online



Calculating permutations

Date : October 2016

Description :
Article about the generation of all possible permutations (without repetition) of set set. Presents three different algorithms with examples. Implementation with source code of eight different algorithms in total available for download.

View article online



Understanding and implementing Base64

Date : January 2016

Description :
Article about the calculation of Base64. It discusses the general idea of Base64 and and shows different implementation variants. Source code for all algorithms available for download.

View article online



Understanding and implementing CRC (Cyclic Redundancy Check) calculation

Date : February 2015 (Updated: June 2023)

Description :
Article about the calculation of CRC (Cyclic Redundancy Check). It discusses the general idea of CRC and evolves step by step different algorithms for CRC calculation. Source code for all algorithms available for download.

View article online



Algorithms for calculating the difference of dates in days

Date : December 2014

Description :
Article and source code about three different algorithm to calculate the difference of dates (in days).

View article online



(Projected) Point on Line (2D) Algorithm

Date : December 2013

Description :
Article and source code about the relation of a given point to a given line in the two-dimension case.

View article online



Applying Hough Transform for detecting lines in images

Date : December 2012

Description :
Article and source code about how the hough transformation for detecting lines in images works.

View article online



Software Rasterization Algorithms for Filling Triangles

Date : May 2012

Description :
Article and source code about three different algorithms how to rasterize a triangle.

View article online



Point-In-Triangle Algorithms

Date : December 2011

Description :
Article and source code about how to detect if a point is inside a traingle.

View article online



Parsing Algorithms

Date : November 2015 (Updated September 2015, Original: October 2010)

Description :
Article and source code about evaluating mathematical expressions using three different algorithms.

View article online



14-15 Puzzle

Date : February 2010

Description :
Personal notes I made while I coded an applet as well as an automatic solver for the 14-15 puzzle.

View article online



Welzl's 'Smallest enclosing disk' Algorithm

Date : May 2008

Description :
My own notes about Welzl's algorithm for calculating a smallest enclosing disk (minimal enclosing circle) of a set of points in the plane.

View article online



Cohen-Hodgman-Algorithm

Date : December 2007

Description :
My own notes about the Sutherland-Hodgman-Algorithm for clipping a polygon against a rectangle.

View article online



Cohen-Sutherland-Algorithm

Date : December 2007

Description :
My own notes about the Cohen-Sutherland-Algorithm for clipping 2D lines against a rectangle.

View article online



Bresenham-Algorithm

Date : December 2010

Description :
My own notes about the Cohen-Sutherland-Algorithm for clipping 2D lines against a rectangle.

View article online



Polygon Algorithms

Date : September 2007 - July 2009

Description :
Discusses Polygon Convexity, Polygon Filling with the Scanline Algorithm and Polygon Triangulation with Kong's Algorithm.

View article online



Introduction to Curves

Date : July 2007

Description :
Discusses Linear Interpolation of two points, Quadratic & Cubic Bezier Curves, The Bernstein Form of a Bézier Curve, The de Casteljau Algorithm and Degree Elevation.

View article online



Simple Collision of Two Balls

Description :
Some time ago I dealt with 2D collisions of balls. So why not share what I have thought of :-) Here are some notes concerning simple 1D/2D collision of balls and two applets showing this stuff in action. Source included in the archive file.

View article online
Download article & sources (55KB)



Inserting a splash screen into an Exe file (through a dll) - "The easy way"

Date : November 2003

Description :
Demonstrates how to add a splash screen to a PE file. To make less changes as possible to the exe file, we'll code a dll with the splash screen and add it simply to the import table.

View article online
Download article & sources (225KB)



Writing a Patcher in Delphi

Date : May 2002

Description :
Demonstrates how to code your own little tool which changes bytes in another file. Useful if you want to write something like a savegame editor. In my example we'll change a string. In this tut 2 ways are covered: one using delphi functions, the other using Win API functions for file-access.

View article online
Download article & sources (56KB)



Writing a Loader in Delphi

Date : May 2002

Description :
Demonstrates how to manipulate another program's memory in order to change its behaviour. Only Windows API functions are used, so it should be no problem to convert it into another language.

View article online
Download article & sources (27KB)






arrow Math / Theory articles

Panning and Zooming

Date : June 2022

Description :
This article describes the formula to pan and zoom a view port inside a global plane

View article online



2D line representations

Date : April 2022

Description :
This article describes the different ways how to represent a 2D line mathematically. It describes the meaning of each representation and how to create the particular 2D line form from two given points. Further, it shows the geometric interpretation of each line form and how to convert one line representation form into another.

View article online



Simplistic fixed camera to perspective screen transformation

Date : October 2020

Description :
This article addresses an key point in the projection pipeline of a 3D engine: the transformation of camera coordinates to perspective coordinates and finally to screen coordinates. Based on a very simplistic camera model (LHS system, camera at the origin, no translation or rotation), the single steps are mathematically derived step-by-step. Comes with a simpe C# demo application for visualization.

View article online



Notes about the (two-dimensional) perp dot product

Date : December 2019

Description :
An article explaining the two-dimensional perp dot product and its geometric interpretation.

Download (PDF, 1434KB)



Derivation of the two-dimensional dot product

Date : May 2017

Description :
An article about the derivation of the two-dimensional dot product and its geometric interpretation.

Download (PDF, 1062KB)



Rotation Derivation

Date : September 2011

Description :
A short primer on how to derivate the rotation of a point around the x-, y- and z-axis.

Download (PDF, 480KB)



The Birthday Paradox

Date : April 2010

Description :
This document contains my own notes about the so-called Birthday Problem or Birthday Paradox. This was written due to personal interest, in order to fully understand everything but also to get the required knowledge to explain this problem others in a logical way. Therefore, I also compare it to a similar problem and emphasize the difference. You should have a basic understanding of logic and probability calculation.

Download (PDF, 579KB)



Proof of Pascal's Rule

Date : March 2008

Description :
Again I delt with Bezier curves and especially with the recursive formula of the de Casteljau Algorithm which bases on the recursive formula of Bernstein polynomials which finally bases on Pascal's Rule. None of the books here lying on my table contains the proof so here it is - in fact short and really simple!

Download (PDF, 29KB)



The Derivative of Bernstein Polynomials

Date : August 2007

Description :
While reading about Bézier curves, I came several times across the formula for the derivative of Bernstein polynomials but I found nowhere how to get there. Also the fact that a Bernstein polynomial has just one maximum in [0,1], more specific at t = i/n, is easy to see but I did not find the proof in any book so here is my try to show it.

Download (PDF, 38KB)





This site is part of Sunshine's Homepage