public void TestFindContactsOnAxisAlignedBox() { Volumes.AxisAlignedBox3 box = new Volumes.AxisAlignedBox3( new Vector3(10.0f, 10.0f, 10.0f), new Vector3(20.0f, 20.0f, 20.0f) ); float outRadius = 5.0f + Specifications.HullAccuracy; Assert.AreEqual( new float[] { 10.0f, 20.0f }, new Line3(new Vector3(0.0f, 15.0f, 15.0f), Vector3.Right).FindContacts(box), "Contact locations on AAB for X sweep found" ); Assert.IsNull( new Line3(new Vector3(0.0f, 15.0f - outRadius, 15.0f), Vector3.Right).FindContacts(box), "Close miss of AAB on Y axis properly handled" ); Assert.IsNull( new Line3(new Vector3(0.0f, 15.0f + outRadius, 15.0f), Vector3.Right).FindContacts(box), "Close miss of AAB on Y axis properly handled" ); Assert.IsNull( new Line3(new Vector3(0.0f, 15.0f, 15.0f - outRadius), Vector3.Right).FindContacts(box), "Close miss of AAB on Z axis properly handled" ); Assert.IsNull( new Line3(new Vector3(0.0f, 15.0f, 15.0f + outRadius), Vector3.Right).FindContacts(box), "Close miss of AAB on Z axis properly handled" ); Assert.AreEqual( new double[] { 10.0f, 20.0f }, new Line3(new Vector3(15.0f, 0.0f, 15.0f), Vector3.Up).FindContacts(box), "Contact locations on AAB for Y sweep found" ); Assert.IsNull( new Line3(new Vector3(15.0f - outRadius, 0.0f, 15.0f), Vector3.Up).FindContacts(box), "Close miss of AAB on X axis properly handled" ); Assert.IsNull( new Line3(new Vector3(15.0f + outRadius, 0.0f, 15.0f), Vector3.Up).FindContacts(box), "Close miss of AAB on X axis properly handled" ); Assert.IsNull( new Line3(new Vector3(15.0f, 0.0f, 15.0f - outRadius), Vector3.Up).FindContacts(box), "Close miss of AAB on Z axis properly handled" ); Assert.IsNull( new Line3(new Vector3(15.0f, 0.0f, 15.0f + outRadius), Vector3.Up).FindContacts(box), "Close miss of AAB on Z axis properly handled" ); Assert.AreEqual( new float[] { 10.0f, 20.0f }, new Line3(new Vector3(15.0f, 15.0f, 0.0f), Vector3.Backward).FindContacts(box), "Contact locations on AAB for Z sweep found" ); Assert.IsNull( new Line3(new Vector3(15.0f - outRadius, 15.0f, 0.0f), Vector3.Backward).FindContacts(box), "Close miss of AAB on X axis properly handled" ); Assert.IsNull( new Line3(new Vector3(15.0f + outRadius, 15.0f, 0.0f), Vector3.Backward).FindContacts(box), "Close miss of AAB on X axis properly handled" ); Assert.IsNull( new Line3(new Vector3(15.0f, 15.0f - outRadius, 0.0f), Vector3.Backward).FindContacts(box), "Close miss of AAB on Y axis properly handled" ); Assert.IsNull( new Line3(new Vector3(15.0f, 15.0f + outRadius, 0.0f), Vector3.Backward).FindContacts(box), "Close miss of AAB on Y axis properly handled" ); }
public void TestFindContactsOnAxisAlignedBox() { Volumes.AxisAlignedBox3 box = new Volumes.AxisAlignedBox3( new Vector3(10.0f, 10.0f, 10.0f), new Vector3(20.0f, 20.0f, 20.0f) ); float outRadius = 5.0f + Specifications.MaximumDeviation; Assert.AreEqual( new float[] { 10.0f / 30.0f, 20.0f / 30.0f }, // 30.0f to take line's length into account new Segment3( new Vector3(0.0f, 15.0f, 15.0f), new Vector3(30.0f, 15.0f, 15.0f) ).FindContacts(box), "Contact locations on AAB for X sweep found" ); Assert.IsNull( new Segment3( new Vector3(0.0f, 15.0f, 15.0f), new Vector3(15.0f - outRadius, 15.0f, 15.0f) ).FindContacts(box), "Close miss of AAB on X axis properly handled" ); Assert.IsNull( new Segment3( new Vector3(15.0f + outRadius, 15.0f, 15.0f), new Vector3(30.0f, 15.0f, 15.0f) ).FindContacts(box), "Close miss of AAB on X axis properly handled" ); Assert.IsNull( new Segment3( new Vector3(0.0f, 15.0f - outRadius, 15.0f), new Vector3(30.0f, 15.0f - outRadius, 15.0f) ).FindContacts(box), "Close miss of AAB on Y axis properly handled" ); Assert.IsNull( new Segment3( new Vector3(0.0f, 15.0f + outRadius, 15.0f), new Vector3(30.0f, 15.0f + outRadius, 15.0f) ).FindContacts(box), "Close miss of AAB on Y axis properly handled" ); Assert.IsNull( new Segment3( new Vector3(0.0f, 15.0f, 15.0f - outRadius), new Vector3(30.0f, 15.0f, 15.0f - outRadius) ).FindContacts(box), "Close miss of AAB on Z axis properly handled" ); Assert.IsNull( new Segment3( new Vector3(0.0f, 15.0f, 15.0f + outRadius), new Vector3(30.0f, 15.0f, 15.0f + outRadius) ).FindContacts(box), "Close miss of AAB on Z axis properly handled" ); Assert.AreEqual( new float[] { 10.0f / 30.0f, 20.0f / 30.0f }, // 30.0 to take line's length into account new Segment3( new Vector3(15.0f, 0.0f, 15.0f), new Vector3(15.0f, 30.0f, 15.0f) ).FindContacts(box), "Contact locations on AAB for Y sweep found" ); Assert.IsNull( new Segment3( new Vector3(15.0f, 0.0f, 15.0f), new Vector3(15.0f, 15.0f - outRadius, 15.0f) ).FindContacts(box), "Close miss of AAB on Y axis properly handled" ); Assert.IsNull( new Segment3( new Vector3(15.0f, 15.0f + outRadius, 15.0f), new Vector3(15.0f, 30.0f, 15.0f) ).FindContacts(box), "Close miss of AAB on Y axis properly handled" ); Assert.IsNull( new Segment3( new Vector3(15.0f - outRadius, 0.0f, 15.0f), new Vector3(15.0f - outRadius, 30.0f, 15.0f) ).FindContacts(box), "Close miss of AAB on X axis properly handled" ); Assert.IsNull( new Segment3( new Vector3(15.0f + outRadius, 0.0f, 15.0f), new Vector3(15.0f + outRadius, 30.0f, 15.0f) ).FindContacts(box), "Close miss of AAB on X axis properly handled" ); Assert.IsNull( new Segment3( new Vector3(15.0f, 0.0f, 15.0f - outRadius), new Vector3(15.0f, 30.0f, 15.0f - outRadius) ).FindContacts(box), "Close miss of AAB on Z axis properly handled" ); Assert.IsNull( new Segment3( new Vector3(15.0f, 0.0f, 15.0f + outRadius), new Vector3(15.0f, 30.0f, 15.0f + outRadius) ).FindContacts(box), "Close miss of AAB on Z axis properly handled" ); Assert.AreEqual( new float[] { 10.0f / 30.0f, 20.0f / 30.0f }, // 30.0 to take line's length into account new Segment3( new Vector3(15.0f, 15.0f, 0.0f), new Vector3(15.0f, 15.0f, 30.0f) ).FindContacts(box), "Contact locations on AAB for Z sweep found" ); Assert.IsNull( new Segment3( new Vector3(15.0f, 15.0f, 0.0f), new Vector3(15.0f, 15.0f, 15.0f - outRadius) ).FindContacts(box), "Close miss of AAB on Z axis properly handled" ); Assert.IsNull( new Segment3( new Vector3(15.0f, 15.0f, 15.0f + outRadius), new Vector3(15.0f, 15.0f, 30.0f) ).FindContacts(box), "Close miss of AAB on Z axis properly handled" ); Assert.IsNull( new Segment3( new Vector3(15.0f - outRadius, 15.0f, 0.0f), new Vector3(15.0f - outRadius, 15.0f, 30.0f) ).FindContacts(box), "Close miss of AAB on X axis properly handled" ); Assert.IsNull( new Segment3( new Vector3(15.0f + outRadius, 15.0f, 0.0f), new Vector3(15.0f + outRadius, 15.0f, 30.0f) ).FindContacts(box), "Close miss of AAB on X axis properly handled" ); Assert.IsNull( new Segment3( new Vector3(15.0f, 15.0f - outRadius, 0.0f), new Vector3(15.0f, 15.0f - outRadius, 30.0f) ).FindContacts(box), "Close miss of AAB on Y axis properly handled" ); Assert.IsNull( new Segment3( new Vector3(15.0f, 15.0f + outRadius, 0.0f), new Vector3(15.0f, 15.0f + outRadius, 30.0f) ).FindContacts(box), "Close miss of AAB on Y axis properly handled" ); }
public void TestFindContactsOnAxisAlignedBox() { Volumes.AxisAlignedBox3 box = new Volumes.AxisAlignedBox3( new Vector3(10.0f, 10.0f, 10.0f), new Vector3(20.0f, 20.0f, 20.0f) ); float outRadius = 5.0f + Specifications.MaximumDeviation; Assert.AreEqual( new double[] { 10.0f, 20.0f }, new Ray3(new Vector3(0.0f, 15.0f, 15.0f), Vector3.Right).FindContacts(box), "Contact locations on AAB for X sweep found" ); Assert.AreEqual( new double[] { 0.0f, 5.0f }, new Ray3(new Vector3(15.0f, 15.0f, 15.0f), Vector3.Right).FindContacts(box), "Contact locations on AAB for X sweep starting in AAB found" ); Assert.IsNull( new Ray3(new Vector3(15.0f + outRadius, 15.0f, 15.0f), Vector3.Right).FindContacts(box), "Close miss of AAB on X axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(0.0f, 15.0f - outRadius, 15.0f), Vector3.Right).FindContacts(box), "Close miss of AAB on Y axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(0.0f, 15.0f + outRadius, 15.0f), Vector3.Right).FindContacts(box), "Close miss of AAB on Y axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(0.0f, 15.0f, 15.0f - outRadius), Vector3.Right).FindContacts(box), "Close miss of AAB on Z axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(0.0f, 15.0f, 15.0f + outRadius), Vector3.Right).FindContacts(box), "Close miss of AAB on Z axis properly handled" ); Assert.AreEqual( new double[] { 10.0f, 20.0f }, new Ray3(new Vector3(15.0f, 0.0f, 15.0f), Vector3.Up).FindContacts(box), "Contact locations on AAB for Y sweep found" ); Assert.AreEqual( new double[] { 0.0f, 5.0f }, new Ray3(new Vector3(15.0f, 15.0f, 15.0f), Vector3.Up).FindContacts(box), "Contact locations on AAB for Y sweep starting in AAB found" ); Assert.IsNull( new Ray3(new Vector3(15.0f, 15.0f + outRadius, 15.0f), Vector3.Up).FindContacts(box), "Close miss of AAB on Y axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(15.0f - outRadius, 0.0f, 15.0f), Vector3.Up).FindContacts(box), "Close miss of AAB on X axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(15.0f + outRadius, 0.0f, 15.0f), Vector3.Up).FindContacts(box), "Close miss of AAB on X axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(15.0f, 0.0f, 15.0f - outRadius), Vector3.Up).FindContacts(box), "Close miss of AAB on Z axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(15.0f, 0.0f, 15.0f + outRadius), Vector3.Up).FindContacts(box), "Close miss of AAB on Z axis properly handled" ); Assert.AreEqual( new double[] { 10.0f, 20.0f }, new Ray3(new Vector3(15.0f, 15.0f, 0.0f), Vector3.Backward).FindContacts(box), "Contact locations on AAB for Z sweep found" ); Assert.AreEqual( new double[] { 0.0f, 5.0f }, new Ray3(new Vector3(15.0f, 15.0f, 15.0f), Vector3.Backward).FindContacts(box), "Contact locations on AAB for Z sweep starting in AAB found" ); Assert.IsNull( new Ray3(new Vector3(15.0f, 15.0f, 15.0f + outRadius), Vector3.Backward).FindContacts(box), "Close miss of AAB on Z axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(15.0f - outRadius, 15.0f, 0.0f), Vector3.Backward).FindContacts(box), "Close miss of AAB on X axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(15.0f + outRadius, 15.0f, 0.0f), Vector3.Backward).FindContacts(box), "Close miss of AAB on X axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(15.0f, 15.0f - outRadius, 0.0f), Vector3.Backward).FindContacts(box), "Close miss of AAB on Y axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(15.0f, 15.0f + outRadius, 0.0f), Vector3.Backward).FindContacts(box), "Close miss of AAB on Y axis properly handled" ); }