示例#1
0
        public static Triangle ConstructDefaultTriangle()
        {
            Point other1 = PointFactory.GeneratePoint(Figure.GenerateIntValue(), 0);
            Point other2 = PointFactory.GeneratePoint(Figure.GenerateIntValue(), Figure.GenerateIntValue());

            return(new Triangle(origin, other1, other2));
        }
示例#2
0
        public static Trapezoid ConstructDefaultTrapezoid()
        {
            int smallBase = Figure.DefaultSideLength();
            int largeBase = Figure.DefaultSideLength();

            int height = Figure.DefaultSideLength();
            int offset = Figure.SmallIntegerValue();

            // Acquire a non-equal side.
            while (smallBase >= largeBase)
            {
                smallBase = Figure.DefaultSideLength();
                largeBase = Figure.DefaultSideLength();
            }

            Point topLeft     = PointFactory.GeneratePoint(offset, height);
            Point topRight    = PointFactory.GeneratePoint(offset + smallBase, height);
            Point bottomRight = PointFactory.GeneratePoint(largeBase, 0);

            Segment left   = new Segment(origin, topLeft);
            Segment top    = new Segment(topLeft, topRight);
            Segment right  = new Segment(topRight, bottomRight);
            Segment bottom = new Segment(bottomRight, origin);

            return(new Trapezoid(left, right, top, bottom));
        }
示例#3
0
        public static IsoscelesTrapezoid ConstructDefaultIsoscelesTrapezoid()
        {
            int base1 = Figure.DefaultSideLength();
            int side  = Figure.DefaultSideLength();

            // Ensure a smaller side then base for a 'normal' look.
            while (base1 <= side)
            {
                base1 = Figure.DefaultSideLength();
                side  = Figure.DefaultSideLength();
            }

            int   baseAngle = Figure.DefaultFirstQuadrantNonRightAngle();
            Point topLeft   = Figure.GetPointByLengthAndAngleInStandardPosition(side, baseAngle);

            topLeft = PointFactory.GeneratePoint(topLeft.X, topLeft.Y);

            Point topRight = Figure.GetPointByLengthAndAngleInThirdQuadrant(side, baseAngle);

            topRight = PointFactory.GeneratePoint(base1 + topRight.X, topRight.Y);

            Point bottomRight = PointFactory.GeneratePoint(base1, 0);

            Segment left   = new Segment(origin, topLeft);
            Segment top    = new Segment(topLeft, topRight);
            Segment right  = new Segment(topRight, bottomRight);
            Segment bottom = new Segment(bottomRight, origin);

            return(new IsoscelesTrapezoid(left, right, top, bottom));
        }
示例#4
0
        private List <Point> ConstructMidpoints(Point end1, Point end2, int level)
        {
            List <Point> middlePoints = new List <Point>();

            // Recursive Base Case
            if (level == NUM_MID_SEGMENT_POINTS)
            {
                return(middlePoints);
            }

            Point midpoint = PointFactory.GeneratePoint(end1.Midpoint(end2));

            //
            // Recursively construct all points between
            //
            middlePoints.AddRange(ConstructMidpoints(end1, midpoint, level + 1));

            middlePoints.Add(midpoint);

            // Add to the list of midpoints clauses (for instantiation during figure synthesis).
            midpoints.Add(new Midpoint(new InMiddle(midpoint, new Segment(end1, end2))));

            middlePoints.AddRange(ConstructMidpoints(midpoint, end2, level + 1));

            return(middlePoints);
        }
示例#5
0
        public static IsoscelesTriangle ConstructDefaultIsoscelesTriangle()
        {
            int baseLength = Figure.DefaultSideLength();
            int height     = Figure.DefaultSideLength();

            Point top         = PointFactory.GeneratePoint(baseLength / 2.0, height);
            Point bottomRight = PointFactory.GeneratePoint(baseLength, 0);

            Segment left   = new Segment(origin, top);
            Segment right  = new Segment(top, bottomRight);
            Segment bottom = new Segment(bottomRight, origin);

            return(new IsoscelesTriangle(left, right, bottom));
        }
示例#6
0
        public static RightTriangle ConstructDefaultRightTriangle()
        {
            int length = Figure.DefaultSideLength();
            int width  = Figure.DefaultSideLength();

            Point topLeft     = PointFactory.GeneratePoint(0, width);
            Point bottomRight = PointFactory.GeneratePoint(length, 0);

            Segment left       = new Segment(origin, topLeft);
            Segment hypotenuse = new Segment(topLeft, bottomRight);
            Segment bottom     = new Segment(bottomRight, origin);

            return(new RightTriangle(left, bottom, hypotenuse));
        }
示例#7
0
        public static Square ConstructDefaultSquare()
        {
            int length = Figure.DefaultSideLength();

            Point topLeft     = PointFactory.GeneratePoint(0, length);
            Point topRight    = PointFactory.GeneratePoint(length, length);
            Point bottomRight = PointFactory.GeneratePoint(length, 0);

            Segment left   = new Segment(origin, topLeft);
            Segment top    = new Segment(topLeft, topRight);
            Segment right  = new Segment(topRight, bottomRight);
            Segment bottom = new Segment(bottomRight, origin);

            return(new Square(left, right, top, bottom));
        }
示例#8
0
        public static EquilateralTriangle ConstructDefaultEquilateralTriangle()
        {
            int sideLength = Figure.DefaultSideLength();

            Point top = Figure.GetPointByLengthAndAngleInStandardPosition(sideLength, 60);

            top = PointFactory.GeneratePoint(top.X, top.Y);

            Point bottomRight = PointFactory.GeneratePoint(sideLength, 0);

            Segment left   = new Segment(origin, top);
            Segment right  = new Segment(top, bottomRight);
            Segment bottom = new Segment(bottomRight, origin);

            return(new EquilateralTriangle(left, right, bottom));
        }
示例#9
0
        public static Parallelogram ConstructDefaultParallelogram()
        {
            int baseLength = Figure.DefaultSideLength();
            int height     = Figure.DefaultSideLength();
            int offset     = Figure.SmallIntegerValue();

            Point topLeft     = PointFactory.GeneratePoint(offset, height);
            Point topRight    = PointFactory.GeneratePoint(offset + baseLength, height);
            Point bottomRight = PointFactory.GeneratePoint(baseLength, 0);

            Segment left   = new Segment(origin, topLeft);
            Segment top    = new Segment(topLeft, topRight);
            Segment right  = new Segment(topRight, bottomRight);
            Segment bottom = new Segment(bottomRight, origin);

            return(new Parallelogram(left, right, top, bottom));
        }
示例#10
0
        public static Kite ConstructDefaultKite()
        {
            int height = Figure.DefaultSideLength() / 2;
            int width1 = Figure.DefaultSideLength() / 2;
            int width2 = Figure.DefaultSideLength() / 2;

            Point top    = PointFactory.GeneratePoint(width1, height);
            Point right  = PointFactory.GeneratePoint(width1 + width2, 0);
            Point bottom = PointFactory.GeneratePoint(width1, -height);

            Segment leftTop     = new Segment(origin, top);
            Segment rightTop    = new Segment(top, right);
            Segment rightBottom = new Segment(right, bottom);
            Segment leftBottom  = new Segment(bottom, origin);

            return(new Kite(leftTop, rightBottom, rightTop, leftBottom));
        }
示例#11
0
        public static Rhombus ConstructDefaultRhombus()
        {
            int sideLength = Figure.DefaultSideLength();
            int baseAngle  = Figure.DefaultFirstQuadrantNonRightAngle();

            Point  topLeft = Figure.GetPointByLengthAndAngleInStandardPosition(sideLength, baseAngle);
            double offsetX = topLeft.X;
            double offsetY = topLeft.Y;

            topLeft = PointFactory.GeneratePoint(topLeft.X, topLeft.Y);
            Point topRight    = PointFactory.GeneratePoint(offsetX + sideLength, offsetY);
            Point bottomRight = PointFactory.GeneratePoint(sideLength, 0);

            Segment left   = new Segment(origin, topLeft);
            Segment top    = new Segment(topLeft, topRight);
            Segment right  = new Segment(topRight, bottomRight);
            Segment bottom = new Segment(bottomRight, origin);

            return(new Rhombus(left, right, top, bottom));
        }
示例#12
0
        public static Quadrilateral ConstructDefaultRectangle()
        {
            int length = Figure.DefaultSideLength();
            int width  = Figure.DefaultSideLength();

            // Ensure we don't have a square.
            while (width == length)
            {
                length = Figure.DefaultSideLength();
                width  = Figure.DefaultSideLength();
            }

            Point topLeft     = PointFactory.GeneratePoint(0, width);
            Point topRight    = PointFactory.GeneratePoint(length, width);
            Point bottomRight = PointFactory.GeneratePoint(length, 0);

            Segment left   = new Segment(origin, topLeft);
            Segment top    = new Segment(topLeft, topRight);
            Segment right  = new Segment(topRight, bottomRight);
            Segment bottom = new Segment(bottomRight, origin);

            return(new Rectangle(left, right, top, bottom));
        }
        //
        //          C
        //         /)
        //        /  )
        //       / )
        //      / )
        //   A /)_________ B
        //
        // Tangent(Circle(O), Segment(AB)), Intersection(Segment(AC), Segment(AB)) -> 2 * Angle(CAB) = Arc(C, B)
        //
        public static List <EdgeAggregator> InstantiateTheorem(Intersection inter, Tangent tangent, GroundedClause original)
        {
            List <EdgeAggregator> newGrounded = new List <EdgeAggregator>();

            CircleSegmentIntersection tan = tangent.intersection as CircleSegmentIntersection;

            //
            // Does this tangent apply to this intersection?
            //
            if (!inter.intersect.StructurallyEquals(tangent.intersection.intersect))
            {
                return(newGrounded);
            }

            Segment secant     = null;
            Segment tanSegment = null;

            if (tan.HasSegment(inter.lhs))
            {
                secant     = inter.rhs;
                tanSegment = inter.lhs;
            }
            else if (tan.HasSegment(inter.rhs))
            {
                secant     = inter.lhs;
                tanSegment = inter.rhs;
            }
            else
            {
                return(newGrounded);
            }

            //
            // Acquire the angle and intercepted arc.
            //
            Segment chord = tan.theCircle.GetChord(secant);

            if (chord == null)
            {
                return(newGrounded);
            }
            //Segment chord = tan.theCircle.ContainsChord(secant);

            // Arc
            // We want the MINOR ARC only!
            if (tan.theCircle.DefinesDiameter(chord))
            {
                Arc   theArc = null;
                Point midpt  = PointFactory.GeneratePoint(tan.theCircle.Midpoint(chord.Point1, chord.Point2));
                Point opp    = PointFactory.GeneratePoint(tan.theCircle.OppositePoint(midpt));

                Point tanPoint = tanSegment.OtherPoint(inter.intersect);

                if (tanPoint != null)
                {
                    // Angle; the smaller angle is always the chosen angle
                    Angle theAngle = new Angle(chord.OtherPoint(inter.intersect), inter.intersect, tanPoint);

                    theArc = new Semicircle(tan.theCircle, chord.Point1, chord.Point2, midpt, chord);
                    newGrounded.Add(CreateClause(inter, original, theAngle, theArc));

                    theArc = new Semicircle(tan.theCircle, chord.Point1, chord.Point2, opp, chord);
                    newGrounded.Add(CreateClause(inter, original, theAngle, theArc));
                }
                else
                {
                    // Angle; the smaller angle is always the chosen angle
                    Angle theAngle = new Angle(chord.OtherPoint(inter.intersect), inter.intersect, tanSegment.Point1);

                    theArc = new Semicircle(tan.theCircle, chord.Point1, chord.Point2, midpt, chord);
                    newGrounded.Add(CreateClause(inter, original, theAngle, theArc));

                    theArc = new Semicircle(tan.theCircle, chord.Point1, chord.Point2, opp, chord);
                    newGrounded.Add(CreateClause(inter, original, theAngle, theArc));

                    // Angle; the smaller angle is always the chosen angle
                    theAngle = new Angle(chord.OtherPoint(inter.intersect), inter.intersect, tanSegment.Point2);

                    theArc = new Semicircle(tan.theCircle, chord.Point1, chord.Point2, midpt, chord);
                    newGrounded.Add(CreateClause(inter, original, theAngle, theArc));

                    theArc = new Semicircle(tan.theCircle, chord.Point1, chord.Point2, opp, chord);
                    newGrounded.Add(CreateClause(inter, original, theAngle, theArc));
                }
            }
            else
            {
                Arc theArc = new MinorArc(tan.theCircle, chord.Point1, chord.Point2);

                // Angle; the smaller angle is always the chosen angle
                Point endPnt   = (inter.intersect.StructurallyEquals(tanSegment.Point1)) ? tanSegment.Point2 : tanSegment.Point1;
                Angle theAngle = new Angle(chord.OtherPoint(inter.intersect), inter.intersect, endPnt);

                if (theAngle.measure > 90)
                {
                    //If the angle endpoint was already set to Point2, or if the intersect equals Point2, then the smaller angle does not exist
                    //In this case, should we create a major arc or return nothing?
                    if (endPnt.StructurallyEquals(tanSegment.Point2) || inter.intersect.StructurallyEquals(tanSegment.Point2))
                    {
                        return(newGrounded);
                    }
                    theAngle = new Angle(chord.OtherPoint(inter.intersect), inter.intersect, tanSegment.Point2);
                }

                Multiplication            product  = new Multiplication(new NumericValue(2), theAngle);
                GeometricAngleArcEquation angArcEq = new GeometricAngleArcEquation(product, theArc);

                // For hypergraph
                List <GroundedClause> antecedent = new List <GroundedClause>();
                antecedent.Add(original);
                antecedent.Add(inter);
                antecedent.Add(theArc);
                antecedent.Add(theAngle);

                newGrounded.Add(new EdgeAggregator(antecedent, angArcEq, annotation));
            }



            return(newGrounded);
        }