Code center > Darwinbots3
Collision detection tests
Numsgil:
--- Quote from: Peter on August 05, 2013, 06:52:35 PM ---Added 2 tests. Gotta start somewhere. ;)
--- End quote ---
Great! I've added it to my working copy. I'm still neck deep in changes or I'd check it in right now.
--- Quote ---In polygon vs. polygon. Does the test EdgeEdgeSolidHit work as it should?
I see CheckEqual(4, output.TOI); From the code behind it I assume it's the same as timeOfImpact. I also assume the polygon position is based on the center of the polygon. That makes from the distance of 10 at the center a effective distance of 8. That would mean the actual time of impact would be ~3.6 instead of 4. If not how does it define the start location of the polygon?
--- End quote ---
It's 8, yeah. Hmm... check my math?
1/2 * (-1 ) * t^2 = -8
t = 4
I stopped working on the tests in poly vs poly as it became obvious that I needed to return more than a single hit. That's what I'm working out right now. I should have some proper tests for you to use as a template in the next few days. But if you'd like to think up some tests cases in the mean time, all the better. This is the struct for a hit I'm using currently:
--- Code: ---public class Hit
{
public Scalar TOI;
public Polygon.Edge Edge;
public Scalar HitFraction;
public Polygon.Vertex Vertex;
public bool IsEntering;
}
--- End code ---
In the case of vertex-vertex collisions, the hit fraction is 0 and only one hit is recorded. Hopefully that's enough to go on for now. Once I lock down the API a bit more I'll start checking things in.
Peter:
Ah, that math does work out, never mind.
Where would I find the Hit objects. An array in RotatingSimplePolygonvsRotatingSimplePolygon.output or something?
Numsgil:
It'll be a List<Hit> most likely, sorted by TOIs.
Panda:
Just here to say that I would like to help with these tests. :) If you would me to, Peter?
Peter:
Sure, if you can think of some complicated ways that polygons collide or just miss. If you know how to make the test cases even better. :)
All I did so far were just some hit and miss tests with squares. Waiting to turn that in till the API locks in so checks can be properly modified.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version