public static List <GenericInstantiator.EdgeAggregator> CreateProportionEquation(SegmentRatio ratio1, SegmentRatio ratio2) { List <GenericInstantiator.EdgeAggregator> newGrounded = new List <GenericInstantiator.EdgeAggregator>(); // Double-Check that the ratios are, in-fact, known. if (!ratio1.ProportionValueKnown() || !ratio2.ProportionValueKnown()) { return(newGrounded); } // // Create the antecedent clauses // List <GroundedClause> antecedent = new List <GroundedClause>(); antecedent.Add(ratio1); antecedent.Add(ratio2); // Create the consequent proportionality equation. GeometricSegmentRatioEquation gsreq = new GeometricSegmentRatioEquation(ratio1, ratio2); newGrounded.Add(new GenericInstantiator.EdgeAggregator(antecedent, gsreq, propAnnotation)); return(newGrounded); }
public override bool Equals(Object obj) { GeometricSegmentRatioEquation gsr = obj as GeometricSegmentRatioEquation; if (gsr == null) { return(false); } return(base.Equals(gsr)); }
// // // private static List<EdgeAggregator> IfCongruencesApplyToTrianglesGenerate(Triangle ct1, Triangle ct2, CongruentSegments css1, CongruentSegments css2) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); // // The congruent relationships need to link the given triangles // if (!css1.LinksTriangles(ct1, ct2)) return newGrounded; if (!css2.LinksTriangles(ct1, ct2)) return newGrounded; Segment seg1Tri1 = ct1.GetSegment(css1); Segment seg2Tri1 = ct1.GetSegment(css2); Segment seg1Tri2 = ct2.GetSegment(css1); Segment seg2Tri2 = ct2.GetSegment(css2); // Avoid redundant segments, if it arises if (seg1Tri1.StructurallyEquals(seg2Tri1)) return newGrounded; if (seg1Tri2.StructurallyEquals(seg2Tri2)) return newGrounded; // // Proportional Segments (we generate only as needed to avoid bloat in the hypergraph (assuming they are used by both triangles) // We avoid generating proportions if they are truly congruences. // List<GroundedClause> propAntecedent = new List<GroundedClause>(); propAntecedent.Add(css1); propAntecedent.Add(css2); SegmentRatio ratio1 = new SegmentRatio(seg1Tri1, seg1Tri2); SegmentRatio ratio2 = new SegmentRatio(seg2Tri1, seg2Tri2); GeometricSegmentRatioEquation newEq = new GeometricSegmentRatioEquation(ratio1, ratio2); newGrounded.Add(new EdgeAggregator(propAntecedent, newEq, annotation)); //// //// Only generate if ratios are not 1. //// //GeometricSegmentRatio newProp = null; //if (!Utilities.CompareValues(seg1Tri1.Length, seg1Tri2.Length)) //{ // newProp = new GeometricSegmentRatio(seg1Tri1, seg1Tri2); // newGrounded.Add(new EdgeAggregator(propAntecedent, newProp, annotation)); //} //if (!Utilities.CompareValues(seg1Tri1.Length, seg2Tri2.Length)) //{ // newProp = new GeometricSegmentRatio(seg1Tri1, seg2Tri2); // newGrounded.Add(new EdgeAggregator(propAntecedent, newProp, annotation)); //} //if (!Utilities.CompareValues(seg2Tri1.Length, seg1Tri2.Length)) //{ // newProp = new GeometricSegmentRatio(seg2Tri1, seg1Tri2); // newGrounded.Add(new EdgeAggregator(propAntecedent, newProp, annotation)); //} //if (!Utilities.CompareValues(seg2Tri1.Length, seg2Tri2.Length)) //{ // newProp = new GeometricSegmentRatio(seg2Tri1, seg2Tri2); // newGrounded.Add(new EdgeAggregator(propAntecedent, newProp, annotation)); //} return newGrounded; }
private static List<EdgeAggregator> CheckAndGenerateProportionality(Triangle tri, Intersection inter1, Intersection inter2, Parallel parallel) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); // The two intersections should not be at the same vertex if (inter1.intersect.Equals(inter2.intersect)) return newGrounded; // // Do these intersections share a segment? That is, do they share the transversal? // Segment transversal = inter1.AcquireTransversal(inter2); if (transversal == null) return newGrounded; // // Is the transversal a side of the triangle? It should not be. // if (tri.LiesOn(transversal)) return newGrounded; // // Determine if one parallel segment is a side of the triangle (which must occur) // Segment coinciding = tri.DoesParallelCoincideWith(parallel); if (coinciding == null) return newGrounded; // The transversal and common segment must be distinct if (coinciding.IsCollinearWith(transversal)) return newGrounded; // // Determine if the simplified transversal is within the parallel relationship. // Segment parallelTransversal = parallel.OtherSegment(coinciding); Segment simpleParallelTransversal = new Segment(inter1.intersect, inter2.intersect); if (!parallelTransversal.IsCollinearWith(simpleParallelTransversal)) return newGrounded; // A // /\ // / \ // / \ // off1 /------\ off2 // / \ // B /__________\ C // // Both intersections should create a T-shape. // Point off1 = inter1.CreatesTShape(); Point off2 = inter2.CreatesTShape(); if (off1 == null || off2 == null) return newGrounded; // Get the intersection segments which should coincide with the triangle sides KeyValuePair<Segment, Segment> otherSides = tri.OtherSides(coinciding); // The intersections may be outside this triangle if (otherSides.Key == null || otherSides.Value == null) return newGrounded; Segment side1 = inter1.OtherSegment(transversal); Segment side2 = inter2.OtherSegment(transversal); // Get the actual sides of the triangle Segment triangleSide1 = null; Segment triangleSide2 = null; if (side1.IsCollinearWith(otherSides.Key) && side2.IsCollinearWith(otherSides.Value)) { triangleSide1 = otherSides.Key; triangleSide2 = otherSides.Value; } else if (side1.IsCollinearWith(otherSides.Value) && side2.IsCollinearWith(otherSides.Key)) { triangleSide1 = otherSides.Value; triangleSide2 = otherSides.Key; } else return newGrounded; // Verify the opposing parts of the T are on the opposite sides of the triangle if (!triangleSide1.PointLiesOnAndExactlyBetweenEndpoints(off2)) return newGrounded; if (!triangleSide2.PointLiesOnAndExactlyBetweenEndpoints(off1)) return newGrounded; // // Construct the new proprtional relationship and resultant equation // Point sharedVertex = triangleSide1.SharedVertex(triangleSide2); SegmentRatio newProp1 = new SegmentRatio(new Segment(sharedVertex, off2), triangleSide1); SegmentRatio newProp2 = new SegmentRatio(new Segment(sharedVertex, off1), triangleSide2); GeometricSegmentRatioEquation newEq = new GeometricSegmentRatioEquation(newProp1, newProp2); // Construct hyperedge List<GroundedClause> antecedent = new List<GroundedClause>(); antecedent.Add(tri); antecedent.Add(inter1); antecedent.Add(inter2); antecedent.Add(parallel); newGrounded.Add(new EdgeAggregator(antecedent, newEq, annotation)); return newGrounded; }
public static List<GenericInstantiator.EdgeAggregator> CreateProportionEquation(SegmentRatio ratio1, SegmentRatio ratio2) { List<GenericInstantiator.EdgeAggregator> newGrounded = new List<GenericInstantiator.EdgeAggregator>(); // Double-Check that the ratios are, in-fact, known. if (!ratio1.ProportionValueKnown() || !ratio2.ProportionValueKnown()) return newGrounded; // // Create the antecedent clauses // List<GroundedClause> antecedent = new List<GroundedClause>(); antecedent.Add(ratio1); antecedent.Add(ratio2); // Create the consequent proportionality equation. GeometricSegmentRatioEquation gsreq = new GeometricSegmentRatioEquation(ratio1, ratio2); newGrounded.Add(new GenericInstantiator.EdgeAggregator(antecedent, gsreq, propAnnotation)); return newGrounded; }