Sign in to follow this  

Collision Detection test cases

Recommended Posts

I'm working on GJK and Conservative Advancement for my 2D physics engine. I'm also heavily unit testing things. So far I've just been making up unit test cases, but my concern is that I'm missing edge cases. Is there a library of test cases for collision detection somewhere I could copy in to my unit tests? Something describing initial conditions and proper end conditions for various basic and edge cases? Like for GJK one of my unit tests looks like:
IShape quad = new Polygon(new Vector[] { new Vector(-1, 1), new Vector(1, 1), new Vector(1, -1), new Vector(-1, -1) } );

Matrix transformA = new Matrix(0, new Vector(0, 0));
Matrix transformB = new Matrix(-Math.PI / 4, new Vector(-20, 0));

Vector ptA = Vector.Zero;
Vector ptB = Vector.Zero;

	quad, transformA, transformA.Inverse(), ref ptA,
	quad, transformB, transformB.Inverse(), ref ptB

CheckEqual(new Vector(-1, 0), ptA);
CheckEqual(new Vector(1, 1), ptB);
It tests Vertex-to-Edge nearest features. I have various initial conditions, and a black and white test condition which is either true or false. But coming up with test conditions is absolutely exhausting.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this