public void Plane_IntersectionWithPlane_ZeroCases()
        {
            //try all the zero cases
            Point testPoint = Point.Origin;
            Point testPointX = Point.MakePointWithInches(10, 0, 0);
            Point testPointY = Point.MakePointWithInches(0, 10, 0);
            Point testPointZ = Point.MakePointWithInches(0, 0, 10);

            Plane testPlaneXY = new Plane(testPoint, testPointX, testPointY);
            Plane testPlaneXZ = new Plane(testPoint, testPointX, testPointZ);
            Plane testPlaneYZ = new Plane(testPoint, testPointY, testPointZ);

            Line testXYXZIntersect = testPlaneXZ.IntersectWithPlane(testPlaneXY);
            Line testXZXYIntersect = testPlaneXY.IntersectWithPlane(testPlaneXZ);
            testXYXZIntersect.Should().Be(Line.XAxis);
            testXZXYIntersect.Should().Be(Line.XAxis);

            Line testXYYZIntersect = testPlaneXY.IntersectWithPlane(testPlaneYZ);
            Line testYZXYIntersect = testPlaneYZ.IntersectWithPlane(testPlaneXY);
            testXYYZIntersect.Should().Be(Line.YAxis);
            testYZXYIntersect.Should().Be(Line.YAxis);

            Line testXZYZIntersect = testPlaneXZ.IntersectWithPlane(testPlaneYZ);
            Line testYZXZIntersect = testPlaneYZ.IntersectWithPlane(testPlaneXZ);
            testXZYZIntersect.Should().Be(Line.ZAxis);
            testYZXZIntersect.Should().Be(Line.ZAxis);

            Line testXYXY = testPlaneXY.IntersectWithPlane(testPlaneXY);
            testXYXY.Should().Be(Line.YAxis);
        }
        public void Plane_IntersectionWithPlane()
        {
            Plane testPlane1 = new Plane(new Direction(Point.MakePointWithInches(2, -1, 1)), Point.MakePointWithInches(2, 1, 2));
            Plane testPlane2 = new Plane(new Direction(Point.MakePointWithInches(1, 1, -1)), Point.MakePointWithInches(1, 3, 3));

            Line test12Intersect = testPlane1.IntersectWithPlane(testPlane2);
            Line test21Intersect = testPlane2.IntersectWithPlane(testPlane1);

            Line expectedLine = new Line(new Direction(Point.MakePointWithInches(0, 3, 3)), Point.MakePointWithInches(2, -1, 0));

            Assert.IsTrue(test12Intersect.Equals(test21Intersect));
            Assert.IsTrue(test21Intersect.Equals(expectedLine));
        }
        public void Plane_IntersectionWithPlane_IdenticalPlane()
        {
            Plane testPlane = new Plane(new Direction(2, -1, 1), Point.MakePointWithInches(2, 1, 2));

            Line found = (testPlane.IntersectWithPlane(testPlane));
            Line expected = new Line(new Direction(-1, 0, 2), Point.MakePointWithInches(2, 1, 2));

            testPlane.Contains(found).Should().BeTrue();
            (found == expected).Should().BeTrue();
        }
Esempio n. 4
0
        public Arc(Point basePoint, Point endPoint, Direction initialDirection)
        {
            this.BasePoint = basePoint;
            this.EndPoint = endPoint;
            if (this.IsClosed)
            {
                throw new GeometricException("Not enough information given to determine curvature.");
            }
            var segmentBetweenPoints = new LineSegment(basePoint,endPoint);
            this.NormalDirection = initialDirection.CrossProduct(segmentBetweenPoints.Direction);

            var plane1 = new Plane(BasePoint, initialDirection);
            var plane2 = new Plane(segmentBetweenPoints.MidPoint, segmentBetweenPoints.Direction);
            var intersectingLine = plane1.IntersectWithPlane(plane2);
            var containingPlane = new Plane(BasePoint, NormalDirection);
            var centerPoint = intersectingLine.IntersectWithPlane(containingPlane);
            this.CenterPoint = centerPoint;
            //var line1 = new Line(BasePoint, NormalDirection.CrossProduct(initialDirection));
            //var line2 = new Line(segmentBetweenPoints.MidPoint, NormalDirection.CrossProduct(segmentBetweenPoints.Direction));
            //this._centerPoint = line1.IntersectWithLine(line2);
        }