示例#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 an S-Shape
        //
        //         |______
        //         |
        //   ______|
        //         |
        //
        //   Order of non-collinear points is order of intersections: <this, that>
        public KeyValuePair <Point, Point> CreatesStandardSShape(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);
            }

            Point thisNonCollinear = this.CreatesTShape();
            Point thatNonCollinear = thatInter.CreatesTShape();

            if (thisNonCollinear == null || thatNonCollinear == null)
            {
                return(nullPair);
            }

            //
            // Verify that the shape is PI and not an S-shape; look for the intersection point NOT between the endpoints of the transversal
            //
            // The transversal should be valid
            Segment transversal  = this.AcquireTransversal(thatInter);
            Point   intersection = transversal.FindIntersection(new Segment(thisNonCollinear, thatNonCollinear));

            // PI-shape
            if (!transversal.PointLiesOnAndBetweenEndpoints(intersection))
            {
                return(nullPair);
            }

            // S-Shape
            return(new KeyValuePair <Point, Point>(thisNonCollinear, thatNonCollinear));
        }
        //
        // Chair Corresponding
        //
        // |     |                  |
        // |_____|____   leftInter  |_________ tipOfT
        // |                        |     |
        // |                        |     |
        //                         off   tipOfT
        //
        //                                bottomInter
        private static List<EdgeAggregator> InstantiateChairIntersection(Parallel parallel, Intersection inter1, Point off, Intersection inter2, Point bottomTip)
        {
            List<EdgeAggregator> newGrounded = new List<EdgeAggregator>();

            Segment transversal = inter1.AcquireTransversal(inter2);
            Point tipOfT1 = inter1.CreatesTShape();
            Point tipOfT2 = inter2.CreatesTShape();

            Point leftTip = null;
            Intersection leftInter = null;
            Intersection bottomInter = null;

            if (transversal.PointLiesOn(tipOfT1))
            {
                leftInter = inter1;
                bottomInter = inter2;
                leftTip = tipOfT1;
            }
            // thatInter is leftInter
            else if (transversal.PointLiesOn(tipOfT2))
            {
                leftInter = inter2;
                bottomInter = inter1;
                leftTip = tipOfT2;
            }

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

            // CTA: Hack fix to alleviate exception thrown from improper congruent constructions.
            GeometricCongruentAngles gca = null;
            try
            {
                gca = new GeometricCongruentAngles(new Angle(leftTip, bottomInter.intersect, bottomTip),
                                                   new Angle(bottomInter.intersect, leftInter.intersect, off));
            }
            catch (Exception e)
            {
                if (Utilities.DEBUG) System.Diagnostics.Debug.WriteLine(e.ToString());

                return newGrounded;
            }

            newAngleRelations.Add(gca);

            return MakeRelations(newAngleRelations, parallel, inter1, inter2);
        }
示例#4
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));
        }
        private static List<EdgeAggregator> CheckAndGenerateProportionality(Triangle tri, Intersection inter1,
                                                                            Intersection inter2, Parallel parallel)
        {
            List<EdgeAggregator> newGrounded = new List<EdgeAggregator>();

            // The two intersections should not be at the same vertex
            if (inter1.intersect.Equals(inter2.intersect)) return newGrounded;

            //
            // Do these intersections share a segment? That is, do they share the transversal?
            //
            Segment transversal = inter1.AcquireTransversal(inter2);
            if (transversal == null) return newGrounded;

            //
            // Is the transversal a side of the triangle? It should not be.
            //
            if (tri.LiesOn(transversal)) return newGrounded;

            //
            // Determine if one parallel segment is a side of the triangle (which must occur)
            //
            Segment coinciding = tri.DoesParallelCoincideWith(parallel);
            if (coinciding == null) return newGrounded;

            // The transversal and common segment must be distinct
            if (coinciding.IsCollinearWith(transversal)) return newGrounded;

            //
            // Determine if the simplified transversal is within the parallel relationship.
            //
            Segment parallelTransversal = parallel.OtherSegment(coinciding);
            Segment simpleParallelTransversal = new Segment(inter1.intersect, inter2.intersect);

            if (!parallelTransversal.IsCollinearWith(simpleParallelTransversal)) return newGrounded;

            //            A
            //           /\
            //          /  \
            //         /    \
            //  off1  /------\ off2
            //       /        \
            //    B /__________\ C

            //
            // Both intersections should create a T-shape.
            //
            Point off1 = inter1.CreatesTShape();
            Point off2 = inter2.CreatesTShape();
            if (off1 == null || off2 == null) return newGrounded;

            // Get the intersection segments which should coincide with the triangle sides
            KeyValuePair<Segment, Segment> otherSides = tri.OtherSides(coinciding);

            // The intersections may be outside this triangle
            if (otherSides.Key == null || otherSides.Value == null) return newGrounded;

            Segment side1 = inter1.OtherSegment(transversal);
            Segment side2 = inter2.OtherSegment(transversal);

            // Get the actual sides of the triangle
            Segment triangleSide1 = null;
            Segment triangleSide2 = null;
            if (side1.IsCollinearWith(otherSides.Key) && side2.IsCollinearWith(otherSides.Value))
            {
                triangleSide1 = otherSides.Key;
                triangleSide2 = otherSides.Value;
            }
            else if (side1.IsCollinearWith(otherSides.Value) && side2.IsCollinearWith(otherSides.Key))
            {
                triangleSide1 = otherSides.Value;
                triangleSide2 = otherSides.Key;
            }
            else return newGrounded;

            // Verify the opposing parts of the T are on the opposite sides of the triangle
            if (!triangleSide1.PointLiesOnAndExactlyBetweenEndpoints(off2)) return newGrounded;
            if (!triangleSide2.PointLiesOnAndExactlyBetweenEndpoints(off1)) return newGrounded;

            //
            // Construct the new proprtional relationship and resultant equation
            //
            Point sharedVertex = triangleSide1.SharedVertex(triangleSide2);
            SegmentRatio newProp1 = new SegmentRatio(new Segment(sharedVertex, off2), triangleSide1);
            SegmentRatio newProp2 = new SegmentRatio(new Segment(sharedVertex, off1), triangleSide2);

            GeometricSegmentRatioEquation newEq = new GeometricSegmentRatioEquation(newProp1, newProp2);

            // Construct hyperedge
            List<GroundedClause> antecedent = new List<GroundedClause>();
            antecedent.Add(tri);
            antecedent.Add(inter1);
            antecedent.Add(inter2);
            antecedent.Add(parallel);

            newGrounded.Add(new EdgeAggregator(antecedent, newEq, annotation));

            return newGrounded;
        }
示例#6
0
        //
        // Creates an S-Shape
        //
        //         |______
        //         |
        //   ______|
        //         |
        //
        //   Order of non-collinear points is order of intersections: <this, that>
        public KeyValuePair<Point, Point> CreatesStandardSShape(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;

            Point thisNonCollinear = this.CreatesTShape();
            Point thatNonCollinear = thatInter.CreatesTShape();

            if (thisNonCollinear == null || thatNonCollinear == null) return nullPair;

            //
            // Verify that the shape is PI and not an S-shape; look for the intersection point NOT between the endpoints of the transversal
            //
            // The transversal should be valid
            Segment transversal = this.AcquireTransversal(thatInter);
            Point intersection = transversal.FindIntersection(new Segment(thisNonCollinear, thatNonCollinear));

            // PI-shape
            if (!transversal.PointLiesOnAndBetweenEndpoints(intersection)) return nullPair;

            // S-Shape
            return new KeyValuePair<Point, Point>(thisNonCollinear, thatNonCollinear);
        }
示例#7
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;
        }
示例#8
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);
        }
示例#9
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);
        }
示例#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));
        }