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)); }
public static new 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 rhombi that don't match the outer shape. if (quad.VerifyRhombus() && !quad.HasSamePoints(outerShape as Polygon)) { Rhombus rhombus = new Rhombus(quad); SubtractionSynth subSynth = new SubtractionSynth(outerShape, rhombus); try { subSynth.SetOpenRegions(FigSynthProblem.AcquireOpenAtomicRegions(conns, rhombus.points, rhombus)); composed.Add(subSynth); } catch (Exception) { } } } return FigSynthProblem.RemoveSymmetric(composed); }
public static new 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> 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) { // 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)); }
// // Outer minus circle; the circle will only be situation if it touches all sides of the outer figure. // public static List <FigSynthProblem> SubtractShape(Figure outerShape, List <Connection> conns, List <Point> points) { List <FigSynthProblem> composed = new List <FigSynthProblem>(); List <Midpoint> midpoints = outerShape.GetMidpointClauses(); if (midpoints.Count < 3) { return(composed); } // // Construct the circle based on the first 3 points. // Circle circ = Circle.ConstructCircle(midpoints[0].point, midpoints[1].point, midpoints[2].point); // // Verify that the remaining points lie on the circle. // for (int p = 4; p < midpoints.Count; p++) { if (!circ.PointLiesOn(midpoints[p].point)) { return(composed); } } SubtractionSynth subSynth = new SubtractionSynth(outerShape, circ); composed.Add(subSynth); return(composed); }
public static new 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 override FigSynthProblem Copy() { SubtractionSynth copy = new SubtractionSynth(this.leftProblem.Copy(), this.rightProblem.Copy()); copy.SetOpenRegions(new List <AtomicRegion>(this.openRegions)); return(copy); }
// // A symmetric scenario is one in which: // 1) The inner shapes are congruent // 2) The remaining atomic regions match 1-1. // public override bool IsSymmetricTo(FigSynthProblem that) { SubtractionSynth subSynth = that as SubtractionSynth; if (subSynth == null) { return(false); } // The atomic regions have to match 1-1 and onto. return(base.IsSymmetricTo(that)); }
// // Append subtraction to this current problem; the subtraction occurs within the inner figure (shape). // public static FigSynthProblem AppendFigureSubtraction(FigSynthProblem that, FigSynthProblem toAppend) { BinarySynthOperation binaryAppend = toAppend as BinarySynthOperation; if (binaryAppend == null) { return(null); } if (that is SubtractionSynth) { // Verify that the outer part of toAppend is a figure in this problem. Figure theShape = (binaryAppend.leftProblem as UnarySynth).figure; FigSynthProblem leftShapeProblem = that.GetSynthByShape(theShape); if (leftShapeProblem == null) { throw new ArgumentException("Shape is not in the given problem: " + theShape); } // // Create the new subtraction node and insert it into the copy. // // Since the 'left' expression was a shape, the 'right' is the actual shape we are appending. SubtractionSynth newSub = new SubtractionSynth(leftShapeProblem, binaryAppend.rightProblem); return(that.Copy().ReplaceUnary(theShape, newSub)); } else if (that is AdditionSynth) { // Verify that the external form of that matches with the LHS of toAppend. Polygon outerPoly = Polygon.MakePolygon(that.GetExteriorSegments()); if (!outerPoly.StructurallyEquals((binaryAppend.leftProblem as UnarySynth).figure)) { throw new ArgumentException("Exterior polygons do not match: " + (binaryAppend.leftProblem as UnarySynth).figure); } // Make a copy of that. return(new SubtractionSynth(that.Copy(), (binaryAppend.rightProblem as UnarySynth).figure)); } else { throw new ArgumentException("Expected Addition or Subtraction; acquired neither."); } }
// // Append subtraction to this current problem; the subtraction occurs within one of the open atomic regions. // public static FigSynthProblem AppendAtomicSubtraction(FigSynthProblem that, FigSynthProblem toAppend) { BinarySynthOperation binaryAppend = toAppend as BinarySynthOperation; if (binaryAppend == null) { return(null); } // Verify that the outer part of toAppend is an open atomic region. if (!that.openRegions.Contains(new ShapeAtomicRegion((binaryAppend.leftProblem as UnarySynth).figure))) { throw new ArgumentException("Shape is not an open atomic region: " + (binaryAppend.leftProblem as UnarySynth).figure); } // Since the 'left' expression was an open region, the 'right' is the actual shape we are appending. SubtractionSynth newSub = new SubtractionSynth(that.Copy(), binaryAppend.rightProblem); // Update the open regions to the inner-most shape. newSub.SetOpenRegions(toAppend.openRegions); return(newSub); }
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 static new 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 static new 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); }
// // Append subtraction to this current problem; the subtraction occurs within the inner figure (shape). // public static FigSynthProblem AppendFigureSubtraction(FigSynthProblem that, FigSynthProblem toAppend) { BinarySynthOperation binaryAppend = toAppend as BinarySynthOperation; if (binaryAppend == null) return null; if (that is SubtractionSynth) { // Verify that the outer part of toAppend is a figure in this problem. Figure theShape = (binaryAppend.leftProblem as UnarySynth).figure; FigSynthProblem leftShapeProblem = that.GetSynthByShape(theShape); if (leftShapeProblem == null) { throw new ArgumentException("Shape is not in the given problem: " + theShape); } // // Create the new subtraction node and insert it into the copy. // // Since the 'left' expression was a shape, the 'right' is the actual shape we are appending. SubtractionSynth newSub = new SubtractionSynth(leftShapeProblem, binaryAppend.rightProblem); return that.Copy().ReplaceUnary(theShape, newSub); } else if (that is AdditionSynth) { // Verify that the external form of that matches with the LHS of toAppend. Polygon outerPoly = Polygon.MakePolygon(that.GetExteriorSegments()); if (!outerPoly.StructurallyEquals((binaryAppend.leftProblem as UnarySynth).figure)) { throw new ArgumentException("Exterior polygons do not match: " + (binaryAppend.leftProblem as UnarySynth).figure); } // Make a copy of that. return new SubtractionSynth(that.Copy(), (binaryAppend.rightProblem as UnarySynth).figure); } else throw new ArgumentException("Expected Addition or Subtraction; acquired neither."); }
// // Outer minus circle; the circle will only be situation if it touches all sides of the outer figure. // public static List<FigSynthProblem> SubtractShape(Figure outerShape, List<Connection> conns, List<Point> points) { List<FigSynthProblem> composed = new List<FigSynthProblem>(); List<Midpoint> midpoints = outerShape.GetMidpointClauses(); if (midpoints.Count < 3) return composed; // // Construct the circle based on the first 3 points. // Circle circ = Circle.ConstructCircle(midpoints[0].point, midpoints[1].point, midpoints[2].point); // // Verify that the remaining points lie on the circle. // for (int p = 4; p < midpoints.Count; p++) { if (!circ.PointLiesOn(midpoints[p].point)) return composed; } SubtractionSynth subSynth = new SubtractionSynth(outerShape, circ); composed.Add(subSynth); return composed; }
// // Append subtraction to this current problem; the subtraction occurs within one of the open atomic regions. // public static FigSynthProblem AppendAtomicSubtraction(FigSynthProblem that, FigSynthProblem toAppend) { BinarySynthOperation binaryAppend = toAppend as BinarySynthOperation; if (binaryAppend == null) return null; // Verify that the outer part of toAppend is an open atomic region. if (!that.openRegions.Contains(new ShapeAtomicRegion((binaryAppend.leftProblem as UnarySynth).figure))) { throw new ArgumentException("Shape is not an open atomic region: " + (binaryAppend.leftProblem as UnarySynth).figure); } // Since the 'left' expression was an open region, the 'right' is the actual shape we are appending. SubtractionSynth newSub = new SubtractionSynth(that.Copy(), binaryAppend.rightProblem); // Update the open regions to the inner-most shape. newSub.SetOpenRegions(toAppend.openRegions); return newSub; }
public override FigSynthProblem Copy() { SubtractionSynth copy = new SubtractionSynth(this.leftProblem.Copy(), this.rightProblem.Copy()); copy.SetOpenRegions(new List<AtomicRegion>(this.openRegions)); return copy; }