# jon harrop's ray-tracer in c++, ocaml, factor, k2/3, and k4

## stevan apter — 2005-09-10 14:18:21

    jon harrop's original implementations, in c++ and ocaml:

    http://www.ffconsultancy.com/free/ray_tracer/comparison.html

    105 and 62 lines, respectively.

    the benchmark image (160x160 pixels, level 6 scene-graph) is

    at the bottom of my main page:

    http://www.nsl.com

    slava has a factor implementation (of level 3, 200x200):

    http://www.jroller.com/page/slava?entry=two_factor_programs_intel_8080

    a 7-line scalar version in k2/3:

    http://www.nsl.com/k/ray/ray.k

    an array version in k2/3:

    http://www.nsl.com/k/ray/rayv.k

    a faster array version in k2/3:

    http://www.nsl.com/k/ray/rayv_.k

    factoring out some common code:

    http://www.nsl.com/k/ray/rayw_.k

    finally, rayw_.k in k4 (2.3t), the latest version of k:

    http://www.nsl.com/k/ray/rayq.k

    the k4 version looks to be about 3-5x slower than jon's

    ocaml implementation.  perhaps a different approach, which

    avoids recursion through the scene-graph (the I, J, and K

    functions) would boost performance, although it isn't yet

    clear to me how to do that.