public void CircleIntersectionWithPlaneTest() { // parallel obecjts Circle3d c = new Circle3d(new Point3d(5, 6, 1), 5, new Vector3d(0, 0, 1)); Plane3d s = new Plane3d(new Point3d(0, 0, 0), new Vector3d(0, 0, 1)); Assert.AreEqual(c.IntersectionWith(s), null); // coplanar objects s = new Plane3d(new Point3d(0, 0, 1), new Vector3d(0, 0, 1)); Assert.AreEqual(c.IntersectionWith(s), c); // nonintersecting objects c = new Circle3d(new Point3d(5, 6, 10), 5, new Vector3d(0, 0, 1)); s = new Plane3d(new Point3d(0, 0, 1), new Vector3d(0, 0, 1)); Assert.AreEqual(c.IntersectionWith(s), null); // intersection in one point c = new Circle3d(new Point3d(0, 0, 3), 5, new Vector3d(3, 0, 4)); s = new Plane3d(new Point3d(5, 5, 0), new Vector3d(0, 0, 1)); Assert.AreEqual(c.IntersectionWith(s), new Point3d(4, 0, 0)); // intersection in two points c = new Circle3d(new Point3d(0, 0, 3), 5, new Vector3d(3, 0, 0)); s = new Plane3d(new Point3d(5, 5, 0), new Vector3d(0, 0, 1)); Assert.AreEqual(c.IntersectionWith(s), new Segment3d(new Point3d(0, 4, 0), new Point3d(0, -4, 0))); }
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)); // 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)); // 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); // 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); // 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); }
public void CircleIntersectionWithRayTest() { // intersection in one point (crossing ray) Circle3d c = new Circle3d(new Point3d(0, 0, 0), 5, new Vector3d(0, 0, 1)); Ray3d r = new Ray3d(new Point3d(0, 0, 0), new Vector3d(1, 0, 0)); Assert.AreEqual(c.IntersectionWith(r), new Segment3d(new Point3d(5, 0, 0), new Point3d(0, 0, 0))); // intersection in one point (touching line) r = new Ray3d(new Point3d(5, 0, 0), new Vector3d(1, 0, 0)); Assert.AreEqual(c.IntersectionWith(r), new Point3d(5, 0, 0)); }
public void CircleIntersectionWithLineTest() { // parallel obecjts Circle3d c = new Circle3d(new Point3d(0, 0, 0), 5, new Vector3d(0, 0, 1)); Line3d l = new Line3d(new Point3d(0, 0, 1), new Vector3d(1, 0, 0)); Assert.AreEqual(c.IntersectionWith(l), null); // nonintersecting objects c = new Circle3d(new Point3d(0, 0, 0), 5, new Vector3d(0, 0, 1)); l = new Line3d(new Point3d(10, 0, 0), new Vector3d(1, 1, 0)); Assert.AreEqual(c.IntersectionWith(l), null); // intersection in one point (touching line) c = new Circle3d(new Point3d(0, 0, 0), 5, new Vector3d(0, 0, 1)); l = new Line3d(new Point3d(5, 0, 0), new Vector3d(0, 1, 0)); Assert.AreEqual(c.IntersectionWith(l), new Point3d(5, 0, 0)); // intersection in one point (crossing line) c = new Circle3d(new Point3d(0, 0, 0), 5, new Vector3d(0, 0, 1)); l = new Line3d(new Point3d(1, 1, 0), new Vector3d(0, 0, 1)); Assert.AreEqual(c.IntersectionWith(l), new Point3d(1, 1, 0)); // intersection in two points c = new Circle3d(new Point3d(0, 0, 0), 5, new Vector3d(0, 0, 1)); l = new Line3d(new Point3d(0, -4, 0), new Vector3d(1, 0, 0)); Assert.AreEqual(c.IntersectionWith(l), new Segment3d(new Point3d(-3, -4, 0), new Point3d(3, -4, 0))); }
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); // Coincided circles c2 = new Circle3d(new Point3d(0, 0, 0), 5, new Vector3d(0, 0, 1)); Assert.AreEqual(c1.IntersectionWith(c2), c1); // Separated circles c2 = new Circle3d(new Point3d(10, 0, 0), 2, new Vector3d(0, 0, 1)); Assert.AreEqual(c1.IntersectionWith(c2), null); // 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)); // 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)); // 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)); // 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); }
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 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); // 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); // 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); // 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); // Restore initial state GeometRi3D.UseAbsoluteTolerance = mode; GeometRi3D.Tolerance = tol; }