Exemplo n.º 1
0
        //
        // Construct the AngleBisector if we have
        //
        //      V---------------A
        //     / \
        //    /   \
        //   /     \
        //  B       C
        //
        // Congruent(Angle, A, V, C), Angle(C, V, B)),  Segment(V, C)) -> AngleBisector(Angle(A, V, B)
        //
        //
        private static List <EdgeAggregator> InstantiateToDef(CongruentAngles cas, Segment segment)
        {
            List <EdgeAggregator> newGrounded = new List <EdgeAggregator>();

            // Find the shared segment between the two angles; we know it is valid if we reach this point
            Segment shared = cas.AreAdjacent();

            // The bisector must align with the given segment
            if (!segment.IsCollinearWith(shared))
            {
                return(newGrounded);
            }

            // We need a true bisector in which the shared vertex of the angles in between the endpoints of this segment
            if (!segment.PointLiesOnAndBetweenEndpoints(cas.ca1.GetVertex()))
            {
                return(newGrounded);
            }

            //
            // Create the overall angle which is being bisected
            //
            Point   vertex        = cas.ca1.GetVertex();
            Segment newRay1       = cas.ca1.OtherRayEquates(shared);
            Segment newRay2       = cas.ca2.OtherRayEquates(shared);
            Angle   combinedAngle = new Angle(newRay1.OtherPoint(vertex), vertex, newRay2.OtherPoint(vertex));

            // Determine if the segment is a straight angle (we don't want an angle bisector here, we would want a segment bisector)
            if (newRay1.IsCollinearWith(newRay2))
            {
                return(newGrounded);
            }

            // The bisector cannot be of the form:
            //    \
            //     \
            //      V---------------A
            //     /
            //    /
            //   B
            if (!combinedAngle.IsOnInteriorExplicitly(segment.Point1) && !combinedAngle.IsOnInteriorExplicitly(segment.Point2))
            {
                return(newGrounded);
            }

            AngleBisector newAB = new AngleBisector(combinedAngle, segment);

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

            antecedent.Add(segment);
            antecedent.Add(cas);

            newGrounded.Add(new EdgeAggregator(antecedent, newAB, annotation));
            return(newGrounded);
        }
        //
        // Intersection(M, Segment(A,B), Segment(C, D)),
        // Congruent(Angle(C, M, B), Angle(D, M, B)) -> Perpendicular(Segment(A, B), Segment(C, D))
        //
        //                                            B
        //                                           /
        //                              C-----------/-----------D
        //                                         / M
        //                                        /
        //                                       A
        public static List <EdgeAggregator> Instantiate(GroundedClause c)
        {
            annotation.active = EngineUIBridge.JustificationSwitch.CONGRUENT_ADJACENT_ANGLES_IMPLY_PERPENDICULAR;

            // The list of new grounded clauses if they are deduced
            List <EdgeAggregator> newGrounded = new List <EdgeAggregator>();

            if (c is CongruentAngles)
            {
                CongruentAngles conAngles = c as CongruentAngles;

                // We are interested in adjacent angles, not reflexive
                if (conAngles.IsReflexive())
                {
                    return(newGrounded);
                }

                // Any candidates congruent angles need to be adjacent to each other.
                if (conAngles.AreAdjacent() == null)
                {
                    return(newGrounded);
                }

                // Find two candidate lines cut by the same transversal
                foreach (Intersection inter in candIntersection)
                {
                    newGrounded.AddRange(CheckAndGenerateCongruentAdjacentImplyPerpendicular(inter, conAngles));
                }

                candAngles.Add(conAngles);
            }
            else if (c is Intersection)
            {
                Intersection newIntersection = c as Intersection;

                if (!newIntersection.IsStraightAngleIntersection())
                {
                    return(newGrounded);
                }

                foreach (CongruentAngles cas in candAngles)
                {
                    newGrounded.AddRange(CheckAndGenerateCongruentAdjacentImplyPerpendicular(newIntersection, cas));
                }

                candIntersection.Add(newIntersection);
            }

            return(newGrounded);
        }
Exemplo n.º 3
0
        private static List <EdgeAggregator> InstantiateCongruent(GroundedClause c)
        {
            List <EdgeAggregator> newGrounded = new List <EdgeAggregator>();

            if (c is CongruentAngles)
            {
                CongruentAngles cas = c as CongruentAngles;

                // We are interested in adjacent angles, not reflexive
                if (cas.IsReflexive())
                {
                    return(newGrounded);
                }
                if (cas.AreAdjacent() == null)
                {
                    return(newGrounded);
                }

                //
                // The candidate must equates to a given segment; that is, find the proper segment
                // The segment must pass through the actual vertex of the adjacent angles
                //
                foreach (Segment segment in candidateSegments)
                {
                    newGrounded.AddRange(InstantiateToDef(cas, segment));
                }

                // Did not unify so add to the candidate list
                if (!newGrounded.Any())
                {
                    candidateCongruent.Add(cas);
                }
            }
            else if (c is Segment)
            {
                Segment segment = c as Segment;
                foreach (CongruentAngles cas in candidateCongruent)
                {
                    newGrounded.AddRange(InstantiateToDef(cas, segment));
                }

                candidateSegments.Add(segment);
            }

            return(newGrounded);
        }