POV-Ray : Newsgroups : povray.off-topic : Still random : Re: Still random Server Time
29 Sep 2024 11:22:29 EDT (-0400)
  Re: Still random  
From: Invisible
Date: 7 May 2009 05:23:56
Message: <4a02a8ac$1@news.povray.org>
Warp wrote:

>   I wonder how much faster it would be if it was properly implemented in
> a *real* programming language... ;)

Is that a challenge? :-P

Do you know how to numerically integrate a physical simulation? ;-)

You're welcome to try if you like...



You're not totally wrong though: When I initially implemented this, I 
discovered, to my astonishment, that converting the state of the system 
into an image took vastly longer than all that complicated Runge-Kutta 
numerical integration stuff. Which, obviously, is absurd.

On closer investigation, the program was spending 80% of its time in one 
function: floor. Looking at the source code, I discovered that floor is 
implemented by converting a floating-point double into an 
infinite-precision rational and then converting that into an integer. 
Like, WTF?

It seems that while *most* numeric operations are very fast, one or two 
of the more unusual ones are jaw-droppingly slow.

Anyway, I replaced floor with a direct call to the compiler's low-level 
internals library and now converting to an image is near instantaneous. 
(Like you'd expect!) It takes longer to suck the data off disk than to 
process it.

Now if I could just find a way to make the integration go faster... ;-)


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.