public static List<GenericInstantiator.EdgeAggregator> GenerateCorrespondingParts(List<KeyValuePair<Point, Point>> pairs, List<GroundedClause> antecedent, Hypergraph.EdgeAnnotation givenAnnotation) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); // If pairs is populated, we have a Similiarity if (!pairs.Any()) return newGrounded; // Create the similarity between the triangles List<Point> triangleOne = new List<Point>(); List<Point> triangleTwo = new List<Point>(); foreach (KeyValuePair<Point, Point> pair in pairs) { triangleOne.Add(pair.Key); triangleTwo.Add(pair.Value); } GeometricSimilarTriangles simTris = new GeometricSimilarTriangles(new Triangle(triangleOne), new Triangle(triangleTwo)); newGrounded.Add(new EdgeAggregator(antecedent, simTris, givenAnnotation)); // Add all the corresponding parts as new Similar clauses newGrounded.AddRange(SimilarTriangles.GenerateComponents(simTris, triangleOne, triangleTwo)); return newGrounded; }
public override bool Equals(Object obj) { GeometricSimilarTriangles gst = obj as GeometricSimilarTriangles; if (gst == null) { return(false); } return(base.Equals(obj)); }
public static List<EdgeAggregator> InstantiateRight(RightTriangle rt, Altitude altitude, GroundedClause original) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); // The altitude must connect the vertex defining the right angle and the opposite side. if (!altitude.segment.HasPoint(rt.rightAngle.GetVertex())) return newGrounded; // The other point of the altitude must lie on the opposite side of the triangle Point altPointOppRightAngle = altitude.segment.OtherPoint(rt.rightAngle.GetVertex()); Segment oppositeSide = rt.GetOppositeSide(rt.rightAngle); if (!Segment.Between(altPointOppRightAngle, oppositeSide.Point1, oppositeSide.Point2)) return newGrounded; // // Find the two smaller right triangles in the candidate list (which should be in the list at this point) // RightTriangle first = null; RightTriangle second = null; foreach (RightTriangle smallerRT in candRightTriangles) { if (smallerRT.IsDefinedBy(rt, altitude)) { if (first == null) { first = smallerRT; } else { second = smallerRT; break; } } } // CTA: We did not check to see points aligned, but these are the original triangles from the figure GeometricSimilarTriangles gsts1 = new GeometricSimilarTriangles(rt, first); GeometricSimilarTriangles gsts2 = new GeometricSimilarTriangles(rt, second); GeometricSimilarTriangles gsts3 = new GeometricSimilarTriangles(first, second); List<GroundedClause> antecedent = new List<GroundedClause>(); antecedent.Add(original); antecedent.Add(altitude); newGrounded.Add(new EdgeAggregator(antecedent, gsts1, annotation)); newGrounded.Add(new EdgeAggregator(antecedent, gsts2, annotation)); newGrounded.Add(new EdgeAggregator(antecedent, gsts3, annotation)); return newGrounded; }
// // 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; }
/// <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> stris = new List<GroundedClause>(); foreach (GroundedClause gc in currentGivens) { GeometricSimilarTriangles stri = gc as GeometricSimilarTriangles; if (stri != null) { stris.Add(stri); } } // 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 (isSimilar(t1, t2)) { GeometricSimilarTriangles stri = new GeometricSimilarTriangles(t1, t2); if (!t1.StructurallyEquals(t2) && !StructurallyContains(stris, stri)) { 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; }