Пример #1
0
        //
        // Creates an H-Shape
        //
        // |     |
        // |_____|
        // |     |
        // |     |
        //
        public bool CreatesHShape(Intersection thatInter)
        {
            // A valid transversal is required for this shape
            if (!this.CreatesAValidTransversalWith(thatInter))
            {
                return(false);
            }

            // Both intersections must be standing on (and not endpoints)
            if (!this.StandsOn() || !thatInter.StandsOn())
            {
                return(false);
            }
            if (this.StandsOnEndpoint() || this.StandsOnEndpoint())
            {
                return(false);
            }

            Point thisTipOfT = this.CreatesTShape();
            Point thatTipOfT = thatInter.CreatesTShape();

            Segment transversal = this.AcquireTransversal(thatInter);

            // The tips of the intersections must be within the transversal (at the endpoint) for an H
            if (!transversal.PointLiesOnAndBetweenEndpoints(thisTipOfT))
            {
                return(false);
            }
            if (!transversal.PointLiesOnAndBetweenEndpoints(thatTipOfT))
            {
                return(false);
            }

            return(true);
        }
Пример #2
0
        //
        // 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));
        }
Пример #3
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));
        }
Пример #4
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);
        }
Пример #5
0
        //
        //                    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);
        }
Пример #6
0
        //
        // 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));
        }
Пример #7
0
        //
        // 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);
        }
Пример #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 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);
        }
Пример #10
0
        //
        // 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);
        }
Пример #11
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);
        }
Пример #12
0
        //                   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);
        }
Пример #13
0
        //                   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));
        }
Пример #14
0
        //
        // 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));
        }
Пример #15
0
        //
        // Creates an H-Shape
        //
        // |     |
        // |_____|
        // |     |
        // |     |
        //
        public bool CreatesHShape(Intersection thatInter)
        {
            // A valid transversal is required for this shape
            if (!this.CreatesAValidTransversalWith(thatInter)) return false;

            // Both intersections must be standing on (and not endpoints)
            if (!this.StandsOn() || !thatInter.StandsOn()) return false;
            if (this.StandsOnEndpoint() || this.StandsOnEndpoint()) return false;

            Point thisTipOfT = this.CreatesTShape();
            Point thatTipOfT = thatInter.CreatesTShape();

            Segment transversal = this.AcquireTransversal(thatInter);

            // The tips of the intersections must be within the transversal (at the endpoint) for an H
            if (!transversal.PointLiesOnAndBetweenEndpoints(thisTipOfT)) return false;
            if (!transversal.PointLiesOnAndBetweenEndpoints(thatTipOfT)) return false;

            return true;
        }
Пример #16
0
        //
        // 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);
        }
        //                   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);
        }
Пример #18
0
        //
        //                    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:
        //            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);
        }
Пример #20
0
        //  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;
        }
Пример #21
0
        //
        // 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));
        }