public override bool Equals(Object c)
        {
            CongruentTriangles cts = c as CongruentTriangles;

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

            // The point must equate in order
            KeyValuePair <Triangle, Triangle> pair1;
            KeyValuePair <Triangle, Triangle> pair2;

            if (ct1.Equals(cts.ct1) && ct2.Equals(cts.ct2))
            {
                pair1 = new KeyValuePair <Triangle, Triangle>(ct1, cts.ct1);
                pair2 = new KeyValuePair <Triangle, Triangle>(ct2, cts.ct2);
            }
            else if (ct1.Equals(cts.ct2) && ct2.Equals(cts.ct1))
            {
                pair1 = new KeyValuePair <Triangle, Triangle>(ct1, cts.ct2);
                pair2 = new KeyValuePair <Triangle, Triangle>(ct2, cts.ct1);
            }
            else
            {
                return(false);
            }

            if (!VerifyMappingOrder(pair1, pair2))
            {
                return(false);
            }

            return(base.Equals(c));
        }
        public static List<EdgeAggregator> InstantiateTransitive(CongruentTriangles cts1, CongruentTriangles cts2)
        {
            List<EdgeAggregator> newGrounded = new List<EdgeAggregator>();

            Dictionary<Point, Point> firstTriangleCorrespondence = cts1.HasTriangle(cts2.ct1);
            Dictionary<Point, Point> secondTriangleCorrespondence = cts1.HasTriangle(cts2.ct2);

            // Same Congruence
            if (firstTriangleCorrespondence != null && secondTriangleCorrespondence != null) return newGrounded;

            // No relationship between congruences
            if (firstTriangleCorrespondence == null && secondTriangleCorrespondence == null) return newGrounded;

            // Acquiring the triangle that links the congruences
            Triangle linkTriangle = firstTriangleCorrespondence != null ? cts2.ct1 : cts2.ct2;
            List<Point> linkPts = linkTriangle.points;

            Dictionary<Point, Point> otherCorrGCTSpts = cts1.OtherTriangle(linkTriangle);
            Dictionary<Point, Point> otherCorrCTSpts = cts2.OtherTriangle(linkTriangle);

            // Link the other triangles together in a new congruence
            Dictionary<Point, Point> newCorrespondence = new Dictionary<Point,Point>();
            foreach (Point linkPt in linkPts)
            {
                Point otherGpt;
                if (!otherCorrGCTSpts.TryGetValue(linkPt, out otherGpt)) throw new ArgumentException("Something strange happened in Triangle correspondence.");

                Point otherCpt;
                if (!otherCorrCTSpts.TryGetValue(linkPt, out otherCpt)) throw new ArgumentException("Something strange happened in Triangle correspondence.");

                newCorrespondence.Add(otherGpt, otherCpt);
            }

            List<Point> triOne = new List<Point>();
            List<Point> triTwo = new List<Point>();
            foreach (KeyValuePair<Point, Point> pair in newCorrespondence)
            {
                triOne.Add(pair.Key);
                triTwo.Add(pair.Value);
            }

            //
            // Create the new congruence
            //
            AlgebraicCongruentTriangles acts = new AlgebraicCongruentTriangles(new Triangle(triOne), new Triangle(triTwo));

            List<GroundedClause> antecedent = new List<GroundedClause>();
            antecedent.Add(cts1);
            antecedent.Add(cts2);

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

            return newGrounded;
        }
        //
        // Generate all corresponding conngruent components.
        // Ensure vertices correpsond appropriately.
        //
        public static List <GenericInstantiator.EdgeAggregator> Instantiate(GroundedClause clause)
        {
            List <GenericInstantiator.EdgeAggregator> newGrounded = new List <GenericInstantiator.EdgeAggregator>();

            CongruentTriangles conTris = clause as CongruentTriangles;

            if (conTris == null)
            {
                return(newGrounded);
            }

            List <Point> orderedTriOnePts = new List <Point>();
            List <Point> orderedTriTwoPts = new List <Point>();

            if (!conTris.VerifyCongruentTriangles(out orderedTriOnePts, out orderedTriTwoPts))
            {
                return(newGrounded);
            }

            return(GenerateCPCTC(conTris, orderedTriOnePts, orderedTriTwoPts));
        }
Beispiel #4
0
        //
        // Create the three resultant angles from each triangle to create the congruency of angles
        //
        public static List <GenericInstantiator.EdgeAggregator> GenerateCongruentAngles(SimilarTriangles simTris,
                                                                                        List <Point> orderedTriOnePts,
                                                                                        List <Point> orderedTriTwoPts)
        {
            angleAnnotation.active = EngineUIBridge.JustificationSwitch.SIMILARITY;

            List <GroundedClause> congAngles = CongruentTriangles.GenerateCPCTCAngles(orderedTriOnePts, orderedTriTwoPts);

            //
            // Construct the new deduced edges: congruent angles.
            //
            List <GenericInstantiator.EdgeAggregator> newGrounded = new List <GenericInstantiator.EdgeAggregator>();
            List <GroundedClause> antecedent = Utilities.MakeList <GroundedClause>(simTris);

            foreach (GeometricCongruentAngles ccas in congAngles)
            {
                newGrounded.Add(new GenericInstantiator.EdgeAggregator(antecedent, ccas, angleAnnotation));
            }

            return(newGrounded);
        }
        public static List<GenericInstantiator.EdgeAggregator> GenerateCPCTC(CongruentTriangles ccts,
                                                         List<Point> orderedTriOnePts,
                                                         List<Point> orderedTriTwoPts)
        {
            List<GenericInstantiator.EdgeAggregator> newGrounded = new List<GenericInstantiator.EdgeAggregator>();

            List<GroundedClause> antecedent = Utilities.MakeList<GroundedClause>(ccts);
            List<GroundedClause> congAngles = GenerateCPCTCAngles(orderedTriOnePts, orderedTriTwoPts);

            foreach (GeometricCongruentAngles ccas in congAngles)
            {
                newGrounded.Add(new GenericInstantiator.EdgeAggregator(antecedent, ccas, cpctcAnnotation));
            }

            List<GroundedClause> congSegments = GenerateCPCTCSegments(orderedTriOnePts, orderedTriTwoPts);
            foreach (GroundedClause ccss in congSegments)
            {
                newGrounded.Add(new GenericInstantiator.EdgeAggregator(antecedent, ccss, cpctcAnnotation));
            }

            return newGrounded;
        }
        public static List <GenericInstantiator.EdgeAggregator> GenerateCPCTC(CongruentTriangles ccts,
                                                                              List <Point> orderedTriOnePts,
                                                                              List <Point> orderedTriTwoPts)
        {
            List <GenericInstantiator.EdgeAggregator> newGrounded = new List <GenericInstantiator.EdgeAggregator>();

            List <GroundedClause> antecedent = Utilities.MakeList <GroundedClause>(ccts);
            List <GroundedClause> congAngles = GenerateCPCTCAngles(orderedTriOnePts, orderedTriTwoPts);

            foreach (GeometricCongruentAngles ccas in congAngles)
            {
                newGrounded.Add(new GenericInstantiator.EdgeAggregator(antecedent, ccas, cpctcAnnotation));
            }

            List <GroundedClause> congSegments = GenerateCPCTCSegments(orderedTriOnePts, orderedTriTwoPts);

            foreach (GroundedClause ccss in congSegments)
            {
                newGrounded.Add(new GenericInstantiator.EdgeAggregator(antecedent, ccss, cpctcAnnotation));
            }

            return(newGrounded);
        }