// // Checks for AA given the 4 values // private static List<EdgeAggregator> InstantiateAASimilarity(Triangle tri1, Triangle tri2, CongruentAngles cas1, CongruentAngles cas2) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); // // All congruence pairs must minimally relate the triangles // if (!cas1.LinksTriangles(tri1, tri2)) return newGrounded; if (!cas2.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 angle1Tri1 = tri1.NormalizeAngle(tri1.AngleBelongs(cas1)); Angle angle1Tri2 = tri2.NormalizeAngle(tri2.AngleBelongs(cas1)); Angle angle2Tri1 = tri1.NormalizeAngle(tri1.AngleBelongs(cas2)); Angle angle2Tri2 = tri2.NormalizeAngle(tri2.AngleBelongs(cas2)); // The angles for each triangle must be distinct if (angle1Tri1.Equals(angle2Tri1) || angle1Tri2.Equals(angle2Tri2)) return newGrounded; // // Construct the corrsesponding points between the triangles // List<Point> triangleOne = new List<Point>(); List<Point> triangleTwo = new List<Point>(); triangleOne.Add(angle1Tri1.GetVertex()); triangleTwo.Add(angle1Tri2.GetVertex()); triangleOne.Add(angle2Tri1.GetVertex()); triangleTwo.Add(angle2Tri2.GetVertex()); // We know the segment endpoint mappings above, now acquire the opposite point triangleOne.Add(tri1.OtherPoint(new Segment(angle1Tri1.GetVertex(), angle2Tri1.GetVertex()))); triangleTwo.Add(tri2.OtherPoint(new Segment(angle1Tri2.GetVertex(), angle2Tri2.GetVertex()))); // // Construct the new clauses: similar triangles and resultant components // GeometricSimilarTriangles simTris = new GeometricSimilarTriangles(new Triangle(triangleOne), new Triangle(triangleTwo)); // Hypergraph edge List<GroundedClause> antecedent = new List<GroundedClause>(); antecedent.Add(tri1); antecedent.Add(tri2); antecedent.Add(cas1); antecedent.Add(cas2); newGrounded.Add(new EdgeAggregator(antecedent, simTris, annotation)); // Add all the corresponding parts as new Similar clauses newGrounded.AddRange(SimilarTriangles.GenerateComponents(simTris, triangleOne, triangleTwo)); return newGrounded; }
// // // private static List<EdgeAggregator> CollectAndCheckSAS(Triangle ct1, Triangle ct2, CongruentAngles cas, SegmentRatioEquation sre) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); // Proportions must actually equate //if (!pss1.ProportionallyEquals(pss2)) return newGrounded; //// The smaller and larger segments of the proportionality must be distinct, respectively. //if (!pss1.IsDistinctFrom(pss2)) return newGrounded; // The proportional relationships need to link the given triangles if (!cas.LinksTriangles(ct1, ct2)) return newGrounded; if (!sre.LinksTriangles(ct1, ct2)) return newGrounded; //if (!pss1.LinksTriangles(ct1, ct2)) return newGrounded; //if (!pss2.LinksTriangles(ct1, ct2)) return newGrounded; // The smaller segments must belong to one triangle, same for larger segments. //if (!(ct1.HasSegment(pss1.smallerSegment) && ct1.HasSegment(pss2.smallerSegment) && // ct2.HasSegment(pss1.largerSegment) && ct2.HasSegment(pss2.largerSegment)) && // !(ct2.HasSegment(pss1.smallerSegment) && ct2.HasSegment(pss2.smallerSegment) && // ct1.HasSegment(pss1.largerSegment) && ct1.HasSegment(pss2.largerSegment))) // return newGrounded; KeyValuePair<Segment, Segment> segsTri1 = sre.GetSegments(ct1); KeyValuePair<Segment, Segment> segsTri2 = sre.GetSegments(ct2); //Segment seg1Tri1 = ct1.GetSegment(pss1); //Segment seg2Tri1 = ct1.GetSegment(pss2); //Segment seg1Tri2 = ct2.GetSegment(pss1); //Segment seg2Tri2 = ct2.GetSegment(pss2); // Avoid redundant segments, if they arise if (segsTri1.Key.StructurallyEquals(segsTri1.Value)) return newGrounded; if (segsTri2.Key.StructurallyEquals(segsTri2.Value)) return newGrounded; //if (seg1Tri1.StructurallyEquals(seg2Tri1)) return newGrounded; //if (seg1Tri2.StructurallyEquals(seg2Tri2)) return newGrounded; Angle angleTri1 = ct1.AngleBelongs(cas); Angle angleTri2 = ct2.AngleBelongs(cas); // Check both triangles if this is the included angle; if it is, we have SAS if (!angleTri1.IsIncludedAngle(segsTri1.Key, segsTri1.Value)) return newGrounded; if (!angleTri2.IsIncludedAngle(segsTri2.Key, segsTri2.Value)) return newGrounded; // // Generate Similar Triangles // Point vertex1 = angleTri1.GetVertex(); Point vertex2 = angleTri2.GetVertex(); // Construct a list of pairs to return; this is the correspondence from triangle 1 to triangle 2 List<KeyValuePair<Point, Point>> pairs = new List<KeyValuePair<Point, Point>>(); // The vertices of the angles correspond pairs.Add(new KeyValuePair<Point, Point>(vertex1, vertex2)); // For the segments, look at the congruences and select accordingly pairs.Add(new KeyValuePair<Point, Point>(segsTri1.Key.OtherPoint(vertex1), segsTri2.Key.OtherPoint(vertex2))); pairs.Add(new KeyValuePair<Point, Point>(segsTri1.Value.OtherPoint(vertex1), segsTri2.Value.OtherPoint(vertex2))); List<GroundedClause> simTriAntecedent = new List<GroundedClause>(); simTriAntecedent.Add(ct1); simTriAntecedent.Add(ct2); simTriAntecedent.Add(cas); simTriAntecedent.Add(sre); newGrounded.AddRange(GenerateCorrespondingParts(pairs, simTriAntecedent, annotation)); return newGrounded; }
// // Checks for ASA given the 5 values // private static List<EdgeAggregator> InstantiateAAS(Triangle tri1, Triangle tri2, CongruentAngles cas1, CongruentAngles cas2, CongruentSegments css) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); // // All congruence pairs must minimally relate the triangles // if (!cas1.LinksTriangles(tri1, tri2)) return newGrounded; if (!cas2.LinksTriangles(tri1, tri2)) return newGrounded; if (!css.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 angle1Tri1 = tri1.NormalizeAngle(tri1.AngleBelongs(cas1)); Angle angle1Tri2 = tri2.NormalizeAngle(tri2.AngleBelongs(cas1)); Angle angle2Tri1 = tri1.NormalizeAngle(tri1.AngleBelongs(cas2)); Angle angle2Tri2 = tri2.NormalizeAngle(tri2.AngleBelongs(cas2)); // The angles for each triangle must be distinct if (angle1Tri1.Equals(angle2Tri1) || angle1Tri2.Equals(angle2Tri2)) return newGrounded; Segment segTri1 = tri1.GetSegment(css); Segment segTri2 = tri2.GetSegment(css); // ASA situations if (segTri1.IsIncludedSegment(angle1Tri1, angle2Tri1)) return newGrounded; if (segTri2.IsIncludedSegment(angle1Tri2, angle2Tri2)) return newGrounded; // The segments for each triangle must be corresponding if (segTri1.Equals(tri1.OtherSide(angle1Tri1)) && segTri2.Equals(tri2.OtherSide(angle2Tri2))) return newGrounded; if (segTri1.Equals(tri1.OtherSide(angle2Tri1)) && segTri2.Equals(tri2.OtherSide(angle1Tri2))) return newGrounded; // // Construct the corrsesponding points between the triangles // List<Point> triangleOne = new List<Point>(); List<Point> triangleTwo = new List<Point>(); triangleOne.Add(angle1Tri1.GetVertex()); triangleTwo.Add(angle1Tri2.GetVertex()); triangleOne.Add(angle2Tri1.GetVertex()); triangleTwo.Add(angle2Tri2.GetVertex()); // We know the segment endpoint mappings above, now acquire the opposite point triangleOne.Add(tri1.OtherPoint(angle1Tri1.GetVertex(), angle2Tri1.GetVertex())); triangleTwo.Add(tri2.OtherPoint(angle1Tri2.GetVertex(), angle2Tri2.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(cas1); antecedent.Add(cas2); antecedent.Add(css); 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; }
// // Acquires all of the applicable congruent segments as well as congruent angles. Then checks for SAS // private static List<EdgeAggregator> CheckAndGenerateThirdCongruentPair(Triangle tri1, Triangle tri2, CongruentAngles cas1, CongruentAngles cas2) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); // We have eliminated all reflexive relationships at this point // The congruent relations should not share any angles if (cas1.AngleShared(cas2) != null) return newGrounded; // Both congruent pairs of angles must relate both triangles if (!cas1.LinksTriangles(tri1, tri2)) return newGrounded; if (!cas2.LinksTriangles(tri1, tri2)) return newGrounded; Angle firstAngleTri1 = tri1.AngleBelongs(cas1); Angle secondAngleTri1 = tri1.AngleBelongs(cas2); Angle firstAngleTri2 = tri2.AngleBelongs(cas1); Angle secondAngleTri2 = tri2.AngleBelongs(cas2); Angle thirdAngle1 = tri1.OtherAngle(firstAngleTri1, secondAngleTri1); Angle thirdAngle2 = tri2.OtherAngle(firstAngleTri2, secondAngleTri2); CongruentAngles newCas = new CongruentAngles(thirdAngle1, thirdAngle2); // Hypergraph List<GroundedClause> antecedent = new List<GroundedClause>(); antecedent.Add(tri1); antecedent.Add(tri2); antecedent.Add(cas1); antecedent.Add(cas2); newGrounded.Add(new EdgeAggregator(antecedent, newCas, annotation)); return newGrounded; }