Exemple #1
0
 public MajorArc(Circle circle, Point e1, Point e2, List <Point> minorPts, List <Point> majorPts) : base(circle, e1, e2, minorPts, majorPts)
 {
     if (circle.DefinesDiameter(new Segment(e1, e2)))
     {
         System.Diagnostics.Debug.WriteLine("Major Arc should not be constructed when a semicircle is appropriate.");
     }
 }
Exemple #2
0
 public MajorArc(Circle circle, Point e1, Point e2, List<Point> minorPts, List<Point> majorPts)
     : base(circle, e1, e2, minorPts, majorPts)
 {
     if (circle.DefinesDiameter(new Segment(e1, e2)))
     {
         System.Diagnostics.Debug.WriteLine("Major Arc should not be constructed when a semicircle is appropriate.");
     }
 }
Exemple #3
0
        public Semicircle(Circle circle, Point e1, Point e2, Point m, List<Point> minorPts, List<Point> majorPts, Segment d)
            : base(circle, e1, e2, minorPts, majorPts)
        {
            diameter = d;
            middlePoint = m;

            if (!circle.DefinesDiameter(diameter))
            {
                System.Diagnostics.Debug.WriteLine("Semicircle constructed without a diameter");
            }

            if (!circle.DefinesDiameter(new Segment(e1, e2)))
            {
                System.Diagnostics.Debug.WriteLine("Semicircle constructed without a diameter");
            }

            thisAtomicRegion = new ShapeAtomicRegion(this);
        }
Exemple #4
0
        public Semicircle(Circle circle, Point e1, Point e2, Point m, List <Point> minorPts, List <Point> majorPts, Segment d)
            : base(circle, e1, e2, minorPts, majorPts)
        {
            diameter    = d;
            middlePoint = m;

            if (!circle.DefinesDiameter(diameter))
            {
                System.Diagnostics.Debug.WriteLine("Semicircle constructed without a diameter");
            }

            if (!circle.DefinesDiameter(new Segment(e1, e2)))
            {
                System.Diagnostics.Debug.WriteLine("Semicircle constructed without a diameter");
            }

            thisAtomicRegion = new ShapeAtomicRegion(this);
        }
Exemple #5
0
        private static Arc GetInscribedInterceptedArc(Circle circle, Angle angle)
        {
            Point endpt1, endpt2;

            Point pt1, pt2;

            circle.FindIntersection(angle.ray1, out pt1, out pt2);
            endpt1 = pt1.StructurallyEquals(angle.GetVertex()) ? pt2 : pt1;

            circle.FindIntersection(angle.ray2, out pt1, out pt2);
            endpt2 = pt1.StructurallyEquals(angle.GetVertex()) ? pt2 : pt1;

            // Need to check if the angle is a diameter and create a semicircle
            Segment chord = new Segment(endpt1, endpt2);

            if (circle.DefinesDiameter(chord))
            {
                Point      opp  = circle.Midpoint(endpt1, endpt2, angle.GetVertex());
                Semicircle semi = new Semicircle(circle, endpt1, endpt2, circle.OppositePoint(opp), chord);
                //Find a defined semicircle of the figure that lies on the same side
                Semicircle sameSideSemi = figureSemicircles.Where(s => semi.SameSideSemicircle(s)).FirstOrDefault();
                //If none were found, should we throw an exception or just return the original semi?
                if (sameSideSemi == null)
                {
                    return(semi);
                }
                else
                {
                    return(sameSideSemi);
                }
            }

            //Initially assume intercepted arc is the minor arc
            Arc intercepted = null;

            intercepted = new MinorArc(circle, endpt1, endpt2);
            //Verify assumption, create major arc if necessary
            if (Arc.BetweenMinor(angle.GetVertex(), intercepted))
            {
                intercepted = new MajorArc(circle, endpt1, endpt2);
            }
            return(intercepted);
        }
Exemple #6
0
        private List<AtomicRegion> CreateSectors(Circle circle, Point pt1, Point pt2)
        {
            List<AtomicRegion> atoms = new List<AtomicRegion>();

            Segment diameter = new Segment(pt1, pt2);
            if (circle.DefinesDiameter(diameter))
            {
                Point midpt = circle.Midpoint(pt1, pt2);
                atoms.Add(new ShapeAtomicRegion(new Sector(new Semicircle(circle, pt1, pt2, midpt, diameter))));
                atoms.Add(new ShapeAtomicRegion(new Sector(new Semicircle(circle, pt1, pt2, circle.OppositePoint(midpt), diameter))));
            }
            else
            {
                atoms.Add(new ShapeAtomicRegion(new Sector(new MinorArc(circle, pt1, pt2))));
                atoms.Add(new ShapeAtomicRegion(new Sector(new MajorArc(circle, pt1, pt2))));
            }

            return atoms;
        }
Exemple #7
0
        private static Arc GetInscribedInterceptedArc(Circle circle, Angle angle)
        {
            Point endpt1, endpt2;

            Point pt1, pt2;
            circle.FindIntersection(angle.ray1, out pt1, out pt2);
            endpt1 = pt1.StructurallyEquals(angle.GetVertex()) ? pt2 : pt1;

            circle.FindIntersection(angle.ray2, out pt1, out pt2);
            endpt2 = pt1.StructurallyEquals(angle.GetVertex()) ? pt2 : pt1;

            // Need to check if the angle is a diameter and create a semicircle
            Segment chord = new Segment(endpt1, endpt2);
            if (circle.DefinesDiameter(chord))
            {
                Point opp = circle.Midpoint(endpt1, endpt2, angle.GetVertex());
                Semicircle semi = new Semicircle(circle, endpt1, endpt2, circle.OppositePoint(opp), chord);
                //Find a defined semicircle of the figure that lies on the same side
                Semicircle sameSideSemi = figureSemicircles.Where(s => semi.SameSideSemicircle(s)).FirstOrDefault();
                //If none were found, should we throw an exception or just return the original semi?
                if (sameSideSemi == null) return semi;
                else return sameSideSemi;
            }

            //Initially assume intercepted arc is the minor arc
            Arc intercepted = null;
            intercepted = new MinorArc(circle, endpt1, endpt2);
            //Verify assumption, create major arc if necessary
            if (Arc.BetweenMinor(angle.GetVertex(), intercepted)) intercepted = new MajorArc(circle, endpt1, endpt2);
            return intercepted;
        }
        //
        // Detect diameters and generate all of the Semicircle Arc and ArcInMiddle clauses
        //
        private void GenerateSemicircleClauses(Circle circle)
        {
            if (circle.pointsOnCircle.Count == 2)
            {
                Segment diameter = new Segment(circle.pointsOnCircle[0], circle.pointsOnCircle[1]);

                if (circle.DefinesDiameter(diameter))
                {
                    Point midpt = circle.Midpoint(diameter.Point1, diameter.Point2);
                    Point opp = circle.OppositePoint(midpt);

                    AddSemicircleClauses(new Semicircle(circle, diameter.Point1, diameter.Point2, midpt, diameter));
                    AddSemicircleClauses(new Semicircle(circle, diameter.Point1, diameter.Point2, opp, diameter));
                }
            }

            for (int p1 = 0; p1 < circle.pointsOnCircle.Count - 1; p1++)
            {
                for (int p2 = p1 + 1; p2 < circle.pointsOnCircle.Count; p2++)
                {
                    Segment diameter = new Segment(circle.pointsOnCircle[p1], circle.pointsOnCircle[p2]);

                    if (circle.DefinesDiameter(diameter))
                    {
                        //Get the endpoints of the diameter and the indices of these endpoints
                        Point e1 = diameter.Point1;
                        Point e2 = diameter.Point2;
                        //int p1 = circle.pointsOnCircle.IndexOf(e1);
                        //int p2 = circle.pointsOnCircle.IndexOf(e2);

                        ////For partitioning purposes, order of the endpoints matters. Make sure p1 holds the lower of the two indices
                        //if (p1 > p2)
                        //{
                        //    int p3 = p1;
                        //    p1 = p2;
                        //    p2 = p3;
                        //}

                        // Partition the remaining points on the circle
                        List<Point> minorArcPoints;
                        List<Point> majorArcPoints;
                        PartitionSemiCircleArcPoints(circle.pointsOnCircle, p1, p2, out minorArcPoints, out majorArcPoints);

                        // Semicircle requires 3 points to be defined - the two endpoints and a point inbetween
                        // The minorArcPoints and majorArcPoints lists contain all the potential inbetween points for either side of the diameter
                        // Handle 'side' 1:
                        // If majorArcPoints is empty, create an implied semicircle (minorArcPoints should be guaranteed to have at least one point, since
                        // the case of having only 2 points on the circle was already handled)
                        if (majorArcPoints.Count == 0 && minorArcPoints.Count != 0)
                            AddSemicircleClauses(CreateImpliedSemicircle(circle, diameter, minorArcPoints[0]));
                        else
                            for (int i = 0; i < majorArcPoints.Count; ++i)
                            {
                                Semicircle semi = new Semicircle(circle, e1, e2, majorArcPoints[i], minorArcPoints, majorArcPoints, diameter);
                                AddSemicircleClauses(semi);
                            }
                        // Handle 'side' 2:
                        if (minorArcPoints.Count == 0 && majorArcPoints.Count != 0)
                            AddSemicircleClauses(CreateImpliedSemicircle(circle, diameter, majorArcPoints[0]));
                        else
                            for (int i = 0; i < minorArcPoints.Count; ++i)
                            {
                                Semicircle semi = new Semicircle(circle, e1, e2, minorArcPoints[i], majorArcPoints, minorArcPoints, diameter);
                                AddSemicircleClauses(semi);
                            }

                    }
                }
            }
        }
 //
 // Generate all of the Major/Minor Arc and ArcInMiddle clauses; similar to generating for collinear points on segments.
 //
 private void GenerateArcClauses(Circle circle)
 {
     //
     // Generate all Arc objects with their minor / major arc points; also generate ArcInMiddle clauses.
     //
     for (int p1 = 0; p1 < circle.pointsOnCircle.Count - 1; p1++)
     {
         for (int p2 = p1 + 1; p2 < circle.pointsOnCircle.Count; p2++)
         {
             // Do these endpoints form a diameter? If so, the semicircle arcs should have already been handled by GenerateSemicircleClauses()
             Segment seg = new Segment(circle.pointsOnCircle[p1], circle.pointsOnCircle[p2]);
             if (!circle.DefinesDiameter(seg)) CreateMajorMinorArcs(circle, p1, p2);
         }
     }
 }
Exemple #10
0
        // Construct the region between a chord and the circle arc:
        //    (|
        //   ( |
        //  (  |
        //   ( |
        //    (|
        //
        private List<AtomicRegion> ConstructBasicLineCircleRegion(Segment chord, Circle circle)
        {
            //
            // Standard
            //
            if (!circle.DefinesDiameter(chord))
            {
                AtomicRegion region = new AtomicRegion();

                Arc theArc = new MinorArc(circle, chord.Point1, chord.Point2);

                region.AddConnection(chord.Point1, chord.Point2, ConnectionType.ARC, theArc);

                region.AddConnection(chord.Point1, chord.Point2, ConnectionType.SEGMENT, chord);

                return Utilities.MakeList<AtomicRegion>(region);
            }

            //
            // Semi-circles
            //

            Point midpt = circle.Midpoint(chord.Point1, chord.Point2);
            Arc semi1 = new Semicircle(circle, chord.Point1, chord.Point2, midpt, chord);
            ShapeAtomicRegion region1 = new ShapeAtomicRegion(new Sector(semi1));

            Point opp = circle.OppositePoint(midpt);
            Arc semi2 = new Semicircle(circle, chord.Point1, chord.Point2, opp, chord);
            ShapeAtomicRegion region2 = new ShapeAtomicRegion(new Sector(semi2));

            List<AtomicRegion> regions = new List<AtomicRegion>();
            regions.Add(region1);
            regions.Add(region2);

            return regions;
        }
Exemple #11
0
        // Construct the region between a circle and circle:
        //     __
        //    ( (
        //   ( (
        //  ( (
        //   ( (
        //    ( (
        //     --
        private Atomizer.AtomicRegion ConstructBasicCircleCircleRegion(Segment chord, Circle smaller, Circle larger)
        {
            AtomicRegion region = new AtomicRegion();

            Arc arc1 = null;
            if (smaller.DefinesDiameter(chord))
            {
                Point midpt = smaller.Midpoint(chord.Point1, chord.Point2, larger.Midpoint(chord.Point1, chord.Point2));

                arc1 = new Semicircle(smaller, chord.Point1, chord.Point2, midpt, chord);
            }
            else
            {
                arc1 = new MinorArc(smaller, chord.Point1, chord.Point2);
            }

            MinorArc arc2 = new MinorArc(larger, chord.Point1, chord.Point2);

            region.AddConnection(chord.Point1, chord.Point2, ConnectionType.ARC, arc1);

            region.AddConnection(chord.Point1, chord.Point2, ConnectionType.ARC, arc2);

            return region;
        }
Exemple #12
0
        private Circle CheckCircleCutInsidePolygon(Polygon poly, Circle circle, Point pt1, Point pt2)
        {
            Segment diameter = new Segment(pt1, pt2);

            // A semicircle always cuts into the polygon.
            if (circle.DefinesDiameter(diameter)) return circle;
            else
            {
                // Is the midpoint on the interior of the polygon?
                Point midpt = circle.Midpoint(pt1, pt2);

                // Is this point in the interior of this polygon?
                if (poly.IsInPolygon(midpt)) return circle;
            }

            return null;
        }