|
![](/i/fill.gif) |
> Alain wrote:
>>> Yeah, it's really horrible. POV's SDL wasn't meant to be quick at
>>> everything...
>>>
>>> So far, my C++ implementation is very fast, for not being coded with ASM
>>> and all. I was able to implement a few speedups, like not using
>>> sqrt(x*x+y*y) for *every pixel*, but instead making a 1/4 circle 2D
>>> array and picking from that.
>>
>> What's the fastest? sqrt(x*x+y*y) or sqrt(x^2+y^2)
>> In POV-Ray SDL, the second, as sqrt(pow(x,2)+pow(y,2)), is faster.
>> Don't know how it compare in C/C++ or other compiled languages.
>>
>> May be worth testing.
>>
>> Alain
>
> Hmm, I was not aware that pow(n,2) was faster than n*n. I'll keep it in
> mind next time the issue comes up. In my program, sqrt(x*x+y*y) is only
> called at the very beginning to fill a small array.
If you only use it a few times, the speed gain is low. If you use it a
LOT, like in the function of an isosurface, then the difference get very
appreciable.
It's faster because every time you need the value of a variable, you
have to search for it and retreive it's value. Also, evaluating an
integer power is almost as quick as doing a multiplication.
Alain
Post a reply to this message
|
![](/i/fill.gif) |