public void PlaneIntersectionWithTwoPlanesTest() { Plane3d s1 = new Plane3d(new Point3d(0, 0, 1), new Vector3d(0, 1, 1)); Plane3d s2 = new Plane3d(-5, 2, 4, 1); Plane3d s3 = new Plane3d(2, -3, 2, 4); Assert.IsTrue((Point3d)s1.IntersectionWith(s2, s3) == (Point3d)s1.IntersectionWith((Line3d)s2.IntersectionWith(s3))); }
public void ToleranceTest() { Plane3d s1 = new Plane3d(new Point3d(0, 0, 1), new Vector3d(0, 1, 1)); Plane3d s2 = new Plane3d(-5, 2, 4, 1); Plane3d s3 = new Plane3d(2, -3, 2, 4); Assert.IsTrue((Point3d)s1.IntersectionWith(s2, s3) == (Point3d)s1.IntersectionWith((Line3d)s2.IntersectionWith(s3))); GeometRi3D.Tolerance = 0; Assert.IsFalse((Point3d)s1.IntersectionWith(s2, s3) == (Point3d)s1.IntersectionWith((Line3d)s2.IntersectionWith(s3))); GeometRi3D.Tolerance = 1E-12; }
public void PlaneIntersectionWithTwoPlanesTest3() { // Three coplanar planes // Three planes are coincide Plane3d s1 = new Plane3d(new Point3d(0, 0, 1), new Vector3d(1, 1, 1)); Plane3d s2 = new Plane3d(new Point3d(0, 1, 0), new Vector3d(1, 1, 1)); Plane3d s3 = new Plane3d(new Point3d(1, 0, 0), new Vector3d(-1, -1, -1)); Assert.IsTrue((Plane3d)s1.IntersectionWith(s2, s3) == s1); }
public void PlaneIntersectionWithTwoPlanesTest1() { // Three coplanar planes // Planes do not coincide Plane3d s1 = new Plane3d(new Point3d(0, 0, 1), new Vector3d(1, 1, 1)); Plane3d s2 = new Plane3d(new Point3d(2, 0, 1), new Vector3d(1, 1, 1)); Plane3d s3 = new Plane3d(new Point3d(0, 3, 1), new Vector3d(-1, -1, -1)); Assert.IsTrue(s1.IntersectionWith(s2, s3) == null); }
public void PlaneIntersectionWithLineTest() { // Inclined line Point3d p1 = new Point3d(1, -5, -1); Vector3d v1 = new Vector3d(-2, 3, 4); Line3d l1 = new Line3d(p1, v1); Plane3d s1 = new Plane3d(-2, 2, 3, -29); Assert.IsTrue((Point3d)s1.IntersectionWith(l1) == new Point3d(-3, 1, 7)); }
public void PlaneIntersectionWithTwoPlanesTest5() { // Three vertical planes (relative to the XY-plane) with NO common line Plane3d s1 = new Plane3d(new Point3d(1, 0, 0), new Vector3d(1, 1, 0)); Plane3d s2 = new Plane3d(new Point3d(0, 2, 2), new Vector3d(4, 2, 0)); Plane3d s3 = new Plane3d(new Point3d(3, 3, 4), new Vector3d(-1, 1, 0)); object obj = s1.IntersectionWith(s2, s3); Assert.IsTrue(obj == null); }
public void PlaneIntersectionWithLineTest3() { // Line lies in the plane Point3d p1 = new Point3d(1, 0, 0); Vector3d v1 = new Vector3d(1, 1, 1); Plane3d s1 = new Plane3d(p1, v1); p1 = new Point3d(0, 1, 0); Point3d p2 = new Point3d(0, 0, 1); Line3d l1 = new Line3d(p1, new Vector3d(p1, p2)); Assert.IsTrue((Line3d)s1.IntersectionWith(l1) == l1); }
public void PlaneIntersectionWithLineTest2() { // Parallel line Point3d p1 = new Point3d(1, 0, 0); Vector3d v1 = new Vector3d(1, 1, 1); Plane3d s1 = new Plane3d(p1, v1); p1 = new Point3d(0, 2, 0); Point3d p2 = new Point3d(0, 0, 2); Line3d l1 = new Line3d(p1, new Vector3d(p1, p2)); Assert.IsTrue(s1.IntersectionWith(l1) == null); }
public void PlaneConvertIntersectionToPlaneTest() { Coord3d coord1 = Coord3d.GlobalCS.Copy(); Coord3d coord2 = Coord3d.GlobalCS.Copy(); coord1.RotateDeg(new Vector3d(1, 1, 1), 90); coord2.RotateDeg(new Vector3d(1, 1, 1), 120); Plane3d s1 = new Plane3d(1, 1, 1, 0, Coord3d.GlobalCS); Plane3d s2 = new Plane3d(1, 3, 6, 0, coord1); Plane3d s3 = new Plane3d(100, -1000, 1, 0, coord2); Assert.IsTrue((Point3d)s1.IntersectionWith(s2, s3) == new Point3d(0, 0, 0)); }
public void PlaneConvertToTest() { Coord3d coord1 = Coord3d.GlobalCS.Copy(); Coord3d coord2 = Coord3d.GlobalCS.Copy(); coord2.RotateDeg(new Vector3d(1, 1, 1), 120); Point3d p1 = new Point3d(1, 2, 3, coord1); Vector3d v1 = new Vector3d(0, 0, 1); Line3d l1 = new Line3d(p1, v1); l1.Point = l1.Point.ConvertTo(coord2); Plane3d s1 = coord2.XZ_plane; s1.Point = s1.Point.ConvertTo(coord1); Assert.IsTrue((Point3d)s1.IntersectionWith(l1) == new Point3d(1, 2, 0)); }
public void PlaneIntersectionWithTwoPlanesTest4() { // Three vertical planes (relative to the XY-plane) with common line Plane3d s1 = new Plane3d(new Point3d(0, 0, 0), new Vector3d(1, 1, 0)); Plane3d s2 = new Plane3d(new Point3d(0, 0, 2), new Vector3d(4, 2, 0)); Plane3d s3 = new Plane3d(new Point3d(0, 0, 4), new Vector3d(-1, 1, 0)); object obj = s1.IntersectionWith(s2, s3); if (obj != null && obj.GetType() == typeof(Line3d)) { Line3d l1 = (Line3d)obj; Assert.IsTrue(l1 == new Line3d(new Point3d(0, 0, 0), new Vector3d(0, 0, 1))); } else { Assert.Fail(); } }
public void PlaneIntersectionWithTwoPlanesTest6() { // Three intersecting planes with common point Plane3d s1 = new Plane3d(new Point3d(1, 0, 0), new Vector3d(0, 1, 5)); Plane3d s2 = new Plane3d(new Point3d(0, 2, 0), new Vector3d(4, 0, 0)); Plane3d s3 = new Plane3d(new Point3d(0, 0, 0), new Vector3d(-1, 1, 3)); object obj = s1.IntersectionWith(s2, s3); if (obj != null && obj.GetType() == typeof(Point3d)) { Point3d p1 = (Point3d)obj; Assert.IsTrue(p1 == new Point3d(0, 0, 0)); } else { Assert.Fail(); } }
public void PlaneIntersectionWithPlanesTest() { Coord3d coord1 = Coord3d.GlobalCS.Copy(); Coord3d coord2 = Coord3d.GlobalCS.Copy(); coord1.RotateDeg(new Vector3d(1, 2, 3), 90); coord2.RotateDeg(new Vector3d(1, 1, 1), 120); coord1.Origin = new Point3d(1, 1, 1); coord2.Origin = new Point3d(10, 2, 5); Plane3d s1 = new Plane3d(1, 1, 1, 0, Coord3d.GlobalCS); Plane3d s2 = new Plane3d(3, -2, 0, 9, Coord3d.GlobalCS); Plane3d s3 = new Plane3d(2, 5, 1, -2, Coord3d.GlobalCS); Point3d p1 = (Point3d)s1.IntersectionWith(s2, s3); s1.Point = s1.Point.ConvertTo(coord2); s2.Normal = s2.Normal.ConvertTo(coord1).ConvertTo(coord2); s3.Point = s3.Point.ConvertTo(coord2).ConvertTo(coord1); Point3d p2 = (Point3d)s2.IntersectionWith(s1, s3); Assert.IsTrue(p1 == p2); }