Implement optimized version of triangle drawing

Squashed commit of the following:

commit 6811ce8694cd79aa2e19df51708a865086dc00f1
Author: Maarten de Jonge <mdejonge1990@gmail.com>
Date:   Wed Feb 6 17:16:27 2013 +0000

    fix incremental triangle drawing algorithm

commit 355483b831a5e617dc5702ea42f44e72bd1890ed
Author: Maarten de Jonge <mdejonge1990@gmail.com>
Date:   Wed Feb 6 15:02:00 2013 +0000

    fix erroneous calculation of ymax

commit 64bb8aeb0d2c585da993aa999f940ab102114b49
Author: Maarten de Jonge <mdejonge1990@gmail.com>
Date:   Wed Feb 6 13:59:25 2013 +0100

    first try at optimisation (incorrect results)