Пример #1
0
        //
        // Collinear(A, B, C, D, ...) -> Angle(A, B, C), Angle(A, B, D), Angle(A, C, D), Angle(B, C, D),...
        // All angles will have measure 180^o
        // There will be nC3 resulting clauses.
        //
        public static List <EdgeAggregator> Instantiate(GroundedClause clause)
        {
            annotation.active = EngineUIBridge.JustificationSwitch.STRAIGHT_ANGLE_DEFINITION;

            List <EdgeAggregator> newGrounded = new List <EdgeAggregator>();

            Collinear cc = clause as Collinear;

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

            for (int i = 0; i < cc.points.Count - 2; i++)
            {
                for (int j = i + 1; j < cc.points.Count - 1; j++)
                {
                    for (int k = j + 1; k < cc.points.Count; k++)
                    {
                        Angle newAngle = new Angle(cc.points[i], cc.points[j], cc.points[k]);
                        List <GroundedClause> antecedent = Utilities.MakeList <GroundedClause>(cc);
                        newGrounded.Add(new EdgeAggregator(antecedent, newAngle, annotation));
                    }
                }
            }

            return(newGrounded);
        }
Пример #2
0
        /// <summary>
        /// Calculate all points of intersection between circles.
        /// Updates segments by creating segments.
        /// </summary>
        public void CalcCircleCircleIntersections(out List <GeometryTutorLib.ConcreteAST.CircleCircleIntersection> ccIntersections)
        {
            ccIntersections = new List <CircleCircleIntersection>();

            for (int c1 = 0; c1 < implied.circles.Count - 1; c1++)
            {
                for (int c2 = c1 + 1; c2 < implied.circles.Count; c2++)
                {
                    //
                    // Find any intersection points between the circle and the segment;
                    // the intersection MUST be between the segment endpoints
                    //
                    Point inter1 = null;
                    Point inter2 = null;
                    implied.circles[c1].FindIntersection(implied.circles[c2], out inter1, out inter2);

                    List <Point> intersectionPts = new List <Point>();
                    if (inter1 != null)
                    {
                        intersectionPts.Add(inter1);
                    }
                    if (inter2 != null)
                    {
                        intersectionPts.Add(inter2);
                    }

                    // normalized to drawing point (names)
                    intersectionPts = implied.NormalizePointsToDrawing(intersectionPts);

                    // and add to each figure (circle and polygon).
                    implied.circles[c1].AddIntersectingPoints(intersectionPts);
                    implied.circles[c2].AddIntersectingPoints(intersectionPts);

                    //
                    // Construct the intersections
                    //
                    CircleCircleIntersection ccInter = null;

                    if (inter1 != null)
                    {
                        ccInter = new CircleCircleIntersection(inter1, implied.circles[c1], implied.circles[c2]);
                        GeometryTutorLib.Utilities.AddStructurallyUnique <CircleCircleIntersection>(ccIntersections, ccInter);
                    }
                    if (inter2 != null)
                    {
                        ccInter = new CircleCircleIntersection(inter2, implied.circles[c1], implied.circles[c2]);
                        GeometryTutorLib.Utilities.AddStructurallyUnique <CircleCircleIntersection>(ccIntersections, ccInter);
                    }

                    // Add an implied collinear relationship so that the appropriate segments are generated.
                    // ONLY for tangent situations.
                    if (inter1 != null && inter2 == null)
                    {
                        //Determine the endpoints (the intersection point could be an endpoint if the tangency is internal)
                        Point e1, e2, m;
                        Point center1 = implied.circles[c1].center;
                        Point center2 = implied.circles[c2].center;
                        if (GeometryTutorLib.ConcreteAST.Segment.Between(inter1, center1, center2))
                        {
                            e1 = center1;
                            e2 = center2;
                            m  = inter1;
                        }
                        else if (GeometryTutorLib.ConcreteAST.Segment.Between(center1, inter1, center2))
                        {
                            e1 = inter1;
                            e2 = center2;
                            m  = center1;
                        }
                        else
                        {
                            e1 = inter1;
                            e2 = center1;
                            m  = center2;
                        }
                        Collinear coll = new Collinear();
                        coll.AddCollinearPoint(e1);
                        coll.AddCollinearPoint(m);
                        coll.AddCollinearPoint(e2);
                        implied.collinear.Add(coll);
                    }
                }
            }

            // Construct any radii and chords.
            foreach (GeometryTutorLib.ConcreteAST.Circle circle in implied.circles)
            {
                AddImpliedSegments(circle);
            }
        }