public void CircleIntersectionWithCircle3DTest() { // Touching circles Circle3d c1 = new Circle3d(new Point3d(0, 0, 0), 5, new Vector3d(0, 0, 1)); Circle3d c2 = new Circle3d(new Point3d(5, 0, 0), 5, new Vector3d(1, 0, 0)); Assert.AreEqual(c1.IntersectionWith(c2), new Point3d(5, 0, 0)); Assert.IsTrue(c1.Intersects(c2)); // Touching circles c1 = new Circle3d(new Point3d(0, 0, 0), 5, new Vector3d(0, 0, 1)); c2 = new Circle3d(new Point3d(5, 0, 5), 5, new Vector3d(1, 0, 0)); Assert.AreEqual(c1.IntersectionWith(c2), new Point3d(5, 0, 0)); Assert.IsTrue(c1.Intersects(c2)); // Non touching circles c1 = new Circle3d(new Point3d(0, 0, 0), 5, new Vector3d(0, 0, 1)); c2 = new Circle3d(new Point3d(6, 0, 5), 5, new Vector3d(1, 0, 0)); Assert.IsNull(c1.IntersectionWith(c2)); Assert.IsFalse(c1.Intersects(c2)); // Touching circles c2 = new Circle3d(new Point3d(10, 0, 0), 5, new Vector3d(0, 1, 0)); Assert.AreEqual(c1.IntersectionWith(c2), new Point3d(5, 0, 0)); Assert.IsTrue(c1.Intersects(c2)); // Intersecting circles c2 = new Circle3d(new Point3d(0, 0, 0), 5, new Vector3d(0, 1, 0)); Segment3d s = new Segment3d(new Point3d(-5, 0, 0), new Point3d(5, 0, 0)); Assert.AreEqual(c1.IntersectionWith(c2), s); Assert.IsTrue(c1.Intersects(c2)); // Intersecting circles c2 = new Circle3d(new Point3d(5, 0, 0), 5, new Vector3d(0, 1, 0)); s = new Segment3d(new Point3d(0, 0, 0), new Point3d(5, 0, 0)); Assert.AreEqual(c1.IntersectionWith(c2), s); Assert.IsTrue(c1.Intersects(c2)); // Intersecting circles c2 = new Circle3d(new Point3d(0, 0, 4), 5, new Vector3d(0, 1, 0)); s = new Segment3d(new Point3d(-3, 0, 0), new Point3d(3, 0, 0)); Assert.AreEqual(c1.IntersectionWith(c2), s); Assert.IsTrue(c1.Intersects(c2)); }
public void BoxIntersectsCircleTest2() { Box3d box = new Box3d(new Point3d(0.5, 0.5, 0.5), 1, 1, 1); Circle3d c = new Circle3d(new Point3d(0.957494668177094, 1.08987119472114, -0.11622424522239), 0.154926580712558, new Vector3d(0.362303959251271, 0.267138656415756, 0.892957322249635)); Assert.IsFalse(c.Intersects(box)); }
public void CircleIntersectionWithCircle3DTest_6() { Circle3d c1 = new Circle3d(new Point3d(0.54942463156146, 0.471633229492457, 0.687724718029017), 0.45, new Vector3d(0.00234836551341398, -0.00168595290036738, 0.00407955171963179)); Circle3d c2 = new Circle3d(new Point3d(0.466918419682331, 0.557604272259504, 0.400167832409575), 0.45, new Vector3d(0.000185747980640577, 0.0018045609707127, 0.00465929795040716)); Assert.IsTrue(c1.IntersectionWith(c2) != null); Assert.IsTrue(c2.IntersectionWith(c1) != null); Assert.IsTrue(c1.Intersects(c2)); Assert.IsTrue(c2.Intersects(c1)); }
public void TriangleIntersectsCircleTest() { Circle3d c = new Circle3d(new Point3d(), 1.0, new Vector3d(0, 0, 1)); // Coplanar objects // Triangle's vertecx inside circle Point3d p1 = new Point3d(0.5, 0.5, 0); Point3d p2 = new Point3d(2, 3, 0); Point3d p3 = new Point3d(-3, 1, 0); Triangle t = new Triangle(p1, p2, p3); Assert.IsTrue(c.Intersects(t)); // circle's center inside triangle p1 = new Point3d(-5, -5, 0); p2 = new Point3d(5, -5, 0); p3 = new Point3d(0, 5, 0); t = new Triangle(p1, p2, p3); Assert.IsTrue(c.Intersects(t)); // circle touch triangle p1 = new Point3d(1, -1, 0); p2 = new Point3d(1, 1, 0); p3 = new Point3d(3, 0, 0); t = new Triangle(p1, p2, p3); Assert.IsTrue(c.Intersects(t)); // Non-intersecting objects p1 = new Point3d(1.5, -1, 0); p2 = new Point3d(1.5, 1, 0); p3 = new Point3d(3, 0, 0); t = new Triangle(p1, p2, p3); Assert.IsFalse(c.Intersects(t)); // Non-coplanar objects p1 = new Point3d(0.5, 0.5, -1); p2 = new Point3d(0.5, -0.5, 1); p3 = new Point3d(0, 0, 1); t = new Triangle(p1, p2, p3); Assert.IsTrue(c.Intersects(t)); // Non-intersecting objects p1 = new Point3d(1.5, -1, -1); p2 = new Point3d(1.5, 1, -2); p3 = new Point3d(3, 0, -1); t = new Triangle(p1, p2, p3); Assert.IsFalse(c.Intersects(t)); // Non-intersecting objects p1 = new Point3d(1, 1, -1); p2 = new Point3d(1, 1, -2); p3 = new Point3d(1, 5, -1); t = new Triangle(p1, p2, p3); Assert.IsFalse(c.Intersects(t)); }
public void CircleIntersectsSphereTest() { Point3d p = new Point3d(); Circle3d c = new Circle3d(p, 1.0, new Vector3d(0, 0, 1)); // Intersecting objects Sphere s = new Sphere(new Point3d(0, 0, 1), 1.1); Assert.IsTrue(c.Intersects(s)); s = new Sphere(new Point3d(0, 0, 0), 10); Assert.IsTrue(c.Intersects(s)); s = new Sphere(new Point3d(2, 0, 0), 1.1); Assert.IsTrue(c.Intersects(s)); // Touching objects s = new Sphere(new Point3d(0, 0, 1), 1.0); Assert.IsTrue(c.Intersects(s)); s = new Sphere(new Point3d(2, 0, 0), 1.0); Assert.IsTrue(c.Intersects(s)); // Non-intersecting objects s = new Sphere(new Point3d(3, 0, 0), 1.0); Assert.IsFalse(c.Intersects(s)); }
public void BoxIntersectsCircleTest() { Box3d box = new Box3d(); Circle3d c = new Circle3d(new Point3d(), 1, new Vector3d(0, 0, 1)); Assert.IsTrue(c.Intersects(box)); c = new Circle3d(new Point3d(1.5, 0, 0), 1, new Vector3d(0, 0, 1)); Assert.IsTrue(c.Intersects(box)); c = new Circle3d(new Point3d(0.5, 0.5, 0.5), 1, new Vector3d(1, 1, 1)); Assert.IsTrue(c.Intersects(box)); c = new Circle3d(new Point3d(0.6, 0.6, 0.6), 1, new Vector3d(1, 1, 1)); Assert.IsFalse(c.Intersects(box)); }
public void CircleIntersectionWithCircle3DTest_5() { double tol = GeometRi3D.Tolerance; bool mode = GeometRi3D.UseAbsoluteTolerance; GeometRi3D.Tolerance = 0.01; GeometRi3D.UseAbsoluteTolerance = true; Circle3d c1 = new Circle3d(new Point3d(-0.15988, 0.3074, 0.11761), 0.1, new Vector3d(-0.14315, -0.33678, 0.93064)); Circle3d c2 = new Circle3d(new Point3d(-0.13031, 0.2539, 0.11499), 0.1, new Vector3d(0.70155, 0.62669, -0.33924)); Assert.IsTrue(c1.IntersectionWith(c2) != null); Assert.IsTrue(c2.IntersectionWith(c1) != null); Assert.IsTrue(c1.Intersects(c2)); Assert.IsTrue(c2.Intersects(c1)); // Restore initial state GeometRi3D.UseAbsoluteTolerance = mode; GeometRi3D.Tolerance = tol; }
public void CircleIntersectionWithCircle3DTest_4() { double tol = GeometRi3D.Tolerance; bool mode = GeometRi3D.UseAbsoluteTolerance; GeometRi3D.Tolerance = 0.03; GeometRi3D.UseAbsoluteTolerance = true; Circle3d c1 = new Circle3d(new Point3d(0.21512, -0.00082439, 0.17926), 0.3, new Vector3d(0.62821, -0.68096, 0.37636)); Circle3d c2 = new Circle3d(new Point3d(-0.038202, -0.090672, -0.078966), 0.3, new Vector3d(-0.060788, -0.026431, 0.9978)); Assert.IsTrue(c1.IntersectionWith(c2) != null); Assert.IsTrue(c2.IntersectionWith(c1) != null); Assert.IsTrue(c1.Intersects(c2)); Assert.IsTrue(c2.Intersects(c1)); // Restore initial state GeometRi3D.UseAbsoluteTolerance = mode; GeometRi3D.Tolerance = tol; }
public void CircleIntersectionWithCircle3DTest_3() { double tol = GeometRi3D.Tolerance; bool mode = GeometRi3D.UseAbsoluteTolerance; GeometRi3D.Tolerance = 0.04; GeometRi3D.UseAbsoluteTolerance = true; Circle3d c1 = new Circle3d(new Point3d(0.36335, -0.46836, -0.11003), 0.25, new Vector3d(0.89975, -0.12088, -0.41932)); Circle3d c2 = new Circle3d(new Point3d(0.18967, -0.14709, 0.081927), 0.25, new Vector3d(0.90756, -0.16092, -0.38787)); Assert.IsTrue(c1.IntersectionWith(c2) == null); Assert.IsTrue(c2.IntersectionWith(c1) == null); Assert.IsFalse(c1.Intersects(c2)); Assert.IsFalse(c2.Intersects(c1)); // Restore initial state GeometRi3D.UseAbsoluteTolerance = mode; GeometRi3D.Tolerance = tol; }
public void CircleIntersectionWithCircle3DTest_2() { double tol = GeometRi3D.Tolerance; bool mode = GeometRi3D.UseAbsoluteTolerance; GeometRi3D.Tolerance = 0.01; GeometRi3D.UseAbsoluteTolerance = true; Circle3d c1 = new Circle3d(new Point3d(-0.28776, -0.29482, -0.16311), 0.2, new Vector3d(-0.44759, -0.3224, -0.8341)); Circle3d c2 = new Circle3d(new Point3d(-0.35134, -0.27228, -0.12871), 0.2, new Vector3d(0.84394, -0.416, -0.33868)); Assert.IsTrue(c1.IntersectionWith(c2) != null); Assert.IsTrue(c2.IntersectionWith(c1) != null); Assert.IsTrue(c1.Intersects(c2)); Assert.IsTrue(c2.Intersects(c1)); // Restore initial state GeometRi3D.UseAbsoluteTolerance = mode; GeometRi3D.Tolerance = tol; }
public void CircleIntersectionWithCircle2DTest() { // parallel obecjts Circle3d c1 = new Circle3d(new Point3d(0, 0, 0), 5, new Vector3d(0, 0, 1)); Circle3d c2 = new Circle3d(new Point3d(5, 0, 1), 5, new Vector3d(0, 0, 1)); Assert.AreEqual(c1.IntersectionWith(c2), null); Assert.IsFalse(c1.Intersects(c2)); // Coincided circles c2 = new Circle3d(new Point3d(0, 0, 0), 5, new Vector3d(0, 0, 1)); Assert.AreEqual(c1.IntersectionWith(c2), c1); Assert.IsTrue(c1.Intersects(c2)); // Separated circles c2 = new Circle3d(new Point3d(10, 0, 0), 2, new Vector3d(0, 0, 1)); Assert.AreEqual(c1.IntersectionWith(c2), null); Assert.IsFalse(c1.Intersects(c2)); // Outer tangency c2 = new Circle3d(new Point3d(10, 0, 0), 5, new Vector3d(0, 0, 1)); Assert.AreEqual(c1.IntersectionWith(c2), new Point3d(5, 0, 0)); Assert.IsTrue(c1.Intersects(c2)); // Inner tangency 1 c2 = new Circle3d(new Point3d(3, 0, 0), 2, new Vector3d(0, 0, 1)); Assert.AreEqual(c1.IntersectionWith(c2), new Point3d(5, 0, 0)); Assert.IsTrue(c1.Intersects(c2)); // Inner tangency 2 c2 = new Circle3d(new Point3d(-2, 0, 0), 7, new Vector3d(0, 0, 1)); Assert.AreEqual(c1.IntersectionWith(c2), new Point3d(5, 0, 0)); Assert.IsTrue(c1.Intersects(c2)); // Intersection c2 = new Circle3d(new Point3d(6, 0, 0), 5, new Vector3d(0, 0, 1)); Segment3d s = new Segment3d(new Point3d(3, 4, 0), new Point3d(3, -4, 0)); Assert.AreEqual(c1.IntersectionWith(c2), s); Assert.IsTrue(c1.Intersects(c2)); }