// // With appending in this case, we choose the given segment to be the base. // public new static List <FigSynthProblem> AppendShape(Figure outerShape, List <Segment> segments) { List <FigSynthProblem> composed = new List <FigSynthProblem>(); // // Construct the triangles. // foreach (Segment seg in segments) { List <Triangle> tris; IsoscelesTriangle.MakeIsoscelesTriangles(seg, seg.Length, out tris); foreach (Triangle t in tris) { FigSynthProblem prob = Figure.MakeAdditionProblem(outerShape, t); if (prob != null) { composed.Add(prob); } } } return(FigSynthProblem.RemoveSymmetric(composed)); }
public new static List <FigSynthProblem> AppendShape(Figure outerShape, List <Segment> segments) { List <FigSynthProblem> composed = new List <FigSynthProblem>(); int length = Figure.DefaultSideLength(); int angle = Figure.DefaultFirstQuadrantNonRightAngle(); foreach (Segment seg in segments) { List <Triangle> tris; MakeTriangles(seg, length, angle, out tris); foreach (Triangle t in tris) { FigSynthProblem prob = Figure.MakeAdditionProblem(outerShape, t); if (prob != null) { composed.Add(prob); } } } return(FigSynthProblem.RemoveSymmetric(composed)); }
public new static List <FigSynthProblem> AppendShape(Figure outerShape, List <Segment> segments) { List <FigSynthProblem> composed = new List <FigSynthProblem>(); foreach (Segment seg in segments) { Rectangle rect1; Rectangle rect2; Rectangle.MakeRectangles(seg, seg.Length, out rect1, out rect2); Square sq1 = new Square(rect1); Square sq2 = new Square(rect2); FigSynthProblem prob = Figure.MakeAdditionProblem(outerShape, sq2); if (prob != null) { composed.Add(prob); } prob = Figure.MakeAdditionProblem(outerShape, sq2); if (prob != null) { composed.Add(prob); } } return(FigSynthProblem.RemoveSymmetric(composed)); }
public new static List <FigSynthProblem> SubtractShape(Figure outerShape, List <Connection> conns, List <Point> points) { // Possible quadrilaterals. List <Quadrilateral> quads = null; if (outerShape is ConcavePolygon) { quads = Quadrilateral.GetQuadrilateralsFromPoints(outerShape as ConcavePolygon, points); } else { quads = Quadrilateral.GetQuadrilateralsFromPoints(points); } List <FigSynthProblem> composed = new List <FigSynthProblem>(); foreach (Quadrilateral quad in quads) { // Select only isosceles trapezoids that don't match the outer shape. if (quad.VerifyIsoscelesTrapezoid() && !quad.HasSamePoints(outerShape as Polygon)) { IsoscelesTrapezoid isoTrap = new IsoscelesTrapezoid(quad); SubtractionSynth subSynth = new SubtractionSynth(outerShape, isoTrap); subSynth.SetOpenRegions(FigSynthProblem.AcquireOpenAtomicRegions(conns, isoTrap.points, isoTrap)); composed.Add(subSynth); } } return(FigSynthProblem.RemoveSymmetric(composed)); }
public new static List <FigSynthProblem> SubtractShape(Figure outerShape, List <Connection> conns, List <Point> points) { List <FigSynthProblem> composed = new List <FigSynthProblem>(); // Possible triangles. List <Triangle> tris = null; if (outerShape is ConcavePolygon) { tris = Triangle.GetTrianglesFromPoints(outerShape as ConcavePolygon, points); } else { tris = Triangle.GetTrianglesFromPoints(points); } // Check all triangles to determine applicability. foreach (Triangle tri in tris) { // Avoid equilateral, isosceles, and right triangles. if (!tri.IsEquilateral() && !tri.IsIsosceles() && !tri.isRightTriangle() && !tri.StructurallyEquals(outerShape)) { SubtractionSynth subSynth = new SubtractionSynth(outerShape, tri); try { subSynth.SetOpenRegions(FigSynthProblem.AcquireOpenAtomicRegions(conns, tri.points, tri)); composed.Add(subSynth); } catch (Exception) { } } } return(FigSynthProblem.RemoveSymmetric(composed)); }
public new static List <FigSynthProblem> SubtractShape(Figure outerShape, List <Connection> conns, List <Point> points) { // Possible quadrilaterals. List <Quadrilateral> quads = null; if (outerShape is ConcavePolygon) { quads = Quadrilateral.GetQuadrilateralsFromPoints(outerShape as ConcavePolygon, points); } else { quads = Quadrilateral.GetQuadrilateralsFromPoints(points); } List <FigSynthProblem> composed = new List <FigSynthProblem>(); foreach (Quadrilateral quad in quads) { // Select only rectangles that don't match the outer shape. if (quad.VerifyRectangle() && !quad.HasSamePoints(outerShape as Polygon)) { Rectangle rect = new Rectangle(quad); SubtractionSynth subSynth = new SubtractionSynth(outerShape, rect); try { subSynth.SetOpenRegions(FigSynthProblem.AcquireOpenAtomicRegions(conns, rect.points, rect)); composed.Add(subSynth); } catch (Exception) { } } } return(FigSynthProblem.RemoveSymmetric(composed)); }
public new static List <FigSynthProblem> SubtractShape(Figure outerShape, List <Connection> conns, List <Point> points) { List <Triangle> tris = Triangle.GetTrianglesFromPoints(points); List <FigSynthProblem> composed = new List <FigSynthProblem>(); foreach (Triangle tri in tris) { // Only create right triangles that are NOT the outershape. if (tri.isRightTriangle() && !tri.StructurallyEquals(outerShape)) { RightTriangle rTri = new RightTriangle(tri); SubtractionSynth subSynth = new SubtractionSynth(outerShape, rTri); try { subSynth.SetOpenRegions(FigSynthProblem.AcquireOpenAtomicRegions(conns, rTri.points, rTri)); composed.Add(subSynth); } catch (Exception) { } } } return(FigSynthProblem.RemoveSymmetric(composed)); }
// // With appending in this case, we choose the given segment to be the base. // public new static List <FigSynthProblem> AppendShape(Figure outerShape, List <Segment> segments) { List <FigSynthProblem> composed = new List <FigSynthProblem>(); // Acquire a set of lengths of the given segments. List <int> lengths = new List <int>(); segments.ForEach(s => Utilities.AddUnique <int>(lengths, (int)s.Length)); // // Acquire the length of the isosceles triangle so that it is longer than the half the distance of the segment. // int newLength = -1; for (newLength = Figure.DefaultSideLength(); ; newLength = Figure.DefaultSideLength()) { bool longEnough = true; foreach (Segment side in segments) { if (newLength < (side.Length / 2.0) + 1) { longEnough = false; break; } } if (longEnough) { break; } } // // Construct the triangles. // foreach (Segment seg in segments) { List <Triangle> tris; MakeIsoscelesTriangles(seg, newLength, out tris); foreach (Triangle t in tris) { FigSynthProblem prob = Figure.MakeAdditionProblem(outerShape, t); if (prob != null) { composed.Add(prob); } } } return(FigSynthProblem.RemoveSymmetric(composed)); }
public new static List <FigSynthProblem> AppendShape(Figure outerShape, List <Segment> segments) { // // Acquire a set of lengths of the given segments. // List <int> lengths = new List <int>(); segments.ForEach(s => Utilities.AddUnique <int>(lengths, (int)s.Length)); // Acquire the length of the rectangle so it is fixed among all appended shapes. // We avoid a square by looping. int newLength = -1; for (newLength = Figure.DefaultSideLength(); lengths.Contains(newLength); newLength = Figure.DefaultSideLength()) { ; } List <FigSynthProblem> composed = new List <FigSynthProblem>(); foreach (Segment seg in segments) { Rectangle rect1; Rectangle rect2; MakeRectangles(seg, newLength, out rect1, out rect2); FigSynthProblem prob = Figure.MakeAdditionProblem(outerShape, rect1); if (prob != null) { composed.Add(prob); } prob = Figure.MakeAdditionProblem(outerShape, rect2); if (prob != null) { composed.Add(prob); } } return(FigSynthProblem.RemoveSymmetric(composed)); }
// // Append parallelograms to appropriate segments. // public new static List <FigSynthProblem> AppendShape(Figure outerShape, List <Segment> segments) { // Acquire a set of lengths of the given segments. List <int> lengths = new List <int>(); segments.ForEach(s => Utilities.AddUnique <int>(lengths, (int)s.Length)); // Acquire the length of the rectangle so it is fixed among all appended shapes. // We avoid a rhombus by looping. int newLength = -1; for (newLength = Figure.DefaultSideLength(); lengths.Contains(newLength); newLength = Figure.DefaultSideLength()) { ; } int angle = Figure.DefaultFirstQuadrantNonRightAngle(); // Create the shapes. List <FigSynthProblem> composed = new List <FigSynthProblem>(); foreach (Segment seg in segments) { List <Parallelogram> parallelograms = new List <Parallelogram>(); parallelograms.AddRange(MakeParallelograms(seg, newLength, angle)); foreach (Parallelogram para in parallelograms) { FigSynthProblem prob = Figure.MakeAdditionProblem(outerShape, para); if (prob != null) { composed.Add(prob); } } } return(FigSynthProblem.RemoveSymmetric(composed)); }
public new static List <FigSynthProblem> SubtractShape(Figure outerShape, List <Connection> conns, List <Point> points) { // Possible triangles. List <Triangle> tris = null; if (outerShape is ConcavePolygon) { tris = Triangle.GetTrianglesFromPoints(outerShape as ConcavePolygon, points); } else { tris = Triangle.GetTrianglesFromPoints(points); } List <FigSynthProblem> composed = new List <FigSynthProblem>(); foreach (Triangle tri in tris) { // Select only parallelograms that don't match the outer shape. if (tri.IsEquilateral() && !tri.StructurallyEquals(outerShape)) { EquilateralTriangle eqTri = new EquilateralTriangle(tri); SubtractionSynth subSynth = new SubtractionSynth(outerShape, eqTri); try { subSynth.SetOpenRegions(FigSynthProblem.AcquireOpenAtomicRegions(conns, eqTri.points, eqTri)); composed.Add(subSynth); } catch (Exception) { } } } return(FigSynthProblem.RemoveSymmetric(composed)); }
public new static List <FigSynthProblem> AppendShape(Figure outerShape, List <Segment> segments) { List <FigSynthProblem> composed = new List <FigSynthProblem>(); // Acquire a set of lengths of the given segments. // List <int> lengths = new List <int>(); segments.ForEach(s => Utilities.AddUnique <int>(lengths, (int)s.Length)); // Acquire an isosceles triangle by looping. int newLength = -1; for (newLength = Figure.DefaultSideLength(); lengths.Contains(newLength); newLength = Figure.DefaultSideLength()) { ; } foreach (Segment seg in segments) { List <RightTriangle> tris; MakeRightTriangles(seg, newLength, out tris); foreach (RightTriangle rt in tris) { FigSynthProblem prob = Figure.MakeAdditionProblem(outerShape, rt); if (prob != null) { composed.Add(prob); } } } return(FigSynthProblem.RemoveSymmetric(composed)); }