[Shootout-list] Ray tracer developments
Jon Harrop
jon@ffconsultancy.com
Fri, 29 Apr 2005 19:05:30 +0100
Given that the OCaml implementation is much shorter, am I allowed to use this
"room" to implement a slightly more efficient algorithm?
Specifically, I've improved the OCaml version by adding separate functions to
test whether or not a ray intersects a sphere/scene, i.e. returning a boolean
rather than a float giving the point of intersection. This is faster partly
because there is a little less floating point arithmetic but mainly because
the intersection routine can short-circuit as soon as any intersection is
found, rather than having to continue to find the closest intersection.
This reduces the time taken from 19.5s to 17.25s, compared to 17.3s for the
C++. The LOC has gone up from 69 to 80.
Given that this is a "same thing" benchmark and the LOC count is still <100, I
think this should be allowed.
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists