POV-Ray : Newsgroups : povray.binaries.animations : Particle Algorithms : Re: Particle Algorithms Server Time
20 Jul 2024 07:13:25 EDT (-0400)
  Re: Particle Algorithms  
From: David Buck
Date: 8 Dec 2001 21:47:09
Message: <3C12D101.861968FA@simberon.com>
Rune wrote:

> "Tim Nikias" wrote:
> > If you shoot a particle in an angle, and the position
> > calculated for the particle does just not touch the
> > ceiling, but the radius of the particle does, how do
> > you do that?
>

>
> My particle system does indeed only do collision detection using the center
> point of the particle as reference. I don't think there's much I can do
> about that unfortunately...

In ElastoLab, I actually test to see if the center of the particle comes within
the radius distance of any barrier.  If anyone is interested in the math, I put
the following comment into the code:

 // Derivation:
 // We want to find time t where:
 //   (locationOfParticle(t) - barrierPoint) . n = r
 //   (lastLocation + (location - lastLocation) t - barrierPoint) . n = r
 //   (lastLocation - barrierPoint) . n + (location - lastLocation) t .n = r
 //   t = (r - (lastLocation - barrierPoint) . n) / ((location - lastLocation)
. n)
 //   t = (r - (lastLocation . n) + (barrierPoint . n)) / ((location -
lastLocation) . n)
 // If
 //   barrierOffset = -(barrierPoint . n)
 // Then we can write:
 //   t = (r - (lastLocation . n) - barrierOffset) / ((location - lastLocation)
. n)
 // If dot1 = (location - lastLocation) . n,
 //   t = r/dot1 - ((lastLocation . n) + barrierOffset)/dot1

Another interesting case is when a particle hits a corner.  The normal for the
"reflection" of the particle depends on the exact point of the particle that
hit the corner.

Yet another interesting case is when you have two barriers that form an X shape
and you drop the particle into the top of the X.  It should come to rest just
above the center of the X.  It's very hard to prevent the particle from falling
through.

(If anyone has a good solution for that, I'd love to see it.  The only good
solution I've seen involves solving sets of linear equations inside a triple
nested loop).

David Buck
Simberon Inc.
dav### [at] simberoncom


Post a reply to this message

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