Пример #1
0
        // 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));
        }
Пример #2
0
        //
        // 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);
        }
Пример #3
0
        //
        // 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));
        }
        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;
        }
        //                 offCross
        //                     |
        // leftCross     ______|______   rightCross
        //                     |
        // leftStands     _____|_____    rightStands
        //
        private static List<EdgeAggregator> GenerateFlying(Parallel parallel, Intersection inter1, Intersection inter2, 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())
            {
                crossingInter = inter1;
                standsInter = inter2;
            }
            else if (inter2.Crossing())
            {
                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);

            // Determine point orientation in the plane
            Point leftStands = parallelStands.Point1;
            Point rightStands = parallelStands.Point2;
            Point leftCross = null;
            Point rightCross = null;

            Segment crossingTester = new Segment(leftStands, parallelCrossing.Point1);
            Point intersection = transversal.FindIntersection(crossingTester);
            if (transversal.PointLiesOnAndBetweenEndpoints(intersection))
            {
                leftCross = parallelCrossing.Point2;
                rightCross = parallelCrossing.Point1;
            }
            else
            {
                leftCross = parallelCrossing.Point1;
                rightCross = parallelCrossing.Point2;
            }

            //
            // Generate the new congruence
            //
            List<CongruentAngles> newAngleRelations = new List<CongruentAngles>();

            GeometricCongruentAngles gca = new GeometricCongruentAngles(new Angle(rightCross, crossingInter.intersect, standsInter.intersect),
                                                                        new Angle(leftStands, standsInter.intersect, crossingInter.intersect));
            newAngleRelations.Add(gca);

            gca = new GeometricCongruentAngles(new Angle(leftCross, crossingInter.intersect, standsInter.intersect),
                                               new Angle(rightStands, standsInter.intersect, crossingInter.intersect));
            newAngleRelations.Add(gca);

            return MakeRelations(newAngleRelations, parallel, inter1, inter2);
        }
Пример #6
0
        //
        // 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);
        }
Пример #7
0
        // 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);
        }
Пример #8
0
        //
        // 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;
        }
Пример #9
0
        //
        // 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);
        }
        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;
        }
        //     offCross
        //        |
        //  ______|______ rightCrossing
        //        |
        //        |_____  offStands
        //        |
        //        |
        //     bottomStands
        private static List<EdgeAggregator> InstantiateExtendedChairIntersection(Parallel parallel, Intersection inter1, Intersection inter2, 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())
            {
                crossingInter = inter1;
                standsInter = inter2;
            }
            else if (inter2.Crossing())
            {
                crossingInter = inter2;
                standsInter = inter1;
            }

            //
            // Determination of Points
            //
            Point offStands = standsInter.CreatesTShape();

            Segment transversal = inter1.AcquireTransversal(inter2);
            Segment transversalStands = standsInter.GetCollinearSegment(transversal);

            Point bottomStands = Segment.Between(standsInter.intersect, transversalStands.Point1, crossingInter.intersect) ? transversalStands.Point1 : transversalStands.Point2;

            // Which side for rightCrossing
            Segment parallelCrossing = crossingInter.OtherSegment(transversal);
            Segment crossingTester = new Segment(offStands, parallelCrossing.Point1);
            Point intersection = transversal.FindIntersection(crossingTester);

            Point rightCrossing = transversal.PointLiesOnAndBetweenEndpoints(intersection) ? parallelCrossing.Point2 : parallelCrossing.Point1;

            //
            // Generate the new congruence
            //
            List<CongruentAngles> newAngleRelations = new List<CongruentAngles>();

            GeometricCongruentAngles gca = new GeometricCongruentAngles(new Angle(bottomStands, standsInter.intersect, offStands),
                                                                        new Angle(standsInter.intersect, crossingInter.intersect, rightCrossing));
            newAngleRelations.Add(gca);

            gca = new GeometricCongruentAngles(new Angle(offStands, standsInter.intersect, crossingInter.intersect),
                                               new Angle(rightCrossing, crossingInter.intersect, offCross));
            newAngleRelations.Add(gca);

            return MakeRelations(newAngleRelations, parallel, inter1, inter2);
        }
        //
        // Creates a shape like an extended t
        //     offCross                          offCross
        //      |                                   |
        // _____|____ sameSide       sameSide ______|______
        //      |                                   |
        //      |_____ offStands     offStands _____|
        //
        // Returns <offStands, offCross>
        private static List<EdgeAggregator> InstantiateCrossedTIntersection(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;

            //
            // Generate the new congruence
            //
            List<CongruentAngles> newAngleRelations = new List<CongruentAngles>();

            GeometricCongruentAngles gca = new GeometricCongruentAngles(new Angle(offStands, standsInter.intersect, crossingInter.intersect),
                                                                        new Angle(sameSide, crossingInter.intersect, offCross));
            newAngleRelations.Add(gca);

            return MakeRelations(newAngleRelations, parallel, inter1, inter2);
        }
Пример #13
0
        //
        // 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 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 supplement relationship
            //
            List<Supplementary> newSupps = new List<Supplementary>();

            Supplementary supp = new Supplementary(new Angle(offStands, standsInter.intersect, crossingInter.intersect),
                                                   new Angle(sameSide, crossingInter.intersect, standsInter.intersect));
            newSupps.Add(supp);

            return MakeHypergraphRelation(newSupps, parallel, inter1, inter2);
        }