public void BoxTransformTest() { var cnt = 10000; var rnd = new RandomSystem(1); var trafos = new M44d[cnt].SetByIndex(i => new M44d(rnd.CreateUniformDoubleArray(16))); //var trafos = new M44d[cnt].SetByIndex(i => M44d.FromBasis(rnd.UniformV3d(), rnd.UniformV3d(), rnd.UniformV3d(), rnd.UniformV3d())); //var trafos = new M44d[cnt].SetByIndex(i => M44d.Translation(rnd.UniformV3d())); //var trafos = new M44d[cnt].SetByIndex(i => M44d.Rotation(rnd.UniformV3d()) * M44d.Translation(rnd.UniformV3d())); var boxes = new Box3d[cnt].SetByIndex(i => Box3d.FromCenterAndSize(rnd.UniformV3d(), rnd.UniformV3d())); var refBoxes = boxes.Map((b, i) => Transform1(b, trafos[i])); for (int j = 0; j < 10; j++) { Report.BeginTimed("Transform Boxes Aardvark"); for (int i = 0; i < trafos.Length; i++) { var test = boxes[i].Transformed(trafos[i]); Assert.IsTrue(test.Min.ApproximateEquals(refBoxes[i].Min, 1e-7) && test.Max.ApproximateEquals(refBoxes[i].Max, 1e-7)); } Report.End(); Report.BeginTimed("Transform Boxes1"); for (int i = 0; i < trafos.Length; i++) { var test = Transform1(boxes[i], trafos[i]); Assert.IsTrue(test.Min.ApproximateEquals(refBoxes[i].Min, 1e-7) && test.Max.ApproximateEquals(refBoxes[i].Max, 1e-7)); } Report.End(); Report.BeginTimed("Transform Boxes2"); for (int i = 0; i < trafos.Length; i++) { var test = Transform2(boxes[i], trafos[i]); Assert.IsTrue(test.Min.ApproximateEquals(refBoxes[i].Min, 1e-7) && test.Max.ApproximateEquals(refBoxes[i].Max, 1e-7)); } Report.End(); Report.BeginTimed("Transform Boxes3"); for (int i = 0; i < trafos.Length; i++) { var test = Transform3(boxes[i], trafos[i]); Assert.IsTrue(test.Min.ApproximateEquals(refBoxes[i].Min, 1e-7) && test.Max.ApproximateEquals(refBoxes[i].Max, 1e-7)); } Report.End(); Report.BeginTimed("Transform Boxes4"); for (int i = 0; i < trafos.Length; i++) { var test = Transform4(boxes[i], trafos[i]); Assert.IsTrue(test.Min.ApproximateEquals(refBoxes[i].Min, 1e-7) && test.Max.ApproximateEquals(refBoxes[i].Max, 1e-7)); } Report.End(); } }