Exemplo n.º 1
0
        protected bool HasSamePoints(Quadrilateral quad)
        {
            foreach (Point p in quad.points)
            {
                if (!this.points.Contains(p))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        private static Polygon ActuallyConstructThePolygonObject(List <Segment> orderedSides)
        {
            //
            // Check for lines that are actually collinear (and can be compressed into a single segment).
            //
            bool change = true;

            while (change)
            {
                change = false;
                for (int s = 0; s < orderedSides.Count; s++)
                {
                    Segment first  = orderedSides[s];
                    Segment second = orderedSides[(s + 1) % orderedSides.Count];
                    Point   shared = first.SharedVertex(second);

                    // We know these lines share an endpoint and that they are collinear.
                    if (first.IsCollinearWith(second))
                    {
                        Segment newSegment = new Segment(first.OtherPoint(shared), second.OtherPoint(shared));

                        // Replace the two original lines with the new line.
                        orderedSides.Insert(s, newSegment);
                        orderedSides.Remove(first);
                        orderedSides.Remove(second);
                        change = true;
                    }
                }
            }

            KeyValuePair <List <Point>, List <Angle> > pair = MakePointsAngle(orderedSides);

            // If the polygon is concave, make that object.
            if (IsConcavePolygon(pair.Key))
            {
                return(new ConcavePolygon(orderedSides, pair.Key, pair.Value));
            }

            // Otherwise, make the other polygons
            switch (orderedSides.Count)
            {
            case 3:
                return(new Triangle(orderedSides));

            case 4:
                return(Quadrilateral.GenerateQuadrilateral(orderedSides));

            default:
                return(new Polygon(orderedSides, pair.Key, pair.Value));
            }

            //return null;
        }
Exemplo n.º 3
0
        public static Quadrilateral GetFigureQuadrilateral(Quadrilateral q)
        {
            // Search for exact segment first
            foreach (Quadrilateral quad in figureQuadrilaterals)
            {
                if (quad.StructurallyEquals(q))
                {
                    return(quad);
                }
            }

            return(null);
        }
Exemplo n.º 4
0
        public Limitation(bool onoff, bool complete)
            : base(onoff, complete)
        {
            Point a = new Point("A", 0, 0); points.Add(a);
            Point b = new Point("B", 11, 0); points.Add(b);
            Point c = new Point("C", 0, 5); points.Add(c);
            Point d = new Point("D", 11, 5); points.Add(d);

            Point e = new Point("E", 5, 5); points.Add(e);
            Point f = new Point("F", 4, 0); points.Add(f);
            Point g = new Point("G", 8, 5); points.Add(g);

            Segment ac = new Segment(a, c); segments.Add(ac);
            Segment bd = new Segment(b, d); segments.Add(bd);
            Segment ae = new Segment(a, e); segments.Add(ae);
            Segment ef = new Segment(e, f); segments.Add(ef);
            Segment fg = new Segment(f, g); segments.Add(fg);
            Segment bg = new Segment(b, g); segments.Add(bg);

            List<Point> pts = new List<Point>();
            pts.Add(c);
            pts.Add(e);
            pts.Add(g);
            pts.Add(d);
            collinear.Add(new Collinear(pts));

            pts = new List<Point>();
            pts.Add(a);
            pts.Add(f);
            pts.Add(b);
            collinear.Add(new Collinear(pts));

            parser = new GeometryTutorLib.TutorParser.HardCodedParserMain(points, collinear, segments, circles, onoff);

            Quadrilateral quad = new Quadrilateral(ac, bd, (Segment)parser.Get(new Segment(c, d)), (Segment)parser.Get(new Segment(a, b)));
            given.Add(new Strengthened(quad, new Rectangle(quad)));

            known.AddSegmentLength(ac, 5);
            known.AddSegmentLength((Segment)parser.Get(new Segment(a, b)), 11);

            List<Figure> tris = new List<Figure>();
            tris.Add(new Triangle(a, e, f));
            tris.Add(new Triangle(f, g, b));
            goalRegions = parser.implied.GetAtomicRegionsNotByFigures(tris);

            SetSolutionArea(27.5);

            problemName = "Limiting Problem We Cannot Calculate";
            GeometryTutorLib.EngineUIBridge.HardCodedProblemsToUI.AddProblem(problemName, points, circles, segments);
        }
Exemplo n.º 5
0
        public override bool Equals(Object obj)
        {
            Quadrilateral thatQuad = obj as Quadrilateral;

            if (thatQuad == null)
            {
                return(false);
            }

            if (!thatQuad.IsStrictQuadrilateral())
            {
                return(false);
            }

            return(this.HasSamePoints(thatQuad));
        }
Exemplo n.º 6
0
        public Page10Prob18(bool onoff, bool complete)
            : base(onoff, complete)
        {
            Point a = new Point("A", 0, 0); points.Add(a);
            Point b = new Point("B", 0, 7); points.Add(b);
            Point c = new Point("C", 7, 7); points.Add(c);
            Point d = new Point("D", 7, 0); points.Add(d);

            Point o = new Point("O", 0, 3.5); points.Add(o);
            Point p = new Point("P", 3.5, 7); points.Add(p);

            Segment cd = new Segment(c, d); segments.Add(cd);
            Segment da = new Segment(d, a); segments.Add(da);

            List<Point> pts = new List<Point>();
            pts.Add(b);
            pts.Add(o);
            pts.Add(a);
            collinear.Add(new Collinear(pts));

            pts = new List<Point>();
            pts.Add(b);
            pts.Add(p);
            pts.Add(c);
            collinear.Add(new Collinear(pts));

            circles.Add(new Circle(o, 3.5));
            circles.Add(new Circle(p, 3.5));

            parser = new TutorParser.HardCodedParserMain(points, collinear, segments, circles, onoff);

            Quadrilateral quad = new Quadrilateral((Segment)parser.Get(new Segment(a, b)), cd,
                                                   (Segment)parser.Get(new Segment(b, c)), da);
            given.Add(new Strengthened(quad, new Square(quad)));

            known.AddSegmentLength(cd, 7);

            goalRegions = parser.implied.GetAllAtomicRegions();

            SetSolutionArea(49 + (12.25 * System.Math.PI));

            problemName = "Glencoe Page 10 Problem 18";
            GeometryTutorLib.EngineUIBridge.HardCodedProblemsToUI.AddProblem(problemName, points, circles, segments);
        }
Exemplo n.º 7
0
        //
        // Can this Quadrilateral be strengthened to any of the specific quadrilaterals (parallelogram, kite, square, etc)?
        //
        public static List <Strengthened> CanBeStrengthened(Quadrilateral thatQuad)
        {
            List <Strengthened> strengthened = new List <Strengthened>();

            if (thatQuad.VerifyParallelogram())
            {
                strengthened.Add(new Strengthened(thatQuad, new Parallelogram(thatQuad)));
            }

            if (thatQuad.VerifyRectangle())
            {
                strengthened.Add(new Strengthened(thatQuad, new Rectangle(thatQuad)));
            }

            if (thatQuad.VerifySquare())
            {
                strengthened.Add(new Strengthened(thatQuad, new Square(thatQuad)));
            }

            if (thatQuad.VerifyRhombus())
            {
                strengthened.Add(new Strengthened(thatQuad, new Rhombus(thatQuad)));
            }

            if (thatQuad.VerifyKite())
            {
                strengthened.Add(new Strengthened(thatQuad, new Kite(thatQuad)));
            }

            if (thatQuad.VerifyTrapezoid())
            {
                Trapezoid newTrap = new Trapezoid(thatQuad);
                strengthened.Add(new Strengthened(thatQuad, newTrap));

                if (thatQuad.VerifyIsoscelesTrapezoid())
                {
                    strengthened.Add(new Strengthened(newTrap, new IsoscelesTrapezoid(thatQuad)));
                }
            }

            return(strengthened);
        }
Exemplo n.º 8
0
        public Page9Prob33(bool onoff, bool complete)
            : base(onoff, complete)
        {
            Point a = new Point("A", 0, 0); points.Add(a);
            Point b = new Point("B", 0, 2.5); points.Add(b);
            Point c = new Point("C", 0, 5); points.Add(c);
            Point d = new Point("D", 5, 5); points.Add(d);
            Point e = new Point("E", 5, 0); points.Add(e);

            Segment cd = new Segment(c, d); segments.Add(cd);
            Segment de = new Segment(d, e); segments.Add(de);
            Segment ea = new Segment(e, a); segments.Add(ea);

            List<Point> pts = new List<Point>();
            pts.Add(a);
            pts.Add(b);
            pts.Add(c);
            collinear.Add(new Collinear(pts));

            circles.Add(new Circle(b, 2.5));

            parser = new TutorParser.HardCodedParserMain(points, collinear, segments, circles, onoff);

            Quadrilateral quad = new Quadrilateral((Segment)parser.Get(new Segment(a, c)), de, cd, ea);
            given.Add(new Strengthened(quad, new Square(quad)));

            known.AddSegmentLength(cd, 5);

            List<Point> wanted = new List<Point>();
            wanted.Add(new Point("", 4, 4));
            goalRegions = parser.implied.GetAtomicRegionsByPoints(wanted);

            SetSolutionArea(25 - (2.5 * 2.5 * System.Math.PI / 2.0));

            problemName = "Glencoe Page 9 Problem 33";
            GeometryTutorLib.EngineUIBridge.HardCodedProblemsToUI.AddProblem(problemName, points, circles, segments);
        }
Exemplo n.º 9
0
        public new static List <FigSynthProblem> SubtractShape(Figure outerShape, List <Connection> conns, List <Point> points)
        {
            // Possible quadrilaterals.
            List <Quadrilateral> quads = null;

            if (outerShape is ConcavePolygon)
            {
                quads = Quadrilateral.GetQuadrilateralsFromPoints(outerShape as ConcavePolygon, points);
            }
            else
            {
                quads = Quadrilateral.GetQuadrilateralsFromPoints(points);
            }

            List <FigSynthProblem> composed = new List <FigSynthProblem>();

            foreach (Quadrilateral quad in quads)
            {
                // Select only rhombi that don't match the outer shape.
                if (quad.VerifyRhombus() && !quad.HasSamePoints(outerShape as Polygon))
                {
                    Rhombus rhombus = new Rhombus(quad);

                    SubtractionSynth subSynth = new SubtractionSynth(outerShape, rhombus);

                    try
                    {
                        subSynth.SetOpenRegions(FigSynthProblem.AcquireOpenAtomicRegions(conns, rhombus.points, rhombus));
                        composed.Add(subSynth);
                    }
                    catch (Exception) { }
                }
            }

            return(FigSynthProblem.RemoveSymmetric(composed));
        }
Exemplo n.º 10
0
        private static List<EdgeAggregator> InstantiateToRhombus(Quadrilateral quad, CongruentSegments cs1, CongruentSegments cs2, CongruentSegments cs3)
        {
            List<EdgeAggregator> newGrounded = new List<EdgeAggregator>();

            //
            // The 3 congruent segments pairs must relate; one pair must link the two others.
            // Determine the link segments as well as the opposite sides.
            //
            CongruentSegments link = null;
            CongruentSegments opp1 = null;
            CongruentSegments opp2 = null;
            if (cs1.SharedSegment(cs2) != null && cs1.SharedSegment(cs3) != null)
            {
                link = cs1;
                opp1 = cs2;
                opp2 = cs3;
            }
            else if (cs2.SharedSegment(cs1) != null && cs2.SharedSegment(cs3) != null)
            {
                link = cs2;
                opp1 = cs1;
                opp2 = cs3;
            }
            else if (cs3.SharedSegment(cs1) != null && cs3.SharedSegment(cs2) != null)
            {
                link = cs3;
                opp1 = cs1;
                opp2 = cs2;
            }
            else return newGrounded;

            // Are the pairs on the opposite side of this quadrilateral?
            if (!quad.HasOppositeCongruentSides(opp1)) return newGrounded;
            if (!quad.HasOppositeCongruentSides(opp2)) return newGrounded;

            //
            // Create the new Rhombus object
            //
            Strengthened newRhombus = new Strengthened(quad, new Rhombus(quad));

            // For hypergraph
            List<GroundedClause> antecedent = new List<GroundedClause>();
            antecedent.Add(quad);
            antecedent.Add(cs1);
            antecedent.Add(cs2);
            antecedent.Add(cs3);

            newGrounded.Add(new EdgeAggregator(antecedent, newRhombus, annotation));

            return newGrounded;
        }
Exemplo n.º 11
0
 public Parallelogram(Quadrilateral quad) : this(quad.left, quad.right, quad.top, quad.bottom)
 {
 }
Exemplo n.º 12
0
 public IsoscelesTrapezoid(Quadrilateral quad)
     : this(quad.left, quad.right, quad.top, quad.bottom)
 {
 }
Exemplo n.º 13
0
        //
        // Are the parallel sides subsegments of sides of the quadrilateral?
        // If so, instantiate.
        //
        private static List<EdgeAggregator> InstantiateToTrapezoidSubsegments(Quadrilateral quad, Parallel parallel)
        {
            List<EdgeAggregator> newGrounded = new List<EdgeAggregator>();

            // Does this parallel set apply to this quadrilateral?
            if (!quad.HasOppositeParallelSubsegmentSides(parallel)) return newGrounded;

            //
            // The other set of sides should NOT be parallel (that's a parallelogram)
            //
            List<Segment> otherSides = quad.GetOtherSubsegmentSides(parallel);

            if (otherSides.Count != 2)
            {
                throw new ArgumentException("Expected TWO sides returned from a quadrilateral / parallel relationship: "
                                            + quad + " " + parallel + " returned " + otherSides.Count);
            }

            if (otherSides[0].IsParallelWith(otherSides[1])) return newGrounded;

            return MakeTrapezoid(quad, parallel);
        }
Exemplo n.º 14
0
        protected bool HasSamePoints(Quadrilateral quad)
        {
            foreach (Point p in quad.points)
            {
                if (!this.points.Contains(p)) return false;
            }

            return true;
        }
Exemplo n.º 15
0
        private static List<EdgeAggregator> MakeTrapezoid(Quadrilateral quad, Parallel parallel)
        {
            List<EdgeAggregator> newGrounded = new List<EdgeAggregator>();

            //
            // Create the new Trapezoid object
            //
            Strengthened newTrapezoid = new Strengthened(quad, new Trapezoid(quad));

            // For hypergraph
            List<GroundedClause> antecedent = new List<GroundedClause>();
            antecedent.Add(quad);
            antecedent.Add(parallel);

            newGrounded.Add(new EdgeAggregator(antecedent, newTrapezoid, annotation));

            return newGrounded;
        }
Exemplo n.º 16
0
        public static Quadrilateral GetFigureQuadrilateral(Quadrilateral q)
        {
            // Search for exact segment first
            foreach (Quadrilateral quad in figureQuadrilaterals)
            {
                if (quad.StructurallyEquals(q)) return quad;
            }

            return null;
        }
Exemplo n.º 17
0
        private static List<EdgeAggregator> InstantiateToParallelogram(Quadrilateral quad, Parallel parallel1, Parallel parallel2)
        {
            List<EdgeAggregator> newGrounded = new List<EdgeAggregator>();

            // Does this paralle set apply to this triangle?
            if (!quad.HasOppositeParallelSides(parallel1)) return newGrounded;
            if (!quad.HasOppositeParallelSides(parallel2)) return newGrounded;

            //
            // Create the new Parallelogram object
            //
            Strengthened newParallelogram = new Strengthened(quad, new Parallelogram(quad));

            // For hypergraph
            List<GroundedClause> antecedent = new List<GroundedClause>();
            antecedent.Add(quad);
            antecedent.Add(parallel1);
            antecedent.Add(parallel2);

            newGrounded.Add(new EdgeAggregator(antecedent, newParallelogram, annotation));

            return newGrounded;
        }
        private static List<EdgeAggregator> InstantiateToTheorem(Quadrilateral quad, CongruentSegments cs, Parallel parallel)
        {
            List<EdgeAggregator> newGrounded = new List<EdgeAggregator>();

            // Are the pairs on the opposite side of this quadrilateral?
            if (!quad.HasOppositeCongruentSides(cs)) return newGrounded;
            if (!quad.HasOppositeParallelSides(parallel)) return newGrounded;

            // Do the congruent segments coincide with these parallel segments?
            if (!parallel.segment1.HasSubSegment(cs.cs1) && !parallel.segment2.HasSubSegment(cs.cs1)) return newGrounded;
            if (!parallel.segment1.HasSubSegment(cs.cs2) && !parallel.segment2.HasSubSegment(cs.cs2)) return newGrounded;

            //
            // Create the new Rhombus object
            //
            Strengthened newParallelogram = new Strengthened(quad, new Parallelogram(quad));

            // For hypergraph
            List<GroundedClause> antecedent = new List<GroundedClause>();
            antecedent.Add(quad);
            antecedent.Add(cs);
            antecedent.Add(parallel);

            newGrounded.Add(new EdgeAggregator(antecedent, newParallelogram, annotation));

            return newGrounded;
        }
Exemplo n.º 19
0
        //
        // Can this Quadrilateral be strengthened to any of the specific quadrilaterals (parallelogram, kite, square, etc)?
        //
        public static List<Strengthened> CanBeStrengthened(Quadrilateral thatQuad)
        {
            List<Strengthened> strengthened = new List<Strengthened>();

            if (thatQuad.VerifyParallelogram())
            {
                strengthened.Add(new Strengthened(thatQuad, new Parallelogram(thatQuad)));
            }

            if (thatQuad.VerifyRectangle())
            {
                strengthened.Add(new Strengthened(thatQuad, new Rectangle(thatQuad)));
            }

            if (thatQuad.VerifySquare())
            {
                strengthened.Add(new Strengthened(thatQuad, new Square(thatQuad)));
            }

            if (thatQuad.VerifyRhombus())
            {
                strengthened.Add(new Strengthened(thatQuad, new Rhombus(thatQuad)));
            }

            if (thatQuad.VerifyKite())
            {
                strengthened.Add(new Strengthened(thatQuad, new Kite(thatQuad)));
            }

            if (thatQuad.VerifyTrapezoid())
            {
                Trapezoid newTrap = new Trapezoid(thatQuad);
                strengthened.Add(new Strengthened(thatQuad, newTrap));

                if (thatQuad.VerifyIsoscelesTrapezoid())
                {
                    strengthened.Add(new Strengthened(newTrap, new IsoscelesTrapezoid(thatQuad)));
                }
            }

            return strengthened;
        }
Exemplo n.º 20
0
        private static List<EdgeAggregator> InstantiateToKite(Quadrilateral quad, CongruentSegments cs1, CongruentSegments cs2)
        {
            List<EdgeAggregator> newGrounded = new List<EdgeAggregator>();

            // The congruences should not share a side.
            if (cs1.SharedSegment(cs2) != null) return newGrounded;

            // The congruent pairs should not also be congruent to each other
            if (cs1.cs1.CoordinateCongruent(cs2.cs1)) return newGrounded;

            // Does both set of congruent segments apply to the quadrilateral?
            if (!quad.HasAdjacentCongruentSides(cs1)) return newGrounded;
            if (!quad.HasAdjacentCongruentSides(cs2)) return newGrounded;

            //
            // Create the new Kite object
            //
            Strengthened newKite = new Strengthened(quad, new Kite(quad));

            // For hypergraph
            List<GroundedClause> antecedent = new List<GroundedClause>();
            antecedent.Add(quad);
            antecedent.Add(cs1);
            antecedent.Add(cs2);

            newGrounded.Add(new EdgeAggregator(antecedent, newKite, annotation));

            return newGrounded;
        }
Exemplo n.º 21
0
 public Rhombus(Quadrilateral quad)
     : this(quad.left, quad.right, quad.top, quad.bottom,
         quad.TopLeftDiagonalIsValid(), quad.BottomRightDiagonalIsValid(), quad.diagonalIntersection)
 {
 }
        //     A _________________ B
        //      /                /
        //     /     \/         /
        //    /      /\        /
        // D /________________/ C
        //
        // Quadrilateral(A, B, C, D), SegmentBisector(Segment(A, C), Segment(B, D)),
        //                            SegmentBisector(Segment(B, D), Segment(A, C)) -> Parallelogram(A, B, C, D)
        //
        private static List<EdgeAggregator> InstantiateToTheorem(Quadrilateral quad, SegmentBisector sb1, SegmentBisector sb2, GroundedClause originalSB1, GroundedClause originalSB2)
        {
            List<EdgeAggregator> newGrounded = new List<EdgeAggregator>();

            // The two segment bisectors must intersect at the same point
            if (!sb1.bisected.intersect.StructurallyEquals(sb2.bisected.intersect)) return newGrounded;

            // The bisectors must be part of the other segment bisector.
            if (!sb1.bisected.HasSegment(sb2.bisector)) return newGrounded;
            if (!sb2.bisected.HasSegment(sb1.bisector)) return newGrounded;

            // Do these segment bisectors define the diagonals of the quadrilateral?
            if (!sb1.bisector.HasSubSegment(quad.topLeftBottomRightDiagonal) && !sb2.bisector.HasSubSegment(quad.topLeftBottomRightDiagonal)) return newGrounded;
            if (!sb1.bisector.HasSubSegment(quad.bottomLeftTopRightDiagonal) && !sb2.bisector.HasSubSegment(quad.bottomLeftTopRightDiagonal)) return newGrounded;

            // Determine the CongruentSegments opposing sides and output that.
            Strengthened newParallelogram = new Strengthened(quad, new Parallelogram(quad));

            // For hypergraph
            List<GroundedClause> antecedent = new List<GroundedClause>();
            antecedent.Add(quad);
            antecedent.Add(originalSB1);
            antecedent.Add(originalSB2);

            newGrounded.Add(new EdgeAggregator(antecedent, newParallelogram, annotation));

            return newGrounded;
        }
        private static List<EdgeAggregator> InstantiateToTheorem(Quadrilateral quad, CongruentAngles cas1, CongruentAngles cas2)
        {
            List<EdgeAggregator> newGrounded = new List<EdgeAggregator>();

            // Are the pairs on the opposite side of this quadrilateral?
            if (!quad.HasOppositeCongruentAngles(cas1)) return newGrounded;
            if (!quad.HasOppositeCongruentAngles(cas2)) return newGrounded;

            //
            // Create the new Rhombus object
            //
            Strengthened newParallelogram = new Strengthened(quad, new Parallelogram(quad));

            // For hypergraph
            List<GroundedClause> antecedent = new List<GroundedClause>();
            antecedent.Add(quad);
            antecedent.Add(cas1);
            antecedent.Add(cas2);

            newGrounded.Add(new EdgeAggregator(antecedent, newParallelogram, annotation));

            return newGrounded;
        }
Exemplo n.º 24
0
        public static Quadrilateral MakeQuadrilateral(Point a, Point b, Point c, Point d)
        {
            Segment left = new Segment(a, d);
            Segment right = new Segment(b, c);
            Segment top = new Segment(a, b);
            Segment bottom = new Segment(c, d);

            Quadrilateral quad = null;
            try
            {
                quad = new Quadrilateral(left, right, top, bottom);
            }
            catch (Exception)
            {
                left = new Segment(a, d);
                right = new Segment(b, c);
                top = new Segment(a, c);
                bottom = new Segment(b, d);

                quad = new Quadrilateral(left, right, top, bottom);
            }

            return quad;
        }
Exemplo n.º 25
0
 public Parallelogram(Quadrilateral quad)
     : this(quad.left, quad.right, quad.top, quad.bottom)
 {
 }
Exemplo n.º 26
0
 public IsoscelesTrapezoid(Quadrilateral quad) : this(quad.left, quad.right, quad.top, quad.bottom)
 {
 }
Exemplo n.º 27
0
 public Rectangle(Quadrilateral quad) : this(quad.left, quad.right, quad.top, quad.bottom,
                                             quad.TopLeftDiagonalIsValid(), quad.BottomRightDiagonalIsValid(), quad.diagonalIntersection)
 {
 }
Exemplo n.º 28
0
        public override List<GroundedClause> GetGivens()
        {
            Polygon thisPoly = figure as Polygon;
            if (thisPoly == null) return new List<GroundedClause>();

            //
            // Create the simple version of the figure; we already have the strengthened version.
            //
            Polygon simple = null;
            if (thisPoly.points.Count == 3) simple = new Triangle(thisPoly.points);
            if (thisPoly.points.Count == 4) simple = new Quadrilateral(thisPoly.orderedSides[0], thisPoly.orderedSides[2],
                                                                       thisPoly.orderedSides[1], thisPoly.orderedSides[3]);

            return Utilities.MakeList<GroundedClause>(new Strengthened(simple, this.figure));
        }