/// <summary>
        /// Figure out what possible triangle combinations are before showing the window.
        /// </summary>
        protected override void OnShow()
        {
            options = new Dictionary <Triangle, List <Triangle> >();

            //Get a list of all congruent segment givens
            List <GroundedClause> ctris = new List <GroundedClause>();

            foreach (GroundedClause gc in currentGivens)
            {
                GeometricCongruentTriangles ctri = gc as GeometricCongruentTriangles;
                if (ctri != null)
                {
                    ctris.Add(ctri);
                }
            }

            //Pick a first triangle...
            foreach (Triangle t1 in parser.backendParser.implied.polygons[GeometryTutorLib.ConcreteAST.Polygon.TRIANGLE_INDEX])
            {
                List <Triangle> possible = new List <Triangle>();

                //... and see what other triangles are viable second options.
                foreach (Triangle t2 in parser.backendParser.implied.polygons[GeometryTutorLib.ConcreteAST.Polygon.TRIANGLE_INDEX])
                {
                    if (isCongruent(t1, t2))
                    {
                        GeometricCongruentTriangles ctri = new GeometricCongruentTriangles(t1, t2);

                        if (!t1.StructurallyEquals(t2) && !StructurallyContains(ctris, ctri))
                        {
                            possible.Add(t2);
                        }
                    }
                }

                //If we found a possible list of combinations, add it to the dictionary
                if (possible.Count > 0)
                {
                    options.Add(t1, possible);
                }
            }

            //Set the options of the segment1 combo box
            triangle1.ItemsSource = null; //Graphical refresh
            triangle1.ItemsSource = options.Keys;
        }
Example #2
0
        //
        // Implements transitivity with equations
        // Congruent(Triangle(A, B, C), Triangle(D, E, F)), Congruent(Triangle(L, M, N), Triangle(D, E, F)) -> Congruent(Triangle(A, B, C), Triangle(L, M, N))
        //
        // This includes CongruentSegments and CongruentAngles
        //
        // Generation of new equations is restricted to the following rules; let G be Geometric and A algebriac
        //     G + G -> A
        //     G + A -> A
        //     A + A -X> A  <- Not allowed
        //
        public static List <EdgeAggregator> Instantiate(GroundedClause clause)
        {
            annotation.active = EngineUIBridge.JustificationSwitch.TRANSITIVE_CONGRUENT_TRIANGLES;

            List <EdgeAggregator> newGrounded = new List <EdgeAggregator>();

            if (clause is GeometricCongruentTriangles)
            {
                GeometricCongruentTriangles newGCTS = clause as GeometricCongruentTriangles;

                if (newGCTS.IsReflexive())
                {
                    return(newGrounded);
                }

                foreach (GeometricCongruentTriangles oldGCTS in candidateGeoCongruentTriangles)
                {
                    newGrounded.AddRange(InstantiateTransitive(oldGCTS, newGCTS));
                }

                foreach (AlgebraicCongruentTriangles oldACTS in candidateAlgCongruentTriangles)
                {
                    newGrounded.AddRange(InstantiateTransitive(oldACTS, newGCTS));
                }

                candidateGeoCongruentTriangles.Add(newGCTS);
            }
            else if (clause is AlgebraicCongruentTriangles)
            {
                AlgebraicCongruentTriangles newACTS = clause as AlgebraicCongruentTriangles;

                if (newACTS.IsReflexive())
                {
                    return(newGrounded);
                }

                foreach (GeometricCongruentTriangles oldGCTS in candidateGeoCongruentTriangles)
                {
                    newGrounded.AddRange(InstantiateTransitive(oldGCTS, newACTS));
                }

                candidateAlgCongruentTriangles.Add(newACTS);
            }

            return(newGrounded);
        }
Example #3
0
        //
        // Acquires all of the applicable congruent segments; then checks HL
        //
        private static List <EdgeAggregator> CollectAndCheckHL(RightTriangle rt1, RightTriangle rt2,
                                                               CongruentSegments css1, CongruentSegments css2,
                                                               GroundedClause original1, GroundedClause original2)
        {
            List <EdgeAggregator> newGrounded = new List <EdgeAggregator>();

            // The Congruence pairs must relate the two triangles
            if (!css1.LinksTriangles(rt1, rt2) || !css2.LinksTriangles(rt1, rt2))
            {
                return(newGrounded);
            }

            // One of the congruence pairs must relate the hypotenuses
            Segment hypotenuse1 = rt1.OtherSide(rt1.rightAngle);
            Segment hypotenuse2 = rt2.OtherSide(rt2.rightAngle);

            // Determine the specific congruence pair that relates the hypotenuses
            CongruentSegments hypotenuseCongruence    = null;
            CongruentSegments nonHypotenuseCongruence = null;

            if (css1.HasSegment(hypotenuse1) && css1.HasSegment(hypotenuse2))
            {
                hypotenuseCongruence    = css1;
                nonHypotenuseCongruence = css2;
            }
            else if (css2.HasSegment(hypotenuse1) && css2.HasSegment(hypotenuse2))
            {
                hypotenuseCongruence    = css2;
                nonHypotenuseCongruence = css1;
            }
            else
            {
                return(newGrounded);
            }

            // Sanity check that the non hypotenuse congruence pair does not contain hypotenuse
            if (nonHypotenuseCongruence.HasSegment(hypotenuse1) || nonHypotenuseCongruence.HasSegment(hypotenuse2))
            {
                return(newGrounded);
            }

            //
            // We now have a hypotenuse leg situation; acquire the point-to-point congruence mapping
            //
            List <Point> triangleOne = new List <Point>();
            List <Point> triangleTwo = new List <Point>();

            // Right angle vertices correspond
            triangleOne.Add(rt1.rightAngle.GetVertex());
            triangleTwo.Add(rt2.rightAngle.GetVertex());

            Point nonRightVertexRt1 = rt1.GetSegment(nonHypotenuseCongruence).SharedVertex(hypotenuse1);
            Point nonRightVertexRt2 = rt2.GetSegment(nonHypotenuseCongruence).SharedVertex(hypotenuse2);

            triangleOne.Add(nonRightVertexRt1);
            triangleTwo.Add(nonRightVertexRt2);

            triangleOne.Add(hypotenuse1.OtherPoint(nonRightVertexRt1));
            triangleTwo.Add(hypotenuse2.OtherPoint(nonRightVertexRt2));

            //
            // Construct the new deduced relationships
            //
            GeometricCongruentTriangles ccts = new GeometricCongruentTriangles(new Triangle(triangleOne),
                                                                               new Triangle(triangleTwo));

            // Hypergraph
            List <GroundedClause> antecedent = new List <GroundedClause>();

            antecedent.Add(original1);
            antecedent.Add(original2);
            antecedent.Add(css1);
            antecedent.Add(css2);

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

            // Add all the corresponding parts as new congruent clauses
            newGrounded.AddRange(CongruentTriangles.GenerateCPCTC(ccts, triangleOne, triangleTwo));

            return(newGrounded);
        }
Example #4
0
        //
        // Checks for SAS given the 5 values
        //
        private static List <EdgeAggregator> InstantiateSAS(Triangle tri1, Triangle tri2, CongruentSegments css1, CongruentSegments css2, CongruentAngles cas)
        {
            List <EdgeAggregator> newGrounded = new List <EdgeAggregator>();

            //
            // All congruence pairs must minimally relate the triangles
            //
            if (!css1.LinksTriangles(tri1, tri2))
            {
                return(newGrounded);
            }
            if (!css2.LinksTriangles(tri1, tri2))
            {
                return(newGrounded);
            }
            if (!cas.LinksTriangles(tri1, tri2))
            {
                return(newGrounded);
            }

            // Is this angle an 'extension' of the actual triangle angle? If so, acquire the normalized version of
            // the angle, using only the triangle vertices to represent the angle
            Angle angleTri1 = tri1.NormalizeAngle(tri1.AngleBelongs(cas));
            Angle angleTri2 = tri2.NormalizeAngle(tri2.AngleBelongs(cas));

            Segment seg1Tri1 = tri1.GetSegment(css1);
            Segment seg1Tri2 = tri2.GetSegment(css1);

            Segment seg2Tri1 = tri1.GetSegment(css2);
            Segment seg2Tri2 = tri2.GetSegment(css2);

            if (!angleTri1.IsIncludedAngle(seg1Tri1, seg2Tri1) || !angleTri2.IsIncludedAngle(seg1Tri2, seg2Tri2))
            {
                return(newGrounded);
            }

            //
            // Construct the corrsesponding points between the triangles
            //
            List <Point> triangleOne = new List <Point>();
            List <Point> triangleTwo = new List <Point>();

            triangleOne.Add(angleTri1.GetVertex());
            triangleTwo.Add(angleTri2.GetVertex());

            triangleOne.Add(seg1Tri1.OtherPoint(angleTri1.GetVertex()));
            triangleTwo.Add(seg1Tri2.OtherPoint(angleTri2.GetVertex()));

            triangleOne.Add(seg2Tri1.OtherPoint(angleTri1.GetVertex()));
            triangleTwo.Add(seg2Tri2.OtherPoint(angleTri2.GetVertex()));

            //
            // Construct the new clauses: congruent triangles and CPCTC
            //
            GeometricCongruentTriangles gcts = new GeometricCongruentTriangles(new Triangle(triangleOne), new Triangle(triangleTwo));

            // Hypergraph
            List <GroundedClause> antecedent = new List <GroundedClause>();

            antecedent.Add(tri1);
            antecedent.Add(tri2);
            antecedent.Add(css1);
            antecedent.Add(css2);
            antecedent.Add(cas);

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

            // Add all the corresponding parts as new congruent clauses
            newGrounded.AddRange(CongruentTriangles.GenerateCPCTC(gcts, triangleOne, triangleTwo));

            return(newGrounded);
        }
Example #5
0
        //
        // Checks for SSS given the 5 values
        //
        private static List <EdgeAggregator> InstantiateSSS(Triangle tri1, Triangle tri2, CongruentSegments css1, CongruentSegments css2, CongruentSegments css3)
        {
            List <EdgeAggregator> newGrounded = new List <EdgeAggregator>();

            //
            // All congruence pairs must minimally relate the triangles
            //
            if (!css1.LinksTriangles(tri1, tri2))
            {
                return(newGrounded);
            }
            if (!css2.LinksTriangles(tri1, tri2))
            {
                return(newGrounded);
            }
            if (!css3.LinksTriangles(tri1, tri2))
            {
                return(newGrounded);
            }

            Segment seg1Tri1 = tri1.GetSegment(css1);
            Segment seg1Tri2 = tri2.GetSegment(css1);

            Segment seg2Tri1 = tri1.GetSegment(css2);
            Segment seg2Tri2 = tri2.GetSegment(css2);

            Segment seg3Tri1 = tri1.GetSegment(css3);
            Segment seg3Tri2 = tri2.GetSegment(css3);

            //
            // The vertices of both triangles must all be distinct and cover the triangle completely.
            //
            Point vertex1Tri1 = seg1Tri1.SharedVertex(seg2Tri1);
            Point vertex2Tri1 = seg2Tri1.SharedVertex(seg3Tri1);
            Point vertex3Tri1 = seg1Tri1.SharedVertex(seg3Tri1);

            if (vertex1Tri1 == null || vertex2Tri1 == null || vertex3Tri1 == null)
            {
                return(newGrounded);
            }
            if (vertex1Tri1.StructurallyEquals(vertex2Tri1) ||
                vertex1Tri1.StructurallyEquals(vertex3Tri1) ||
                vertex2Tri1.StructurallyEquals(vertex3Tri1))
            {
                return(newGrounded);
            }

            Point vertex1Tri2 = seg1Tri2.SharedVertex(seg2Tri2);
            Point vertex2Tri2 = seg2Tri2.SharedVertex(seg3Tri2);
            Point vertex3Tri2 = seg1Tri2.SharedVertex(seg3Tri2);

            if (vertex1Tri2 == null || vertex2Tri2 == null || vertex3Tri2 == null)
            {
                return(newGrounded);
            }
            if (vertex1Tri2.StructurallyEquals(vertex2Tri2) ||
                vertex1Tri2.StructurallyEquals(vertex3Tri2) ||
                vertex2Tri2.StructurallyEquals(vertex3Tri2))
            {
                return(newGrounded);
            }

            //
            // Construct the corresponding points between the triangles
            //
            List <Point> triangleOne = new List <Point>();
            List <Point> triangleTwo = new List <Point>();

            triangleOne.Add(vertex1Tri1);
            triangleTwo.Add(vertex1Tri2);

            triangleOne.Add(vertex2Tri1);
            triangleTwo.Add(vertex2Tri2);

            triangleOne.Add(vertex3Tri1);
            triangleTwo.Add(vertex3Tri2);

            //
            // Construct the new clauses: congruent triangles and CPCTC
            //
            GeometricCongruentTriangles gcts = new GeometricCongruentTriangles(new Triangle(triangleOne), new Triangle(triangleTwo));

            // Hypergraph
            List <GroundedClause> antecedent = new List <GroundedClause>();

            antecedent.Add(tri1);
            antecedent.Add(tri2);
            antecedent.Add(css1);
            antecedent.Add(css2);
            antecedent.Add(css3);

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

            // Add all the corresponding parts as new congruent clauses
            newGrounded.AddRange(CongruentTriangles.GenerateCPCTC(gcts, triangleOne, triangleTwo));

            return(newGrounded);
        }