private void CreateMajorMinorArcs(Circle circle, int p1, int p2) { List<Point> minorArcPoints; List<Point> majorArcPoints; PartitionArcPoints(circle, p1, p2, out minorArcPoints, out majorArcPoints); MinorArc newMinorArc = new MinorArc(circle, circle.pointsOnCircle[p1], circle.pointsOnCircle[p2], minorArcPoints, majorArcPoints); MajorArc newMajorArc = new MajorArc(circle, circle.pointsOnCircle[p1], circle.pointsOnCircle[p2], minorArcPoints, majorArcPoints); Sector newMinorSector = new Sector(newMinorArc); Sector newMajorSector = new Sector(newMajorArc); if (!GeometryTutorLib.Utilities.HasStructurally<MinorArc>(minorArcs, newMinorArc)) { minorArcs.Add(newMinorArc); minorSectors.Add(newMinorSector); majorSectors.Add(newMajorSector); angles.Add(new Angle(circle.pointsOnCircle[p1], circle.center, circle.pointsOnCircle[p2])); } if (!GeometryTutorLib.Utilities.HasStructurally<MajorArc>(majorArcs, newMajorArc)) { majorArcs.Add(newMajorArc); majorSectors.Add(newMajorSector); } circle.AddMinorArc(newMinorArc); circle.AddMajorArc(newMajorArc); circle.AddMinorSector(newMinorSector); circle.AddMajorSector(newMajorSector); // Generate ArcInMiddle clauses for minor arc and major arc for (int imIndex = 0; imIndex < newMinorArc.arcMinorPoints.Count; imIndex++) { GeometryTutorLib.Utilities.AddStructurallyUnique<ArcInMiddle>(arcInMiddle, new ArcInMiddle(newMinorArc.arcMinorPoints[imIndex], newMinorArc)); } for (int imIndex = 0; imIndex < newMajorArc.arcMajorPoints.Count; imIndex++) { GeometryTutorLib.Utilities.AddStructurallyUnique<ArcInMiddle>(arcInMiddle, new ArcInMiddle(newMajorArc.arcMajorPoints[imIndex], newMajorArc)); } }
public void AddMajorSector(Sector mSector) { majorSectors.Add(mSector); }
public void AddMinorSector(Sector mSector) { minorSectors.Add(mSector); }
// // that Polygon lies within this circle. // private bool ContainsSector(Sector that) { if (!this.PointLiesInOrOn(that.theArc.endpoint1)) return false; if (!this.PointLiesInOrOn(that.theArc.endpoint2)) return false; if (!this.PointLiesInOrOn(that.theArc.theCircle.center)) return false; if (!this.PointLiesInOrOn(that.theArc.Midpoint())) return false; return true; }
// // that Polygon lies within this circle. // private bool ContainsSector(Sector that) { if (!this.PointLiesInOrOn(that.theArc.endpoint1)) return false; if (!this.PointLiesInOrOn(that.theArc.endpoint2)) return false; if (!this.PointLiesInOrOn(that.theArc.theCircle.center)) return false; if (that.theArc is Semicircle) { Semicircle semi = that.theArc as Semicircle; if (!this.PointLiesInOrOn(semi.middlePoint)) return false; if (!this.PointLiesInOrOn(semi.theCircle.Midpoint(semi.endpoint1, semi.middlePoint))) return false; if (!this.PointLiesInOrOn(semi.theCircle.Midpoint(semi.endpoint2, semi.middlePoint))) return false; } else { if (!this.PointLiesInOrOn(that.theArc.Midpoint())) return false; } // Check all point approximations for containment. //List<Point> approx = that.GetFigureAsAtomicRegion().GetVertices(); //foreach (Point pt in approx) //{ // if (!this.PointLiesInOrOn(pt)) return false; //} return true; }
// // that Sector lies within this sector // private bool ContainsSector(Sector that) { if (this.StructurallyEquals(that)) return true; // // Is this sector from the same circle as that sector? // if (this.theArc.theCircle.StructurallyEquals(that.theArc.theCircle)) { foreach (Point pt in that.theArc.GetApproximatingPoints()) { if (!this.PointLiesInOrOn(pt)) return false; } return true; } // this radius must be longer than that. if (Utilities.GreaterThan(that.theArc.theCircle.radius, this.theArc.theCircle.radius)) return false; // // Check containment of the points of that sector. // if (!this.PointLiesInOrOn(that.theArc.endpoint1)) return false; if (!this.PointLiesInOrOn(that.theArc.endpoint2)) return false; if (!this.PointLiesInOrOn(that.theArc.theCircle.center)) return false; // Check midpoint is also within the sector. if (!this.PointLiesInOrOn(that.theArc.Midpoint())) return false; return true; }
private List<Atomizer.AtomicRegion> ConvertToSemicircle(Segment diameter, Semicircle semi) { // Verification Step 2. if (!diameter.PointLiesOnAndExactlyBetweenEndpoints(semi.theCircle.center)) { throw new Exception("Semicircle: expected center between endpoints."); } Sector sector = new Sector(semi); return Utilities.MakeList<AtomicRegion>(new ShapeAtomicRegion(sector)); }
private List<Atomizer.AtomicRegion> ConvertToGeneralSector(List<Segment> sideSet1, List<Segment> sideSet2, List<MinorArc> arcs) { Segment side1 = ComposeSegmentsIntoSegment(sideSet1); Segment side2 = ComposeSegmentsIntoSegment(sideSet2); Arc theArc = ComposeArcsIntoArc(arcs); // // Verify that both sides of the sector contains the center. // And many other tests to ensure proper sector acquisition. // if (!side1.HasPoint(theArc.theCircle.center)) return null; if (!side2.HasPoint(theArc.theCircle.center)) return null; Point sharedCenter = side1.SharedVertex(side2); if (sharedCenter == null) { throw new Exception("Sides do not share a vertex as expected; they share " + sharedCenter); } if (!sharedCenter.StructurallyEquals(theArc.theCircle.center)) { throw new Exception("Center and deduced center do not equate: " + sharedCenter + " " + theArc.theCircle.center); } Point segEndpoint1 = side1.OtherPoint(sharedCenter); Point segEndpoint2 = side2.OtherPoint(sharedCenter); if (!theArc.HasEndpoint(segEndpoint1) || !theArc.HasEndpoint(segEndpoint2)) { throw new Exception("Side endpoints do not equate to the arc endpoints"); } // Satisfied constraints, create the actual sector. Sector sector = new Sector(theArc); return Utilities.MakeList<AtomicRegion>(new ShapeAtomicRegion(sector)); }