Exemplo n.º 1
0
        private static List <EdgeAggregator> InstantiateToAltitude(Triangle triangle, Perpendicular perp, GroundedClause original)
        {
            List <EdgeAggregator> newGrounded = new List <EdgeAggregator>();

            // Acquire the side of the triangle containing the intersection point
            // This point may or may not be directly on the triangle side
            Segment baseSegment = triangle.GetSegmentWithPointOnOrExtends(perp.intersect);

            if (baseSegment == null)
            {
                return(newGrounded);
            }

            // The altitude must pass through the intersection point as well as the opposing vertex
            Point oppositeVertex = triangle.OtherPoint(baseSegment);

            Segment altitude = new Segment(perp.intersect, oppositeVertex);

            // The alitude must alig with the intersection
            if (!perp.ImpliesRay(altitude))
            {
                return(newGrounded);
            }

            // The opposing side must align with the intersection
            if (!perp.OtherSegment(altitude).IsCollinearWith(baseSegment))
            {
                return(newGrounded);
            }


            //
            // Create the new Altitude object
            //
            Altitude newAltitude = new Altitude(triangle, altitude);

            // For hypergraph
            List <GroundedClause> antecedent = new List <GroundedClause>();

            antecedent.Add(triangle);
            antecedent.Add(original);

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

            //
            // Check if this induces a second altitude for a right triangle (although we don't know this is a strengthened triangle)
            // The intersection must be on the vertex of the triangle
            if (triangle.HasPoint(perp.intersect))
            {
                Angle possRightAngle = new Angle(triangle.OtherPoint(new Segment(perp.intersect, oppositeVertex)), perp.intersect, oppositeVertex);

                if (triangle.HasAngle(possRightAngle))
                {
                    Altitude secondAltitude = new Altitude(triangle, new Segment(perp.intersect, oppositeVertex));
                    newGrounded.Add(new EdgeAggregator(antecedent, secondAltitude, annotation));
                }
            }

            return(newGrounded);
        }
Exemplo n.º 2
0
        private static List <EdgeAggregator> CheckAndGeneratePerpendicular(Perpendicular perp, Parallel parallel, Intersection inter, GroundedClause original)
        {
            List <EdgeAggregator> newGrounded = new List <EdgeAggregator>();

            // The perpendicular intersection must refer to one of the parallel segments
            Segment shared = perp.CommonSegment(parallel);

            if (shared == null)
            {
                return(newGrounded);
            }

            // The other intersection must refer to a segment in the parallel pair
            Segment otherShared = inter.CommonSegment(parallel);

            if (otherShared == null)
            {
                return(newGrounded);
            }

            // The two shared segments must be distinct
            if (shared.Equals(otherShared))
            {
                return(newGrounded);
            }

            // Transversals must align
            if (!inter.OtherSegment(otherShared).Equals(perp.OtherSegment(shared)))
            {
                return(newGrounded);
            }

            // Strengthen the old intersection to be perpendicular
            Strengthened strengthenedPerp = new Strengthened(inter, new Perpendicular(inter));

            // Construct hyperedge
            List <GroundedClause> antecedent = new List <GroundedClause>();

            antecedent.Add(original);
            antecedent.Add(parallel);
            antecedent.Add(inter);

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

            return(newGrounded);
        }