Author Topic: Behavior of Ellipsoid collision detection  (Read 1322 times)

Offline mesh

  • byte
  • *
  • Posts: 3
    • View Profile
Behavior of Ellipsoid collision detection
« on: February 26, 2013, 09:41:19 pm »
I'm getting started with JPCT and I noticed a strange result with the ellipsoid collision detection. Here is my test:
Code: [Select]
Object3D source = Primitives.getSphere(1f);
source.translate(0, -2.5f, 0);

Object3D target = Primitives.getSphere(1f);
target.addCollisionListener(new CollisionHandlerTest());

SimpleVector unitDir = new SimpleVector(0, 1, 0);

Log.i("Collision", "Object collisions");
source.checkForCollision(unitDir, 2);
SimpleVector adj = source.checkForCollisionEllipsoid(unitDir, new SimpleVector(1, 1, 1), 5);
Log.i("Collision", "Ellipsoid adjusted: "+adj);
adj = source.checkForCollisionSpherical(unitDir, 1);
Log.i("Collision", "Spherical adjusted: "+adj);

I move the source sphere up by 2.5 units so that it's 0.5 away from the top of the target sphere. Then I try what I believe to be equivalent collision tests, using a radius of 1 for both spherical and ellipsoid methods. The result is:

02-26 21:27:57.305: I/Collision(31851): Object collisions
02-26 21:27:57.315: I/Collision(31851): FirstContact:(0.0,-1.0,0.0) Algo:Ray
02-26 21:27:57.365: I/Collision(31851): FirstContact:(0.0,-2.1,0.0) Algo:Ellipsoid
02-26 21:27:57.365: I/Collision(31851): Ellipsoid adjusted: (0.0,0.4000001,0.0)
02-26 21:27:57.385: I/Collision(31851): FirstContact:(0.037469428,-1.999996,0.005934572) Algo:Sphere
02-26 21:27:57.385: I/Collision(31851): Spherical adjusted: (0.037469428,0.50000405,0.005934572)

Ray and Sphere seem right, but ellipsoid appears to detect 0.1 units before it should. Changing the recursion depth 1-5 doesn't have an effect. Thoughts?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12110
    • View Profile
Re: Behavior of Ellipsoid collision detection
« Reply #1 on: February 26, 2013, 09:48:48 pm »
While i somehow fail to see why this should be a real issue, try to adjust this setting in Config:

Just don't make it too small or you'll get stuck. Keep in mind, that ellipsoid collision detection is a collision avoidance algorithm, while spherical collision detection actually resolves active collisions. That means that the ellipsoid approach has to make sure that no collision happens..never. Simply because it couldn't resolve them, if they would occur. That's one reason why it maintains a little "gap" between entities.

Offline mesh

  • byte
  • *
  • Posts: 3
    • View Profile
Re: Behavior of Ellipsoid collision detection
« Reply #2 on: February 26, 2013, 11:05:49 pm »
Yeah, it was more just something I found while playing around with the different algorithms. Thanks for the explanation.