// // Creates a Leaner-Shape (a bench you can sit on) // // top // |______ tipStands // | // tipEndpt ______| // // Returns <tipEndpoint, tipStands> public KeyValuePair <Point, Point> CreatesLeanerShape(Intersection thatInter) { KeyValuePair <Point, Point> nullPair = new KeyValuePair <Point, Point>(null, null); // A valid transversal is required for this shape if (!this.CreatesAValidTransversalWith(thatInter)) { return(nullPair); } if (this.StandsOnEndpoint() && thatInter.StandsOnEndpoint()) { return(nullPair); } // // Determine which is the stands and which is the endpoint // Intersection endpointInter = null; Intersection standsInter = null; if (this.StandsOnEndpoint() && thatInter.StandsOn()) { endpointInter = this; standsInter = thatInter; } else if (thatInter.StandsOnEndpoint() && this.StandsOn()) { endpointInter = thatInter; standsInter = this; } else { return(nullPair); } // // Acquire Points // Point tipStands = standsInter.CreatesTShape(); Segment transversal = this.AcquireTransversal(thatInter); Segment parallelEndpoint = endpointInter.OtherSegment(transversal); Point tipEndpoint = parallelEndpoint.OtherPoint(endpointInter.intersect); // Determine sides Segment crossingTester = new Segment(tipEndpoint, tipStands); Point intersection = transversal.FindIntersection(crossingTester); // F-Shape if (!transversal.PointLiesOnAndBetweenEndpoints(intersection)) { return(nullPair); } // Desired Leaner shape return(new KeyValuePair <Point, Point>(tipEndpoint, tipStands)); }
// // o // eoooooooo offStands // e //offEndpoint eeeeeee // o // Returns: <offEndpoint, offStands> public KeyValuePair <Point, Point> CreatesSimpleSShape(Intersection thatInter) { KeyValuePair <Point, Point> nullPair = new KeyValuePair <Point, Point>(null, null); // A valid transversal is required for this shape if (!this.CreatesAValidTransversalWith(thatInter)) { return(nullPair); } // Restrict to desired combination if (this.StandsOnEndpoint() && thatInter.StandsOnEndpoint()) { return(nullPair); } // // Determine which is the stands and which is the endpoint // Intersection endpointInter = null; Intersection standsInter = null; if (this.StandsOnEndpoint() && thatInter.StandsOn()) { endpointInter = this; standsInter = thatInter; } else if (thatInter.StandsOnEndpoint() && this.StandsOn()) { endpointInter = this; standsInter = thatInter; } else { return(nullPair); } // Determine S shape Point offStands = standsInter.CreatesTShape(); Segment transversal = this.AcquireTransversal(thatInter); Segment parallelEndpoint = endpointInter.OtherSegment(transversal); Point offEndpoint = parallelEndpoint.OtherPoint(endpointInter.intersect); Segment crossingTester = new Segment(offStands, offEndpoint); Point intersection = transversal.FindIntersection(crossingTester); return(transversal.PointLiesOnAndBetweenEndpoints(intersection) ? new KeyValuePair <Point, Point>(offEndpoint, offStands) : nullPair); }
// Corresponding angles if: // offRightEnd // standsOn (o) o e // o e standsOnEndpoint (e) // offLeftEnd eeeoeeeeeeee // o // o // // Returns <offLeftEnd, offRightEnd> // public KeyValuePair <Point, Point> CreatesSimpleTShape(Intersection thatInter) { KeyValuePair <Point, Point> nullPair = new KeyValuePair <Point, Point>(null, null); // A valid transversal is required for this shape if (!this.CreatesAValidTransversalWith(thatInter)) { return(nullPair); } if (this.StandsOnEndpoint() && thatInter.StandsOnEndpoint()) { return(nullPair); } // // Determine which is the crossing intersection and which stands on the endpoints // Intersection endpointInter = null; Intersection standsInter = null; if (this.StandsOnEndpoint() && thatInter.StandsOn()) { endpointInter = this; standsInter = thatInter; } else if (thatInter.Crossing() && this.StandsOnEndpoint()) { endpointInter = thatInter; standsInter = this; } else { return(nullPair); } // // Determine if the endpoint intersection extends beyond the stands parallel line // Segment transversal = this.AcquireTransversal(thatInter); Segment transversalEndpoint = endpointInter.GetCollinearSegment(transversal); if (transversal.PointLiesOnAndBetweenEndpoints(transversalEndpoint.Point1) && transversal.PointLiesOnAndBetweenEndpoints(transversalEndpoint.Point2)) { return(nullPair); } // // Acquire the returning points // Segment parallelEndpoint = endpointInter.OtherSegment(transversal); Point offLeftEnd = transversalEndpoint.OtherPoint(endpointInter.intersect); Point offRightEnd = parallelEndpoint.OtherPoint(endpointInter.intersect); return(new KeyValuePair <Point, Point>(offLeftEnd, offRightEnd)); }
// // Creates a flying shape using a CROSSING intersection // offCross // | // ______|______ <--crossingInter // | // _____|_____ <--standsInter // // Returns <offCross> // public Point CreatesFlyingShapeWithCrossing(Intersection thatInter) { // A valid transversal is required for this shape if (!this.CreatesAValidTransversalWith(thatInter)) { return(null); } // We hould not have have endpoint standing as that is handled elsewhere if (this.StandsOnEndpoint() || thatInter.StandsOnEndpoint()) { return(null); } // // Determine which is the crossing intersection and which stands on the endpoints // Intersection crossingInter = null; Intersection standsInter = null; if (this.Crossing() && thatInter.StandsOn()) { crossingInter = this; standsInter = thatInter; } else if (thatInter.Crossing() && this.StandsOn()) { crossingInter = thatInter; standsInter = this; } else { return(null); } Segment transversal = this.AcquireTransversal(thatInter); // Stands on intersection must have BOTH points not on the transversal line // | // ______|______ // | // |_____ // | // | if (!transversal.PointLiesOn(standsInter.CreatesTShape())) { return(null); } // Success, we have the desired shape // Acquire return point: offCross Segment transversalCrossing = crossingInter.GetCollinearSegment(transversal); return(Segment.Between(crossingInter.intersect, transversalCrossing.Point1, standsInter.intersect) ? transversalCrossing.Point1 : transversalCrossing.Point2); }
// // Creates a basic S-Shape with standsOnEndpoints // // offThis ______ // | // offThat ______| // // Return <offThis, offThat> public KeyValuePair <Point, Point> CreatesBasicCShape(Intersection thatInter) { KeyValuePair <Point, Point> nullPair = new KeyValuePair <Point, Point>(null, null); // A valid transversal is required for this shape if (!this.CreatesAValidTransversalWith(thatInter)) { return(nullPair); } if (!this.StandsOnEndpoint()) { return(nullPair); } if (!thatInter.StandsOnEndpoint()) { return(nullPair); } // // Determine offThis and offThat // Segment transversal = this.AcquireTransversal(thatInter); Segment parallelThis = this.OtherSegment(transversal); Segment parallelThat = thatInter.OtherSegment(transversal); Point offThis = transversal.PointLiesOnAndBetweenEndpoints(parallelThis.Point1) ? parallelThis.Point2 : parallelThis.Point1; Point offThat = transversal.PointLiesOnAndBetweenEndpoints(parallelThat.Point1) ? parallelThat.Point2 : parallelThat.Point1; // Avoid S-shape scenario Segment crossingTester = new Segment(offThis, offThat); Point intersection = transversal.FindIntersection(crossingTester); // We may have parallel crossingTester and transversal; that's ok if (crossingTester.IsParallelWith(transversal)) { return(new KeyValuePair <Point, Point>(offThis, offThat)); } // S-shape if (transversal.PointLiesOnAndBetweenEndpoints(intersection)) { return(nullPair); } // C-Shape return(new KeyValuePair <Point, Point>(offThis, offThat)); }
// // Creates a shape like a crazy person flying // // | | // |_____|___ off // | | // | | // // Similar to H-shape with an extended point // Returns the 'larger' intersection that contains the point: off public KeyValuePair <Intersection, Point> CreatesFlyingShape(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); } // Both intersections must be standing on (and not endpoints) if (!this.StandsOn() || !thatInter.StandsOn()) { return(nullPair); } if (this.StandsOnEndpoint() || thatInter.StandsOnEndpoint()) { return(nullPair); } Point thisTipOfT = this.CreatesTShape(); Point thatTipOfT = thatInter.CreatesTShape(); Segment transversal = this.AcquireTransversal(thatInter); // We have an H-Shape if the tips of the intersections are at the endpoints of the transversal if (transversal.PointLiesOnAndBetweenEndpoints(thisTipOfT) && transversal.PointLiesOnAndBetweenEndpoints(thatTipOfT)) { return(nullPair); } Intersection retInter = null; Point off = null; if (transversal.PointLiesOnAndBetweenEndpoints(thisTipOfT)) { retInter = thatInter; off = thatTipOfT; } else { retInter = this; off = thisTipOfT; } return(new KeyValuePair <Intersection, Point>(retInter, off)); }
// // Creates a shape like an extended t // offCross offCross // | | // _____|____ ______|______ // | | // |_____ offStands offStands _____| // // Returns <offStands, offCross> public KeyValuePair <Point, Point> CreatesCrossedTShape(Intersection thatInter) { KeyValuePair <Point, Point> nullPair = new KeyValuePair <Point, Point>(null, null); // A valid transversal is required for this shape if (!this.CreatesAValidTransversalWith(thatInter)) { return(nullPair); } // // Determine which is the crossing intersection and which stands on the endpoints // Intersection crossingInter = null; Intersection standsInter = null; if (this.Crossing() && thatInter.StandsOnEndpoint()) { crossingInter = this; standsInter = thatInter; } else if (thatInter.Crossing() && this.StandsOnEndpoint()) { crossingInter = thatInter; standsInter = this; } else { return(nullPair); } // // Acquire the returning points // Segment transversal = this.AcquireTransversal(thatInter); Segment parallelStands = standsInter.OtherSegment(transversal); Point offStands = transversal.PointLiesOn(parallelStands.Point1) ? parallelStands.Point2 : parallelStands.Point1; Segment transversalCross = crossingInter.GetCollinearSegment(transversal); Point offCross = Segment.Between(crossingInter.intersect, transversalCross.Point1, standsInter.intersect) ? transversalCross.Point1 : transversalCross.Point2; return(new KeyValuePair <Point, Point>(offStands, offCross)); }
// // Creates a shape like an extended t // offCross offCross // | | // _____|____ ______|______ // | | // |_____ offStands offStands _____| // // Returns <offStands, offCross> public KeyValuePair<Point, Point> CreatesCrossedTShape(Intersection thatInter) { KeyValuePair<Point, Point> nullPair = new KeyValuePair<Point, Point>(null, null); // A valid transversal is required for this shape if (!this.CreatesAValidTransversalWith(thatInter)) return nullPair; // // Determine which is the crossing intersection and which stands on the endpoints // Intersection crossingInter = null; Intersection standsInter = null; if (this.Crossing() && thatInter.StandsOnEndpoint()) { crossingInter = this; standsInter = thatInter; } else if (thatInter.Crossing() && this.StandsOnEndpoint()) { crossingInter = thatInter; standsInter = this; } else return nullPair; // // Acquire the returning points // Segment transversal = this.AcquireTransversal(thatInter); Segment parallelStands = standsInter.OtherSegment(transversal); Point offStands = transversal.PointLiesOn(parallelStands.Point1) ? parallelStands.Point2 : parallelStands.Point1; Segment transversalCross = crossingInter.GetCollinearSegment(transversal); Point offCross = Segment.Between(crossingInter.intersect, transversalCross.Point1, standsInter.intersect) ? transversalCross.Point1 : transversalCross.Point2; return new KeyValuePair<Point, Point>(offStands, offCross); }
// // Creates a shape like a crazy person flying // // | | // |_____|___ off // | | // | | // // Similar to H-shape with an extended point // Returns the 'larger' intersection that contains the point: off public KeyValuePair<Intersection, Point> CreatesFlyingShape(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; // Both intersections must be standing on (and not endpoints) if (!this.StandsOn() || !thatInter.StandsOn()) return nullPair; if (this.StandsOnEndpoint() || thatInter.StandsOnEndpoint()) return nullPair; Point thisTipOfT = this.CreatesTShape(); Point thatTipOfT = thatInter.CreatesTShape(); Segment transversal = this.AcquireTransversal(thatInter); // We have an H-Shape if the tips of the intersections are at the endpoints of the transversal if (transversal.PointLiesOnAndBetweenEndpoints(thisTipOfT) && transversal.PointLiesOnAndBetweenEndpoints(thatTipOfT)) return nullPair; Intersection retInter = null; Point off = null; if (transversal.PointLiesOnAndBetweenEndpoints(thisTipOfT)) { retInter = thatInter; off = thatTipOfT; } else { retInter = this; off = thisTipOfT; } return new KeyValuePair<Intersection, Point>(retInter, off); }
// // Creates a basic S-Shape with standsOnEndpoints // // ______ offThat // | // offThis ______| // // Return <offThis, offThat> public KeyValuePair<Point, Point> CreatesBasicSShape(Intersection thatInter) { KeyValuePair<Point, Point> nullPair = new KeyValuePair<Point, Point>(null, null); // A valid transversal is required for this shape if (!this.CreatesAValidTransversalWith(thatInter)) return nullPair; if (!this.StandsOnEndpoint()) return nullPair; if (!thatInter.StandsOnEndpoint()) return nullPair; // // Determine offThis and offThat // Segment transversal = this.AcquireTransversal(thatInter); Segment parallelThis = this.OtherSegment(transversal); Segment parallelThat = thatInter.OtherSegment(transversal); Point offThis = transversal.PointLiesOnAndBetweenEndpoints(parallelThis.Point1) ? parallelThis.Point2 : parallelThis.Point1; Point offThat = transversal.PointLiesOnAndBetweenEndpoints(parallelThat.Point1) ? parallelThat.Point2 : parallelThat.Point1; // Avoid C-like scenario Segment crossingTester = new Segment(offThis, offThat); Point intersection = transversal.FindIntersection(crossingTester); // C-shape if (!transversal.PointLiesOnAndBetweenEndpoints(intersection)) return nullPair; // S-Shape return new KeyValuePair<Point, Point>(offThis, offThat); }
// // Creates a Chair // // | | | // |_____|____ leftInter |_________ tipOfT // | | | // | | | // off tipOfT // // bottomInter // // <leftInter, bottomInter> // Returns the legs of the chair in specific ordering: <off, bottomTip> public KeyValuePair<Point, Point> CreatesChairShape(Intersection thatInter) { KeyValuePair<Point, Point> nullPair = new KeyValuePair<Point, Point>(null, null); // A valid transversal is required for this shape if (!this.CreatesAValidTransversalWith(thatInter)) return nullPair; // Both intersections must be standing on (and not endpoints) if (!this.StandsOn() || !thatInter.StandsOn()) return nullPair; if (this.StandsOnEndpoint() || thatInter.StandsOnEndpoint()) return nullPair; Point thisTipOfT = this.CreatesTShape(); Point thatTipOfT = thatInter.CreatesTShape(); Segment transversal = this.AcquireTransversal(thatInter); Intersection leftInter = null; Intersection bottomInter = null; // Avoid: // | // |______ // | | // | | // this is leftInter Point bottomTip = null; if (transversal.PointLiesOn(thisTipOfT)) { if (transversal.PointLiesOnAndBetweenEndpoints(thisTipOfT)) return nullPair; leftInter = this; bottomInter = thatInter; bottomTip = thisTipOfT; } // thatInter is leftInter else if (transversal.PointLiesOn(thatTipOfT)) { if (transversal.PointLiesOnAndBetweenEndpoints(thatTipOfT)) return nullPair; leftInter = thatInter; bottomInter = this; bottomTip = thisTipOfT; } // Otherwise, this indicates a PI-shaped scenario else return nullPair; // // Returns the bottom of the legs of the chair // Segment parallelLeft = leftInter.OtherSegment(transversal); Segment crossingTester = new Segment(parallelLeft.Point1, bottomTip); Point intersection = transversal.FindIntersection(crossingTester); Point off = transversal.PointLiesOnAndBetweenEndpoints(intersection) ? parallelLeft.Point2 : parallelLeft.Point1; return new KeyValuePair<Point, Point>(off, bottomTip); }
// // Creates a shape like an extended t // offCross offCross // | | // oppSide _____|____ sameSide sameSide ______|______ oppSide // | | // |_____ offStands offStands _____| // // Returns <offStands, offCross> private static List<EdgeAggregator> GenerateCrossedT(Parallel parallel, Intersection inter1, Intersection inter2, Point offStands, Point offCross) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); // // Determine which is the crossing intersection and which stands on the endpoints // Intersection crossingInter = null; Intersection standsInter = null; if (inter1.Crossing() && inter2.StandsOnEndpoint()) { crossingInter = inter1; standsInter = inter2; } else if (inter2.Crossing() && inter1.StandsOnEndpoint()) { crossingInter = inter2; standsInter = inter1; } // Determine the side of the crossing needed for the angle Segment transversal = inter1.AcquireTransversal(inter2); Segment parallelStands = standsInter.OtherSegment(transversal); Segment parallelCrossing = crossingInter.OtherSegment(transversal); Segment crossingTester = new Segment(offStands, parallelCrossing.Point1); Point intersection = transversal.FindIntersection(crossingTester); Point sameSide = transversal.PointLiesOnAndBetweenEndpoints(intersection) ? parallelCrossing.Point2 : parallelCrossing.Point1; Point oppSide = parallelCrossing.OtherPoint(sameSide); // // Generate the new congruence // List<CongruentAngles> newAngleRelations = new List<CongruentAngles>(); GeometricCongruentAngles gca = new GeometricCongruentAngles(new Angle(offStands, standsInter.intersect, crossingInter.intersect), new Angle(oppSide, crossingInter.intersect, standsInter.intersect)); newAngleRelations.Add(gca); return MakeRelations(newAngleRelations, parallel, inter1, inter2); }
// // Creates an F-Shape // top // _____ offEnd <--- Stands on Endpt // | // |_____ offStands <--- Stands on // | // | // bottom // Order of non-collinear points is order of intersections: <this, that> public KeyValuePair <Point, Point> CreatesFShape(Intersection thatInter) { KeyValuePair <Point, Point> nullPair = new KeyValuePair <Point, Point>(null, null); // A valid transversal is required for this shape if (!this.CreatesAValidTransversalWith(thatInter)) { return(nullPair); } // Avoid both standing on an endpoint if (this.StandsOnEndpoint() && thatInter.StandsOnEndpoint()) { return(nullPair); } Intersection endpt = null; Intersection standsOn = null; if (this.StandsOnEndpoint() && thatInter.StandsOn()) { endpt = this; standsOn = thatInter; } else if (thatInter.StandsOnEndpoint() && this.StandsOn()) { endpt = thatInter; standsOn = this; } else { return(nullPair); } Segment transversal = this.AcquireTransversal(thatInter); Segment transversalStands = standsOn.GetCollinearSegment(transversal); // // Determine Top and bottom to avoid PI shape // Point top = null; Point bottom = null; if (Segment.Between(standsOn.intersect, transversalStands.Point1, endpt.intersect)) { bottom = transversalStands.Point1; top = transversalStands.Point2; } else { bottom = transversalStands.Point2; top = transversalStands.Point1; } // Avoid: ____ Although this shouldn't happen since both intersections do not stand on endpoints // ____| if (transversal.HasPoint(top) && transversal.HasPoint(bottom)) { return(nullPair); } // Also avoid Simple PI-Shape // if (!transversal.HasPoint(top) && !transversal.HasPoint(bottom)) { return(nullPair); } // Find the two points that make the points of the F Segment parallelEndPt = endpt.OtherSegment(transversal); Segment parallelStands = standsOn.OtherSegment(transversal); Point offEnd = transversal.PointLiesOn(parallelEndPt.Point1) ? parallelEndPt.Point2 : parallelEndPt.Point1; Point offStands = transversal.PointLiesOn(parallelStands.Point1) ? parallelStands.Point2 : parallelStands.Point1; // Check this is not a crazy F // _____ // | // ____| // | // | Point intersection = transversal.FindIntersection(new Segment(offEnd, offStands)); if (transversal.PointLiesOnAndBetweenEndpoints(intersection)) { return(nullPair); } // Return in the order of 'off' points: <this, that> return(this.Equals(endpt) ? new KeyValuePair <Point, Point>(offEnd, offStands) : new KeyValuePair <Point, Point>(offStands, offEnd)); }
// // o // eoooooooo offStands // e //offEndpoint eeeeeee // o // Returns: <offEndpoint, offStands> public KeyValuePair<Point, Point> CreatesSimpleSShape(Intersection thatInter) { KeyValuePair<Point, Point> nullPair = new KeyValuePair<Point, Point>(null, null); // A valid transversal is required for this shape if (!this.CreatesAValidTransversalWith(thatInter)) return nullPair; // Restrict to desired combination if (this.StandsOnEndpoint() && thatInter.StandsOnEndpoint()) return nullPair; // // Determine which is the stands and which is the endpoint // Intersection endpointInter = null; Intersection standsInter = null; if (this.StandsOnEndpoint() && thatInter.StandsOn()) { endpointInter = this; standsInter = thatInter; } else if (thatInter.StandsOnEndpoint() && this.StandsOn()) { endpointInter = this; standsInter = thatInter; } else return nullPair; // Determine S shape Point offStands = standsInter.CreatesTShape(); Segment transversal = this.AcquireTransversal(thatInter); Segment parallelEndpoint = endpointInter.OtherSegment(transversal); Point offEndpoint = parallelEndpoint.OtherPoint(endpointInter.intersect); Segment crossingTester = new Segment(offStands, offEndpoint); Point intersection = transversal.FindIntersection(crossingTester); return transversal.PointLiesOnAndBetweenEndpoints(intersection) ? new KeyValuePair<Point, Point>(offEndpoint, offStands) : nullPair; }
// // 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); }
// // Creates a Leaner-Shape (a bench you can sit on) // // top // |______ tipStands // | // tipEndpt ______| // // Returns <tipEndpoint, tipStands> public KeyValuePair<Point, Point> CreatesLeanerShape(Intersection thatInter) { KeyValuePair<Point, Point> nullPair = new KeyValuePair<Point, Point>(null, null); // A valid transversal is required for this shape if (!this.CreatesAValidTransversalWith(thatInter)) return nullPair; if (this.StandsOnEndpoint() && thatInter.StandsOnEndpoint()) return nullPair; // // Determine which is the stands and which is the endpoint // Intersection endpointInter = null; Intersection standsInter = null; if (this.StandsOnEndpoint() && thatInter.StandsOn()) { endpointInter = this; standsInter = thatInter; } else if (thatInter.StandsOnEndpoint() && this.StandsOn()) { endpointInter = thatInter; standsInter = this; } else return nullPair; // // Acquire Points // Point tipStands = standsInter.CreatesTShape(); Segment transversal = this.AcquireTransversal(thatInter); Segment parallelEndpoint = endpointInter.OtherSegment(transversal); Point tipEndpoint = parallelEndpoint.OtherPoint(endpointInter.intersect); // Determine sides Segment crossingTester = new Segment(tipEndpoint, tipStands); Point intersection = transversal.FindIntersection(crossingTester); // F-Shape if (!transversal.PointLiesOnAndBetweenEndpoints(intersection)) return nullPair; // Desired Leaner shape return new KeyValuePair<Point, Point>(tipEndpoint, tipStands); }
// // Creates a flying shape using a CROSSING intersection // offCross // | // ______|______ <--crossingInter // | // _____|_____ <--standsInter // // Returns <offCross> // public Point CreatesFlyingShapeWithCrossing(Intersection thatInter) { // A valid transversal is required for this shape if (!this.CreatesAValidTransversalWith(thatInter)) return null; // We hould not have have endpoint standing as that is handled elsewhere if (this.StandsOnEndpoint() || thatInter.StandsOnEndpoint()) return null; // // Determine which is the crossing intersection and which stands on the endpoints // Intersection crossingInter = null; Intersection standsInter = null; if (this.Crossing() && thatInter.StandsOn()) { crossingInter = this; standsInter = thatInter; } else if (thatInter.Crossing() && this.StandsOn()) { crossingInter = thatInter; standsInter = this; } else return null; Segment transversal = this.AcquireTransversal(thatInter); // Stands on intersection must have BOTH points not on the transversal line // | // ______|______ // | // |_____ // | // | if (!transversal.PointLiesOn(standsInter.CreatesTShape())) return null; // Success, we have the desired shape // Acquire return point: offCross Segment transversalCrossing = crossingInter.GetCollinearSegment(transversal); return Segment.Between(crossingInter.intersect, transversalCrossing.Point1, standsInter.intersect) ? transversalCrossing.Point1 : transversalCrossing.Point2; }
// // 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)); }
// top // o // offStands oooooooe // e //offEndpoint eeeeeee // o // bottom // Returns: <offEndpoint, offStands> public KeyValuePair <Point, Point> CreatesSimplePIShape(Intersection thatInter) { KeyValuePair <Point, Point> nullPair = new KeyValuePair <Point, Point>(null, null); // A valid transversal is required for this shape if (!this.CreatesAValidTransversalWith(thatInter)) { return(nullPair); } // Restrict to desired combination if (this.StandsOnEndpoint() && thatInter.StandsOnEndpoint()) { return(nullPair); } // // Determine which is the stands and which is the endpoint // Intersection endpointInter = null; Intersection standsInter = null; if (this.StandsOnEndpoint() && thatInter.StandsOn()) { endpointInter = this; standsInter = thatInter; } else if (thatInter.StandsOnEndpoint() && this.StandsOn()) { endpointInter = this; standsInter = thatInter; } else { return(nullPair); } // // Avoid Some shapes // Segment transversal = this.AcquireTransversal(thatInter); Segment transversalStands = standsInter.GetCollinearSegment(transversal); Point top = null; Point bottom = null; if (Segment.Between(standsInter.intersect, transversalStands.Point1, endpointInter.intersect)) { top = transversalStands.Point1; bottom = transversalStands.Point2; } else { top = transversalStands.Point2; bottom = transversalStands.Point1; } // Avoid: ____ Although this shouldn't happen since both intersections do not stand on endpoints // ____| // // Also avoid Simple F-Shape // if (transversal.HasPoint(top) || transversal.HasPoint(bottom)) { return(nullPair); } // Determine S shape Point offStands = standsInter.CreatesTShape(); Segment parallelEndpoint = endpointInter.OtherSegment(transversal); Point offEndpoint = parallelEndpoint.OtherPoint(endpointInter.intersect); Segment crossingTester = new Segment(offStands, offEndpoint); Point intersection = transversal.FindIntersection(crossingTester); // S-shape // PI-Shape return(transversal.PointLiesOnAndBetweenEndpoints(intersection) ? nullPair : new KeyValuePair <Point, Point>(offEndpoint, offStands)); }
// // Creates a Chair // // | | | // |_____|____ leftInter |_________ tipOfT // | | | // | | | // off tipOfT // // bottomInter // // <leftInter, bottomInter> // Returns the legs of the chair in specific ordering: <off, bottomTip> public KeyValuePair <Point, Point> CreatesChairShape(Intersection thatInter) { KeyValuePair <Point, Point> nullPair = new KeyValuePair <Point, Point>(null, null); // A valid transversal is required for this shape if (!this.CreatesAValidTransversalWith(thatInter)) { return(nullPair); } // Both intersections must be standing on (and not endpoints) if (!this.StandsOn() || !thatInter.StandsOn()) { return(nullPair); } if (this.StandsOnEndpoint() || thatInter.StandsOnEndpoint()) { return(nullPair); } Point thisTipOfT = this.CreatesTShape(); Point thatTipOfT = thatInter.CreatesTShape(); Segment transversal = this.AcquireTransversal(thatInter); Intersection leftInter = null; Intersection bottomInter = null; // Avoid: // | // |______ // | | // | | // this is leftInter Point bottomTip = null; if (transversal.PointLiesOn(thisTipOfT)) { if (transversal.PointLiesOnAndBetweenEndpoints(thisTipOfT)) { return(nullPair); } leftInter = this; bottomInter = thatInter; bottomTip = thisTipOfT; } // thatInter is leftInter else if (transversal.PointLiesOn(thatTipOfT)) { if (transversal.PointLiesOnAndBetweenEndpoints(thatTipOfT)) { return(nullPair); } leftInter = thatInter; bottomInter = this; bottomTip = thisTipOfT; } // Otherwise, this indicates a PI-shaped scenario else { return(nullPair); } // // Returns the bottom of the legs of the chair // Segment parallelLeft = leftInter.OtherSegment(transversal); Segment crossingTester = new Segment(parallelLeft.Point1, bottomTip); Point intersection = transversal.FindIntersection(crossingTester); Point off = transversal.PointLiesOnAndBetweenEndpoints(intersection) ? parallelLeft.Point2 : parallelLeft.Point1; return(new KeyValuePair <Point, Point>(off, bottomTip)); }
// // Creates an F-Shape // top // _____ offEnd <--- Stands on Endpt // | // |_____ offStands <--- Stands on // | // | // bottom // Order of non-collinear points is order of intersections: <this, that> public KeyValuePair<Point, Point> CreatesFShape(Intersection thatInter) { KeyValuePair<Point, Point> nullPair = new KeyValuePair<Point, Point>(null, null); // A valid transversal is required for this shape if (!this.CreatesAValidTransversalWith(thatInter)) return nullPair; // Avoid both standing on an endpoint if (this.StandsOnEndpoint() && thatInter.StandsOnEndpoint()) return nullPair; Intersection endpt = null; Intersection standsOn = null; if (this.StandsOnEndpoint() && thatInter.StandsOn()) { endpt = this; standsOn = thatInter; } else if (thatInter.StandsOnEndpoint() && this.StandsOn()) { endpt = thatInter; standsOn = this; } else return nullPair; Segment transversal = this.AcquireTransversal(thatInter); Segment transversalStands = standsOn.GetCollinearSegment(transversal); // // Determine Top and bottom to avoid PI shape // Point top = null; Point bottom = null; if (Segment.Between(standsOn.intersect, transversalStands.Point1, endpt.intersect)) { bottom = transversalStands.Point1; top = transversalStands.Point2; } else { bottom = transversalStands.Point2; top = transversalStands.Point1; } // Avoid: ____ Although this shouldn't happen since both intersections do not stand on endpoints // ____| if (transversal.HasPoint(top) && transversal.HasPoint(bottom)) return nullPair; // Also avoid Simple PI-Shape // if (!transversal.HasPoint(top) && !transversal.HasPoint(bottom)) return nullPair; // Find the two points that make the points of the F Segment parallelEndPt = endpt.OtherSegment(transversal); Segment parallelStands = standsOn.OtherSegment(transversal); Point offEnd = transversal.PointLiesOn(parallelEndPt.Point1) ? parallelEndPt.Point2 : parallelEndPt.Point1; Point offStands = transversal.PointLiesOn(parallelStands.Point1) ? parallelStands.Point2 : parallelStands.Point1; // Check this is not a crazy F // _____ // | // ____| // | // | Point intersection = transversal.FindIntersection(new Segment(offEnd, offStands)); if (transversal.PointLiesOnAndBetweenEndpoints(intersection)) return nullPair; // Return in the order of 'off' points: <this, that> return this.Equals(endpt) ? new KeyValuePair<Point, Point>(offEnd, offStands) : new KeyValuePair<Point, Point>(offStands, offEnd); }
// Corresponding angles if: // // up <- may not occur // |_____ offEnd // | // |_____ offStands // | // | // down // private static List<EdgeAggregator> InstantiateFIntersection(Parallel parallel, Intersection inter1, Point off1, Intersection inter2, Point off2) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); Point offEnd = null; Point offStands = null; Intersection endpt = null; Intersection stands = null; if (inter1.StandsOnEndpoint()) { endpt = inter1; offEnd = off1; stands = inter2; offStands = off2; } else if (inter2.StandsOnEndpoint()) { endpt = inter2; offEnd = off2; stands = inter1; offStands = off1; } Segment transversal = inter1.AcquireTransversal(inter2); Segment nonParallelEndpt = endpt.GetCollinearSegment(transversal); Segment nonParallelStands = stands.GetCollinearSegment(transversal); Point down = null; Point up = null; if (Segment.Between(stands.intersect, nonParallelStands.Point1, endpt.intersect)) { down = nonParallelStands.Point1; up = nonParallelStands.Point2; } else { down = nonParallelStands.Point2; up = nonParallelStands.Point1; } // // Generate the new congruence // List<CongruentAngles> newAngleRelations = new List<CongruentAngles>(); if (!down.Equals(stands.intersect)) { GeometricCongruentAngles gca = new GeometricCongruentAngles(new Angle(offEnd, endpt.intersect, stands.intersect), new Angle(offStands, stands.intersect, down)); newAngleRelations.Add(gca); } if (!up.Equals(endpt.intersect)) { GeometricCongruentAngles gcaOptional = new GeometricCongruentAngles(new Angle(up, endpt.intersect, offEnd), new Angle(endpt.intersect, stands.intersect, offStands)); newAngleRelations.Add(gcaOptional); } return MakeRelations(newAngleRelations, parallel, inter1, inter2); }
// top // o // offStands oooooooe // e //offEndpoint eeeeeee // o // bottom // Returns: <offEndpoint, offStands> public KeyValuePair<Point, Point> CreatesSimplePIShape(Intersection thatInter) { KeyValuePair<Point, Point> nullPair = new KeyValuePair<Point, Point>(null, null); // A valid transversal is required for this shape if (!this.CreatesAValidTransversalWith(thatInter)) return nullPair; // Restrict to desired combination if (this.StandsOnEndpoint() && thatInter.StandsOnEndpoint()) return nullPair; // // Determine which is the stands and which is the endpoint // Intersection endpointInter = null; Intersection standsInter = null; if (this.StandsOnEndpoint() && thatInter.StandsOn()) { endpointInter = this; standsInter = thatInter; } else if (thatInter.StandsOnEndpoint() && this.StandsOn()) { endpointInter = this; standsInter = thatInter; } else return nullPair; // // Avoid Some shapes // Segment transversal = this.AcquireTransversal(thatInter); Segment transversalStands = standsInter.GetCollinearSegment(transversal); Point top = null; Point bottom = null; if (Segment.Between(standsInter.intersect, transversalStands.Point1, endpointInter.intersect)) { top = transversalStands.Point1; bottom = transversalStands.Point2; } else { top = transversalStands.Point2; bottom = transversalStands.Point1; } // Avoid: ____ Although this shouldn't happen since both intersections do not stand on endpoints // ____| // // Also avoid Simple F-Shape // if (transversal.HasPoint(top) || transversal.HasPoint(bottom)) return nullPair; // Determine S shape Point offStands = standsInter.CreatesTShape(); Segment parallelEndpoint = endpointInter.OtherSegment(transversal); Point offEndpoint = parallelEndpoint.OtherPoint(endpointInter.intersect); Segment crossingTester = new Segment(offStands, offEndpoint); Point intersection = transversal.FindIntersection(crossingTester); // S-shape // PI-Shape return transversal.PointLiesOnAndBetweenEndpoints(intersection) ? nullPair : new KeyValuePair<Point, Point>(offEndpoint, offStands); }
private static List<EdgeAggregator> InstantiateIntersection(Parallel parallel, Intersection inter1, Intersection inter2) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); // Avoid: // | | // __| ________| // | | // | | // Both intersections (transversal segments) must contain the actual transversal; that is, a direct, segment relationship must exist if (!inter1.CreatesAValidTransversalWith(inter2)) return newGrounded; // No corresponding angles if we have: // // | | | // |__________| |_________ // | // | // if (inter1.StandsOnEndpoint() && inter2.StandsOnEndpoint()) return newGrounded; // if (Utilities.DEBUG) System.Diagnostics.Debug.WriteLine("Working on: \n\t" + inter1.ToString() + "\n\t" + inter2.ToString()); // // Verify we have a parallel / intersection situation using the given information // Segment transversal = inter1.AcquireTransversal(inter2); // Ensure the non-traversal segments align with the parallel segments Segment coincidingParallel1 = parallel.CoincidesWith(inter1.OtherSegment(transversal)); Segment coincidingParallel2 = parallel.CoincidesWith(inter2.OtherSegment(transversal)); // The pair of non-transversals needs to align exactly with the parallel pair of segments if (coincidingParallel1 == null || coincidingParallel2 == null) return newGrounded; // STANDARD Dual Crossings // Corresponding angles: // // | | // ___|__________|__ // | | // | | // if (inter1.Crossing() && inter2.Crossing()) return InstantiateCompleteIntersection(parallel, inter1, inter2); // NOT Corresponding if an H-Shape // // | | // |_____| // | | // | | // if (inter1.CreatesHShape(inter2)) return newGrounded; // NOT Corresponding angles if: // // |______ // | // ______| // | // KeyValuePair<Point, Point> sShapePoints = inter1.CreatesStandardSShape(inter2); if (sShapePoints.Key != null && sShapePoints.Value != null) return newGrounded; // NOT Corresponding angles if: // // |______ // | // ______| KeyValuePair<Point, Point> leanerShapePoints = inter1.CreatesLeanerShape(inter2); if (leanerShapePoints.Key != null && leanerShapePoints.Value != null) return newGrounded; // Corresponding angles if: // _____ // | // |_____ // | // | // KeyValuePair<Point, Point> fShapePoints = inter1.CreatesFShape(inter2); if (fShapePoints.Key != null && fShapePoints.Value != null) { return InstantiateFIntersection(parallel, inter1, fShapePoints.Key, inter2, fShapePoints.Value); } sShapePoints = inter1.CreatesSimpleSShape(inter2); if (sShapePoints.Key != null && sShapePoints.Value != null) return newGrounded; // Corresponding angles if: // o e // standsOn (o) o e standsOnEndpoint (e) // eeeoeeeeeeee // o // o // KeyValuePair<Point, Point> simpleTShapePoints = inter1.CreatesSimpleTShape(inter2); if (simpleTShapePoints.Key != null && simpleTShapePoints.Value != null) { return InstantiateSimpleTIntersection(parallel, inter1, inter2, simpleTShapePoints.Key, simpleTShapePoints.Value); } // Corresponding angles if: // ____________ // | | // | | // KeyValuePair<Point, Point> piShapePoints = inter1.CreatesSimplePIShape(inter2); if (piShapePoints.Key != null && piShapePoints.Value != null) { return InstantiateSimplePiIntersection(parallel, inter1, inter2, piShapePoints.Key, piShapePoints.Value); } // Corresponding if: // // | | | // |_____|____ |_________ // | | | // | | | // KeyValuePair<Point, Point> chairShapePoints = inter1.CreatesChairShape(inter2); if (chairShapePoints.Key != null && chairShapePoints.Value != null) { return InstantiateChairIntersection(parallel, inter1, chairShapePoints.Key, inter2, chairShapePoints.Value); } // Corresponding angles if: // ____________ // | | // | | // piShapePoints = inter1.CreatesPIShape(inter2); if (piShapePoints.Key != null && piShapePoints.Value != null) { return InstantiatePiIntersection(parallel, inter1, piShapePoints.Key, inter2, piShapePoints.Value); } // // | | // _____|____ ______|______ // | | // |_____ _____| // KeyValuePair<Point, Point> crossedTShapePoints = inter1.CreatesCrossedTShape(inter2); if (crossedTShapePoints.Key != null && crossedTShapePoints.Value != null) { return InstantiateCrossedTIntersection(parallel, inter1, inter2, crossedTShapePoints.Key, crossedTShapePoints.Value); } // Corresponding if a flying-Shape // // | | // |_____|___ // | | // | | // KeyValuePair<Intersection, Point> flyingShapeValues = inter1.CreatesFlyingShape(inter2); if (flyingShapeValues.Key != null && flyingShapeValues.Value != null) { return InstantiateFlyingIntersection(parallel, inter1, inter2, flyingShapeValues.Key, flyingShapeValues.Value); } // | // ______|______ // | // _____|_____ Point offCross = inter1.CreatesFlyingShapeWithCrossing(inter2); if (offCross != null) return InstantiateFlyingCrossedIntersection(parallel, inter1, inter2, offCross); // | // ______|______ // | // |_____ // | offCross = inter1.CreatesExtendedChairShape(inter2); if (offCross != null) return InstantiateExtendedChairIntersection(parallel, inter1, inter2, offCross); return newGrounded; }
// Corresponding angles if: // offRightEnd // standsOn (o) o e // o e standsOnEndpoint (e) // offLeftEnd eeeoeeeeeeee // o // o // // Returns <offLeftEnd, offRightEnd> // public KeyValuePair<Point, Point> CreatesSimpleTShape(Intersection thatInter) { KeyValuePair<Point, Point> nullPair = new KeyValuePair<Point, Point>(null, null); // A valid transversal is required for this shape if (!this.CreatesAValidTransversalWith(thatInter)) return nullPair; if (this.StandsOnEndpoint() && thatInter.StandsOnEndpoint()) return nullPair; // // Determine which is the crossing intersection and which stands on the endpoints // Intersection endpointInter = null; Intersection standsInter = null; if (this.StandsOnEndpoint() && thatInter.StandsOn()) { endpointInter = this; standsInter = thatInter; } else if (thatInter.Crossing() && this.StandsOnEndpoint()) { endpointInter = thatInter; standsInter = this; } else return nullPair; // // Determine if the endpoint intersection extends beyond the stands parallel line // Segment transversal = this.AcquireTransversal(thatInter); Segment transversalEndpoint = endpointInter.GetCollinearSegment(transversal); if (transversal.PointLiesOnAndBetweenEndpoints(transversalEndpoint.Point1) && transversal.PointLiesOnAndBetweenEndpoints(transversalEndpoint.Point2)) return nullPair; // // Acquire the returning points // Segment parallelEndpoint = endpointInter.OtherSegment(transversal); Point offLeftEnd = transversalEndpoint.OtherPoint(endpointInter.intersect); Point offRightEnd = parallelEndpoint.OtherPoint(endpointInter.intersect); return new KeyValuePair<Point, Point>(offLeftEnd, offRightEnd); }
// top // o // offStands oooooooe // e //offEndpoint eeeeeee // o // bottom // Returns: <offEndpoint, offStands> private static List<EdgeAggregator> InstantiateSimplePiIntersection(Parallel parallel, Intersection inter1, Intersection inter2, Point offEndpoint, Point offStands) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); // // Determine which is the endpoint and stands intersections // Intersection endpointInter = null; Intersection standsInter = null; if (inter1.StandsOnEndpoint() && inter2.StandsOn()) { endpointInter = inter1; standsInter = inter2; } else if (inter2.StandsOnEndpoint() && inter1.StandsOn()) { endpointInter = inter2; standsInter = inter1; } else return newGrounded; // // Determine the top and bottom points // Segment transversal = inter1.AcquireTransversal(inter2); Segment transversalStands = standsInter.GetCollinearSegment(transversal); Point top = null; Point bottom = null; if (Segment.Between(standsInter.intersect, transversalStands.Point1, endpointInter.intersect)) { top = transversalStands.Point1; bottom = transversalStands.Point2; } else { top = transversalStands.Point2; bottom = transversalStands.Point1; } // // Generate the new congruences // List<CongruentAngles> newAngleRelations = new List<CongruentAngles>(); GeometricCongruentAngles gca = new GeometricCongruentAngles(new Angle(top, standsInter.intersect, offStands), new Angle(standsInter.intersect, endpointInter.intersect, offEndpoint)); newAngleRelations.Add(gca); gca = new GeometricCongruentAngles(new Angle(bottom, endpointInter.intersect, offEndpoint), new Angle(endpointInter.intersect, standsInter.intersect, offStands)); newAngleRelations.Add(gca); return MakeRelations(newAngleRelations, parallel, inter1, inter2); }
// A B // \ / // \ / // \/ // /\ X // / \ // / \ // C D // // Intersection(X, Segment(A, D), Segment(B, C)) -> Supplementary(Angle(A, X, B), Angle(B, X, D)) // Supplementary(Angle(B, X, D), Angle(D, X, C)) // Supplementary(Angle(D, X, C), Angle(C, X, A)) // Supplementary(Angle(C, X, A), Angle(A, X, B)) // public static List<EdgeAggregator> InstantiateToSupplementary(Intersection inter) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); // The situation looks like this: // | // | // |_______ // if (inter.StandsOnEndpoint()) return newGrounded; // The situation looks like this: // | // | // _____|_______ // if (inter.StandsOn()) { Point up = null; Point left = null; Point right = null; if (inter.lhs.HasPoint(inter.intersect)) { up = inter.lhs.OtherPoint(inter.intersect); left = inter.rhs.Point1; right = inter.rhs.Point2; } else { up = inter.rhs.OtherPoint(inter.intersect); left = inter.lhs.Point1; right = inter.lhs.Point2; } // Gets the single angle object from the original figure Angle newAngle1 = Angle.AcquireFigureAngle(new Angle(left, inter.intersect, up)); Angle newAngle2 = Angle.AcquireFigureAngle(new Angle(right, inter.intersect, up)); Supplementary supp = new Supplementary(newAngle1, newAngle2); supp.SetNotASourceNode(); supp.SetNotAGoalNode(); supp.SetClearDefinition(); newGrounded.Add(new EdgeAggregator(MakeAntecedent(inter, supp.angle1, supp.angle2), supp, annotation)); } // // The situation is standard and results in 4 supplementary relationships // else { Angle newAngle1 = Angle.AcquireFigureAngle(new Angle(inter.lhs.Point1, inter.intersect, inter.rhs.Point1)); Angle newAngle2 = Angle.AcquireFigureAngle(new Angle(inter.lhs.Point1, inter.intersect, inter.rhs.Point2)); Angle newAngle3 = Angle.AcquireFigureAngle(new Angle(inter.lhs.Point2, inter.intersect, inter.rhs.Point1)); Angle newAngle4 = Angle.AcquireFigureAngle(new Angle(inter.lhs.Point2, inter.intersect, inter.rhs.Point2)); List<Supplementary> newSupps = new List<Supplementary>(); newSupps.Add(new Supplementary(newAngle1, newAngle2)); newSupps.Add(new Supplementary(newAngle2, newAngle4)); newSupps.Add(new Supplementary(newAngle3, newAngle4)); newSupps.Add(new Supplementary(newAngle3, newAngle1)); foreach (Supplementary supp in newSupps) { supp.SetNotASourceNode(); supp.SetNotAGoalNode(); supp.SetClearDefinition(); newGrounded.Add(new EdgeAggregator(MakeAntecedent(inter, supp.angle1, supp.angle2), supp, annotation)); } } return newGrounded; }
// Corresponding angles if: // sameSide offRightEnd // standsOn (o) o e // o e standsOnEndpoint (e) // offLeftEnd eeeoeeeeeeee // o // o // // Returns <offLeftEnd, offRightEnd> // private static List<EdgeAggregator> InstantiateSimpleTIntersection(Parallel parallel, Intersection inter1, Intersection inter2, Point offLeftEnd, Point offRightEnd) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); // // Determine which is the endpoint and stands intersections // Intersection endpointInter = null; Intersection standsInter = null; if (inter1.StandsOnEndpoint() && inter2.StandsOn()) { endpointInter = inter1; standsInter = inter2; } else if (inter2.StandsOnEndpoint() && inter1.StandsOn()) { endpointInter = inter2; standsInter = inter1; } else return newGrounded; // Determine the sameSide point Segment transversal = inter1.AcquireTransversal(inter2); Segment parallelStands = standsInter.OtherSegment(transversal); Segment crossingTester = new Segment(offRightEnd, parallelStands.Point1); Point intersection = transversal.FindIntersection(crossingTester); Point sameSide = transversal.PointLiesOnAndBetweenEndpoints(intersection) ? parallelStands.Point2 : parallelStands.Point1; // // Generate the new congruence // List<CongruentAngles> newAngleRelations = new List<CongruentAngles>(); GeometricCongruentAngles gca = new GeometricCongruentAngles(new Angle(offLeftEnd, standsInter.intersect, sameSide), new Angle(standsInter.intersect, endpointInter.intersect, offRightEnd)); newAngleRelations.Add(gca); return MakeRelations(newAngleRelations, parallel, inter1, inter2); }
private static List<EdgeAggregator> CheckAndGenerateParallelImplyAlternateInterior(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; // Determine the transversal Segment transversal = inter1.AcquireTransversal(inter2); if (transversal == null) return newGrounded; // // Ensure the non-traversal segments align with the parallel segments // Segment parallel1 = inter1.OtherSegment(transversal); Segment parallel2 = inter2.OtherSegment(transversal); // The non-transversals should not be the same (coinciding) if (parallel1.IsCollinearWith(parallel2)) return newGrounded; Segment coincidingParallel1 = parallel.CoincidesWith(parallel1); Segment coincidingParallel2 = parallel.CoincidesWith(parallel2); // The pair of non-transversals needs to align exactly with the parallel pair of segments if (coincidingParallel1 == null || coincidingParallel2 == null) return newGrounded; // Both intersections should not be referring to an intersection point on the same parallel segment if (parallel.segment1.PointLiesOn(inter1.intersect) && parallel.segment1.PointLiesOn(inter2.intersect)) return newGrounded; if (parallel.segment2.PointLiesOn(inter1.intersect) && parallel.segment2.PointLiesOn(inter2.intersect)) return newGrounded; // The resultant candidate parallel segments shouldn't share any vertices if (coincidingParallel1.SharedVertex(coincidingParallel2) != null) return newGrounded; if (inter1.StandsOnEndpoint() && inter2.StandsOnEndpoint()) { // // Creates a basic S-Shape with standsOnEndpoints // // offThis ______ // | // offThat ______| // // Return <offThis, offThat> KeyValuePair<Point, Point> cShapePoints = inter1.CreatesBasicCShape(inter2); if (cShapePoints.Key != null && cShapePoints.Value != null) return newGrounded; // // Creates a basic S-Shape with standsOnEndpoints // // ______ offThat _______ // | \ // offThis ______| _____\ // // Return <offThis, offThat> KeyValuePair<Point, Point> sShapePoints = inter1.CreatesBasicSShape(inter2); if (sShapePoints.Key != null && sShapePoints.Value != null) { return GenerateSimpleS(parallel, inter1, sShapePoints.Key, inter2, sShapePoints.Value); } return newGrounded; } // _______/________ // / // / // ______/_______ // / if (inter1.Crossing() && inter2.Crossing()) return GenerateDualCrossings(parallel, inter1, inter2); // No alt int in this case: // Creates an F-Shape // top // _____ offEnd <--- Stands on Endpt // | // |_____ offStands <--- Stands on // | // | // bottom KeyValuePair<Point, Point> fShapePoints = inter1.CreatesFShape(inter2); if (fShapePoints.Key != null && fShapePoints.Value != null) return newGrounded; // Alt. Int if an H-Shape // // | | // |_____| // | | // | | // if (inter1.CreatesHShape(inter2)) return GenerateH(parallel, inter1, inter2); // Creates an S-Shape // // |______ // | // ______| // | // // Order of non-collinear points is order of intersections: <this, that> KeyValuePair<Point, Point> standardSShapePoints = inter1.CreatesStandardSShape(inter2); if (standardSShapePoints.Key != null && standardSShapePoints.Value != null) { return GenerateSimpleS(parallel, inter1, standardSShapePoints.Key, inter2, standardSShapePoints.Value); } // Corresponding if a flying-Shape // // | | // |_____|___ offCross // | | // | | // Point offCross = inter1.CreatesFlyingShapeWithCrossing(inter2); if (offCross != null) { return GenerateFlying(parallel, inter1, inter2, offCross); } // // Creates a shape like an extended t // offCross offCross // | | // _____|____ ______|______ // | | // |_____ offStands offStands _____| // // Returns <offStands, offCross> KeyValuePair<Point, Point> tShapePoints = inter1.CreatesCrossedTShape(inter2); if (tShapePoints.Key != null && tShapePoints.Value != null) { return GenerateCrossedT(parallel, inter1, inter2, tShapePoints.Key, tShapePoints.Value); } // // Creates a Topped F-Shape // top // offLeft __________ offEnd <--- Stands on // | // |_____ off <--- Stands on // | // | // bottom // // Returns: <bottom, off> KeyValuePair<Intersection, Point> toppedFShapePoints = inter1.CreatesToppedFShape(inter2); if (toppedFShapePoints.Key != null && toppedFShapePoints.Value != null) { return GenerateToppedFShape(parallel, inter1, inter2, toppedFShapePoints.Key, toppedFShapePoints.Value); } return newGrounded; }
// Corresponding angles if: // // up <- may not occur // |_____ offEnd // | // |_____ offStands // | // | // down // private static List<EdgeAggregator> InstantiateFIntersection(Parallel parallel, Intersection inter1, Point off1, Intersection inter2, Point off2) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); Point offEnd = null; Point offStands = null; Intersection endpt = null; Intersection stands = null; if (inter1.StandsOnEndpoint()) { endpt = inter1; offEnd = off1; stands = inter2; offStands = off2; } else if (inter2.StandsOnEndpoint()) { endpt = inter2; offEnd = off2; stands = inter1; offStands = off1; } Segment transversal = inter1.AcquireTransversal(inter2); Segment nonParallelEndpt = endpt.GetCollinearSegment(transversal); Segment nonParallelStands = stands.GetCollinearSegment(transversal); Point down = null; Point up = null; if (Segment.Between(stands.intersect, nonParallelStands.Point1, endpt.intersect)) { down = nonParallelStands.Point1; up = nonParallelStands.Point2; } else { down = nonParallelStands.Point2; up = nonParallelStands.Point1; } // // up <- may not occur // |_____ offEnd // | // |_____ offStands // | // | // down // // // Generate the new supplement relationship // List<Supplementary> newSupps = new List<Supplementary>(); Supplementary supp = new Supplementary(new Angle(offEnd, endpt.intersect, stands.intersect), new Angle(offStands, stands.intersect, endpt.intersect)); newSupps.Add(supp); return MakeHypergraphRelation(newSupps, parallel, inter1, inter2); }