public unsafe void IntersectsFuzz(int count) { var boxes = new BoxF[count]; var rng = RandomNumberGenerator.Create(); fixed(BoxF *pBoxes = &boxes[0]) rng.GetBytes(new Span <byte>(pBoxes, count * sizeof(BoxF))); for (var i = 0; i < count; ++i) { boxes[i].Normalize(); } for (var i = 0; i < count; ++i) { for (var j = 0; j < count; ++j) { Assert.AreEqual( BoxF.IsIntersectingNaive(boxes[i], boxes[j]), BoxF.IsIntersectingSse(boxes[i], boxes[j]), $"Mismatch {boxes[i]} vs. {boxes[j]}" ); } } }
public void IntersectsSanity() { Assert.True(BoxF.IsIntersectingNaive(Boxes1[1], Boxes1[0])); Assert.True(BoxF.IsIntersectingNaive(Boxes2[0], Boxes2[1])); Assert.True(BoxF.IsIntersectingNaive(Boxes1[0], Boxes1[1])); Assert.True(BoxF.IsIntersectingNaive(Boxes2[1], Boxes2[0])); for (var i = 0; i < 4; ++i) { Assert.True(BoxF.IsIntersectingNaive(Boxes2[0], Boxes2[3 + i])); Assert.True(BoxF.IsIntersectingNaive(Boxes2[3 + i], Boxes2[0])); } for (var i = 0; i < 4; ++i) { Assert.False(BoxF.IsIntersectingNaive(Boxes2[1], Boxes2[3 + i])); Assert.False(BoxF.IsIntersectingNaive(Boxes2[2], Boxes2[3 + i])); } }