POV-Ray : Newsgroups : povray.unofficial.patches : Speed of collision tests in mechsim : Re: Speed of collision tests in mechsim Server Time
28 Sep 2024 16:40:55 EDT (-0400)
  Re: Speed of collision tests in mechsim  
From: Edward Coffey
Date: 29 May 2004 09:32:42
Message: <40b890fa$1@news.povray.org>
Chambers wrote:
...
> Anyway, I noticed that I'm still not happy with the simulation speed, so I
> looked at the code for the patch.  Collisions are checked between masses by
> calculating the distance, which requires a sqrt call.  The only way I can
> think of to speed that up is to use a box format first, such as this
> pseudocode:
> 
> if ((abs(dx)<max) and (abs(dy)<max)) and (abs(dz)<max)))
>  if (sqrt(dx^2+dy^2+dz^2)<max)
>   collision is true
>  end
> end
...

I've never looked at the code you're describing here, but it looks like 
you don't need the sqrt at all. Wherever max gets set, square it and 
store it in maxSquared, then do:

if ((dx^2+dy^2+dz^2)<maxSquared)
  collision is true
end


Post a reply to this message

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