// // Returns the exact transversal between the intersections // public Segment AcquireTransversal(Intersection thatInter) { // The two intersections should not be at the same vertex if (intersect.Equals(thatInter.intersect)) { return(null); } Segment common = CommonSegment(thatInter); if (common == null) { return(null); } // A legitimate transversal must belong to both intersections (is a subsegment of one of the lines) Segment transversal = new Segment(this.intersect, thatInter.intersect); Segment thisTransversal = this.GetCollinearSegment(transversal); Segment thatTransversal = thatInter.GetCollinearSegment(transversal); if (!thisTransversal.HasSubSegment(transversal)) { return(null); } if (!thatTransversal.HasSubSegment(transversal)) { return(null); } return(transversal); }
// // Returns the exact transversal between the intersections // public Segment AcquireTransversal(Intersection thatInter) { // The two intersections should not be at the same vertex if (intersect.Equals(thatInter.intersect)) return null; Segment common = CommonSegment(thatInter); if (common == null) return null; // A legitimate transversal must belong to both intersections (is a subsegment of one of the lines) Segment transversal = new Segment(this.intersect, thatInter.intersect); Segment thisTransversal = this.GetCollinearSegment(transversal); Segment thatTransversal = thatInter.GetCollinearSegment(transversal); if (!thisTransversal.HasSubSegment(transversal)) return null; if (!thatTransversal.HasSubSegment(transversal)) return null; return transversal; }
// leftTop rightTop // | | // offleft ____|_________|_____ offRight // | | // | | // leftBottom rightBottom // private static List<EdgeAggregator> GenerateDualCrossings(Parallel parallel, Intersection crossingInterLeft, Intersection crossingInterRight) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); Segment transversal = crossingInterLeft.AcquireTransversal(crossingInterRight); // // Find offLeft and offRight // Segment crossingLeftParallel = crossingInterLeft.OtherSegment(transversal); Segment crossingRightParallel = crossingInterRight.OtherSegment(transversal); // // Determine which points are on the same side of the transversal. // Segment testingCrossSegment = new Segment(crossingLeftParallel.Point1, crossingRightParallel.Point1); Point intersection = transversal.FindIntersection(testingCrossSegment); Point leftTop = crossingLeftParallel.Point1; Point leftBottom = crossingLeftParallel.Point2; Point rightTop = null; Point rightBottom = null; if (transversal.PointLiesOnAndBetweenEndpoints(intersection)) { rightTop = crossingRightParallel.Point2; rightBottom = crossingRightParallel.Point1; } else { rightTop = crossingRightParallel.Point1; rightBottom = crossingRightParallel.Point2; } // Point that is outside of the parallel lines and transversal Segment leftTransversal = crossingInterLeft.GetCollinearSegment(transversal); Segment rightTransversal = crossingInterRight.GetCollinearSegment(transversal); Point offLeft = Segment.Between(crossingInterLeft.intersect, leftTransversal.Point1, crossingInterRight.intersect) ? leftTransversal.Point1 : leftTransversal.Point2; Point offRight = Segment.Between(crossingInterRight.intersect, crossingInterLeft.intersect, rightTransversal.Point1) ? rightTransversal.Point1 : rightTransversal.Point2; // // Generate the new congruences // List<CongruentAngles> newAngleRelations = new List<CongruentAngles>(); GeometricCongruentAngles gca = new GeometricCongruentAngles(new Angle(leftTop, crossingInterLeft.intersect, crossingInterRight.intersect), new Angle(rightBottom, crossingInterRight.intersect, crossingInterLeft.intersect)); newAngleRelations.Add(gca); gca = new GeometricCongruentAngles(new Angle(rightTop, crossingInterRight.intersect, crossingInterLeft.intersect), new Angle(leftBottom, crossingInterLeft.intersect, crossingInterRight.intersect)); newAngleRelations.Add(gca); return MakeRelations(newAngleRelations, parallel, crossingInterLeft, crossingInterRight); }
// // Take the angle congruence and bisector and create the AngleBisector relation // \ // \ // B ---------V---------A // \ // \ // C // private static List<EdgeAggregator> InstantiateToDef(Point intersectionPoint, Intersection inter, CongruentSegments cs) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); // Does the given point of intersection apply to this actual intersection object if (!intersectionPoint.Equals(inter.intersect)) return newGrounded; // The entire segment AB Segment overallSegment = new Segment(cs.cs1.OtherPoint(intersectionPoint), cs.cs2.OtherPoint(intersectionPoint)); // The segment must align completely with one of the intersection segments Segment interCollinearSegment = inter.GetCollinearSegment(overallSegment); if (interCollinearSegment == null) return newGrounded; // Does this intersection have the entire segment AB if (!inter.HasSegment(overallSegment)) return newGrounded; Segment bisector = inter.OtherSegment(overallSegment); Segment bisectedSegment = inter.GetCollinearSegment(overallSegment); // Check if the bisected segment extends is the exact same segment as the overall segment AB if (!bisectedSegment.StructurallyEquals(overallSegment)) { if (overallSegment.PointLiesOnAndBetweenEndpoints(bisectedSegment.Point1) && overallSegment.PointLiesOnAndBetweenEndpoints(bisectedSegment.Point2)) return newGrounded; } SegmentBisector newSB = new SegmentBisector(inter, bisector); // For hypergraph List<GroundedClause> antecedent = new List<GroundedClause>(); antecedent.Add(inter); antecedent.Add(cs); newGrounded.Add(new EdgeAggregator(antecedent, newSB, annotation)); return newGrounded; }
// Corresponding angles if: // // left _____________ right // | | // | | // off1 off2 // // Inter 1 Inter 2 // private static List<EdgeAggregator> InstantiatePiIntersection(Parallel parallel, Intersection inter1, Point off1, Intersection inter2, Point off2) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); Segment transversal = inter1.AcquireTransversal(inter2); Segment nonParallel1 = inter1.GetCollinearSegment(transversal); Segment nonParallel2 = inter2.GetCollinearSegment(transversal); Point left = Segment.Between(inter1.intersect, nonParallel1.Point1, inter2.intersect) ? nonParallel1.Point1 : nonParallel1.Point2; Point right = Segment.Between(inter2.intersect, inter1.intersect, nonParallel2.Point1) ? nonParallel2.Point1 : nonParallel2.Point2; // // Generate the new congruences // List<CongruentAngles> newAngleRelations = new List<CongruentAngles>(); // CTA: Hack to avoid an exception being thrown during testing. try { GeometricCongruentAngles gca1 = new GeometricCongruentAngles(new Angle(left, inter1.intersect, off1), new Angle(inter1.intersect, inter2.intersect, off2)); newAngleRelations.Add(gca1); GeometricCongruentAngles gca2 = new GeometricCongruentAngles(new Angle(right, inter2.intersect, off2), new Angle(inter2.intersect, inter1.intersect, off1)); newAngleRelations.Add(gca2); } catch (Exception) { return newGrounded; } return MakeRelations(newAngleRelations, parallel, inter1, inter2); }
// // Creates a Topped F-Shape // top // offLeft __________ offEnd <--- Stands on // | // |_____ off <--- Stands on // | // | // bottom // // Returns: <bottom, off> public KeyValuePair <Intersection, Point> CreatesToppedFShape(Intersection thatInter) { KeyValuePair <Intersection, Point> nullPair = new KeyValuePair <Intersection, Point>(null, null); // A valid transversal is required for this shape if (!this.CreatesAValidTransversalWith(thatInter)) { return(nullPair); } // Avoid both standing on an endpoint OR crossing if (this.StandsOnEndpoint() || thatInter.StandsOnEndpoint()) { return(nullPair); } if (this.Crossing() || thatInter.Crossing()) { return(nullPair); } Segment transversal = this.AcquireTransversal(thatInter); Intersection standsOnTop = null; Intersection standsOnBottom = null; // Top has 2 points on the transversal; bottom has 3 Segment nonTransversalThis = this.OtherSegment(transversal); Segment nonTransversalThat = thatInter.OtherSegment(transversal); if (transversal.PointLiesOnAndBetweenEndpoints(nonTransversalThis.Point1) || transversal.PointLiesOnAndBetweenEndpoints(nonTransversalThis.Point2)) { // | // ____| <--- Stands on // | // |_____ off <--- Stands on // | // | if (transversal.PointLiesOnAndBetweenEndpoints(nonTransversalThat.Point1) || transversal.PointLiesOnAndBetweenEndpoints(nonTransversalThat.Point2)) { return(nullPair); } standsOnBottom = this; standsOnTop = thatInter; } else if (transversal.PointLiesOnAndBetweenEndpoints(nonTransversalThat.Point1) || transversal.PointLiesOnAndBetweenEndpoints(nonTransversalThat.Point2)) { standsOnBottom = this; standsOnTop = thatInter; } else { return(nullPair); } // Check that the bottom extends the transversal if (!standsOnBottom.GetCollinearSegment(transversal).HasStrictSubSegment(transversal)) { return(nullPair); } Point off = standsOnBottom.OtherSegment(transversal).OtherPoint(standsOnBottom.intersect); return(new KeyValuePair <Intersection, Point>(standsOnBottom, off)); }