// all of the contacts where second's edges intersect first's body // handles all cordinate transformation from each body to the world private IEnumerable <Contact> ContactsOnFirst(IBody first, IBody second) { IEdgeIntersector firstShape = first.CollisionShape; IEdgeIntersector secondShape = second.CollisionShape; Transform firstTransform = first.Dynamics.Transform; Transform secondTransform = second.Dynamics.Transform; var secondToFirst = new Transformation(secondTransform, firstTransform); if (IntersectStrats.HasStrategy(firstShape, secondShape)) { return(IntersectStrats.EnactStrategy(firstShape, secondShape, secondToFirst.Reverse()).Select(i => new Contact(i, first, second))); } // general case return // everything is converted to the firsts local transform coords (secondShape.Edges.SelectMany(secondEdge => firstShape.FindIntersections(secondToFirst.TransformEdge(secondEdge)) .Select(i => new Contact(firstTransform.ToWorldSpace(i), first, second)))); // then to world coords }