public void TestFindContactsOnSphere() { Volumes.Sphere3 sphere = new Volumes.Sphere3( new Vector3(15.0f, 15.0f, 15.0f), 5.0f ); float outRadius = 5.0f + Specifications.MaximumDeviation; Assert.AreEqual( new float[] { 10.0f / 30.0f, 20.0f / 30.0f }, new Segment3( new Vector3(0.0f, 15.0f, 15.0f), new Vector3(30.0f, 15.0f, 15.0f) ).FindContacts(sphere), "Contact locations on sphere 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(sphere), "Close miss of sphere 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(sphere), "Close miss of sphere 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(sphere), "Close miss of sphere 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(sphere), "Close miss of sphere 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(sphere), "Close miss of sphere 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(sphere), "Close miss of sphere on Z axis properly handled" ); Assert.AreEqual( new float[] { 10.0f / 30.0f, 20.0f / 30.0f }, new Segment3( new Vector3(15.0f, 0.0f, 15.0f), new Vector3(15.0f, 30.0f, 15.0f) ).FindContacts(sphere), "Contact locations on sphere 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(sphere), "Close miss of sphere 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(sphere), "Close miss of sphere 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(sphere), "Close miss of sphere 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(sphere), "Close miss of sphere 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(sphere), "Close miss of sphere 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(sphere), "Close miss of sphere on Z axis properly handled" ); Assert.AreEqual( new float[] { 10.0f / 30.0f, 20.0f / 30.0f }, new Segment3( new Vector3(15.0f, 15.0f, 0.0f), new Vector3(15.0f, 15.0f, 30.0f) ).FindContacts(sphere), "Contact locations on sphere 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(sphere), "Close miss of sphere 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(sphere), "Close miss of sphere 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(sphere), "Close miss of sphere 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(sphere), "Close miss of sphere 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(sphere), "Close miss of sphere 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(sphere), "Close miss of sphere on Y axis properly handled" ); }
public void TestFindContactsOnSphere() { Volumes.Sphere3 sphere = new Volumes.Sphere3( new Vector3(15.0f, 15.0f, 15.0f), 5.0f ); float outRadius = 5.0f + Specifications.MaximumDeviation; Assert.AreEqual( new float[] { 10.0f, 20.0f }, new Line3(new Vector3(0.0f, 15.0f, 15.0f), Vector3.Right).FindContacts(sphere), "Contact locations on sphere for X sweep found" ); Assert.IsNull( new Line3(new Vector3(0.0f, 15.0f - outRadius, 15.0f), Vector3.Right).FindContacts(sphere), "Close miss of sphere on Y axis properly handled" ); Assert.IsNull( new Line3(new Vector3(0.0f, 15.0f + outRadius, 15.0f), Vector3.Right).FindContacts(sphere), "Close miss of sphere on Y axis properly handled" ); Assert.IsNull( new Line3(new Vector3(0.0f, 15.0f, 15.0f - outRadius), Vector3.Right).FindContacts(sphere), "Close miss of sphere on Z axis properly handled" ); Assert.IsNull( new Line3(new Vector3(0.0f, 15.0f, 15.0f + outRadius), Vector3.Right).FindContacts(sphere), "Close miss of sphere on Z axis properly handled" ); Assert.AreEqual( new float[] { 10.0f, 20.0f }, new Line3(new Vector3(15.0f, 0.0f, 15.0f), Vector3.Up).FindContacts(sphere), "Contact locations on sphere for Y sweep found" ); Assert.IsNull( new Line3(new Vector3(15.0f - outRadius, 0.0f, 15.0f), Vector3.Up).FindContacts(sphere), "Close miss of sphere on X axis properly handled" ); Assert.IsNull( new Line3(new Vector3(15.0f + outRadius, 0.0f, 15.0f), Vector3.Up).FindContacts(sphere), "Close miss of sphere on X axis properly handled" ); Assert.IsNull( new Line3(new Vector3(15.0f, 0.0f, 15.0f - outRadius), Vector3.Up).FindContacts(sphere), "Close miss of sphere on Z axis properly handled" ); Assert.IsNull( new Line3(new Vector3(15.0f, 0.0f, 15.0f + outRadius), Vector3.Up).FindContacts(sphere), "Close miss of sphere 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(sphere), "Contact locations on sphere for Z sweep found" ); Assert.IsNull( new Line3(new Vector3(15.0f - outRadius, 15.0f, 0.0f), Vector3.Backward).FindContacts(sphere), "Close miss of sphere on X axis properly handled" ); Assert.IsNull( new Line3(new Vector3(15.0f + outRadius, 15.0f, 0.0f), Vector3.Backward).FindContacts(sphere), "Close miss of sphere on X axis properly handled" ); Assert.IsNull( new Line3(new Vector3(15.0f, 15.0f - outRadius, 0.0f), Vector3.Backward).FindContacts(sphere), "Close miss of sphere on Y axis properly handled" ); Assert.IsNull( new Line3(new Vector3(15.0f, 15.0f + outRadius, 0.0f), Vector3.Backward).FindContacts(sphere), "Close miss of sphere on Y axis properly handled" ); }
public void TestFindContactsOnSphere() { Volumes.Sphere3 sphere = new Volumes.Sphere3( new Vector3(15.0f, 15.0f, 15.0f), 5.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(sphere), "Contact locations on sphere 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(sphere), "Contact locations on sphere for X sweep starting in sphere found" ); Assert.IsNull( new Ray3(new Vector3(15.0f + outRadius, 15.0f, 15.0f), Vector3.Right).FindContacts(sphere), "Close miss of sphere on X axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(0.0f, 15.0f - outRadius, 15.0f), Vector3.Right).FindContacts(sphere), "Close miss of sphere on Y axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(0.0f, 15.0f + outRadius, 15.0f), Vector3.Right).FindContacts(sphere), "Close miss of sphere on Y axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(0.0f, 15.0f, 15.0f - outRadius), Vector3.Right).FindContacts(sphere), "Close miss of sphere on Z axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(0.0f, 15.0f, 15.0f + outRadius), Vector3.Right).FindContacts(sphere), "Close miss of sphere 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(sphere), "Contact locations on sphere 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(sphere), "Contact locations on sphere for Y sweep starting in sphere found" ); Assert.IsNull( new Ray3(new Vector3(15.0f, 15.0f + outRadius, 15.0f), Vector3.Up).FindContacts(sphere), "Close miss of sphere on Y axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(15.0f - outRadius, 0.0f, 15.0f), Vector3.Up).FindContacts(sphere), "Close miss of sphere on X axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(15.0f + outRadius, 0.0f, 15.0f), Vector3.Up).FindContacts(sphere), "Close miss of sphere on X axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(15.0f, 0.0f, 15.0f - outRadius), Vector3.Up).FindContacts(sphere), "Close miss of sphere on Z axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(15.0f, 0.0f, 15.0f + outRadius), Vector3.Up).FindContacts(sphere), "Close miss of sphere 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(sphere), "Contact locations on sphere 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(sphere), "Contact locations on sphere for Z sweep starting in sphere found" ); Assert.IsNull( new Ray3(new Vector3(15.0f, 15.0f, 15.0f + outRadius), Vector3.Backward).FindContacts(sphere), "Close miss of sphere on Z axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(15.0f - outRadius, 15.0f, 0.0f), Vector3.Backward).FindContacts(sphere), "Close miss of sphere on X axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(15.0f + outRadius, 15.0f, 0.0f), Vector3.Backward).FindContacts(sphere), "Close miss of sphere on X axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(15.0f, 15.0f - outRadius, 0.0f), Vector3.Backward).FindContacts(sphere), "Close miss of sphere on Y axis properly handled" ); Assert.IsNull( new Ray3(new Vector3(15.0f, 15.0f + outRadius, 0.0f), Vector3.Backward).FindContacts(sphere), "Close miss of sphere on Y axis properly handled" ); }