Ejemplo n.º 1
0
        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);
        }
        private static List<EdgeAggregator> InstantiateToTheorem(Rhombus rhombus, GroundedClause original)
        {
            List<EdgeAggregator> newGrounded = new List<EdgeAggregator>();

            // For hypergraph
            List<GroundedClause> antecedent = Utilities.MakeList<GroundedClause>(original);

            // Instantiate this rhombus diagonals ONLY if the original figure has the diagonals drawn.
            if (rhombus.TopLeftDiagonalIsValid())
            {
                AngleBisector ab1 = new AngleBisector(rhombus.topLeftAngle, rhombus.topLeftBottomRightDiagonal);
                AngleBisector ab2 = new AngleBisector(rhombus.bottomRightAngle, rhombus.topLeftBottomRightDiagonal);
                newGrounded.Add(new EdgeAggregator(antecedent, ab1, annotation));
                newGrounded.Add(new EdgeAggregator(antecedent, ab2, annotation));
            }

            if (rhombus.BottomRightDiagonalIsValid())
            {
                AngleBisector ab1 = new AngleBisector(rhombus.topRightAngle, rhombus.bottomLeftTopRightDiagonal);
                AngleBisector ab2 = new AngleBisector(rhombus.bottomLeftAngle, rhombus.bottomLeftTopRightDiagonal);
                newGrounded.Add(new EdgeAggregator(antecedent, ab1, annotation));
                newGrounded.Add(new EdgeAggregator(antecedent, ab2, annotation));
            }

            return newGrounded;
        }
Ejemplo n.º 3
0
        public static Figure ConstructDefaultShape(ShapeType type)
        {
            switch (type)
            {
            case ShapeType.TRIANGLE:               return(Triangle.ConstructDefaultTriangle());

            case ShapeType.ISOSCELES_TRIANGLE:     return(IsoscelesTriangle.ConstructDefaultIsoscelesTriangle());

            case ShapeType.RIGHT_TRIANGLE:         return(RightTriangle.ConstructDefaultRightTriangle());

            case ShapeType.EQUILATERAL_TRIANGLE:   return(EquilateralTriangle.ConstructDefaultEquilateralTriangle());

            case ShapeType.KITE:                   return(Kite.ConstructDefaultKite());

            case ShapeType.QUADRILATERAL:          return(Quadrilateral.ConstructDefaultQuadrilateral());

            case ShapeType.TRAPEZOID:              return(Trapezoid.ConstructDefaultTrapezoid());

            case ShapeType.ISO_TRAPEZOID:          return(IsoscelesTrapezoid.ConstructDefaultIsoscelesTrapezoid());

            case ShapeType.PARALLELOGRAM:          return(Parallelogram.ConstructDefaultParallelogram());

            case ShapeType.RECTANGLE:              return(Rectangle.ConstructDefaultRectangle());

            case ShapeType.RHOMBUS:                return(Rhombus.ConstructDefaultRhombus());

            case ShapeType.SQUARE:                 return(Square.ConstructDefaultSquare());

            case ShapeType.CIRCLE:                 return(Circle.ConstructDefaultCircle());

            case ShapeType.SECTOR:                 return(Sector.ConstructDefaultSector());
            }

            return(null);
        }
Ejemplo n.º 4
0
        public override bool StructurallyEquals(Object obj)
        {
            Rhombus thatRhom = obj as Rhombus;

            if (thatRhom == null)
            {
                return(false);
            }

            if (thatRhom is Square)
            {
                return(false);
            }

            //return base.StructurallyEquals(obj);
            return(base.HasSamePoints(obj as Quadrilateral));
        }
        private static List<EdgeAggregator> InstantiateToTheorem(Rhombus rhombus, GroundedClause original)
        {
            List<EdgeAggregator> newGrounded = new List<EdgeAggregator>();

            // Instantiate this rhombus diagonals ONLY if the original figure has the diagonals drawn.
            if (rhombus.diagonalIntersection == null) return newGrounded;

            // Determine the CongruentSegments opposing sides and output that.
            Strengthened newPerpendicular = new Strengthened(rhombus.diagonalIntersection, new Perpendicular(rhombus.diagonalIntersection));

            // For hypergraph
            List<GroundedClause> antecedent = new List<GroundedClause>();
            antecedent.Add(original);

            newGrounded.Add(new EdgeAggregator(antecedent, newPerpendicular, annotation));

            return newGrounded;
        }
Ejemplo n.º 6
0
        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 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));
        }
Ejemplo n.º 7
0
        private static List<EdgeAggregator> InstantiateFromRhombus(Rhombus rhombus, GroundedClause original)
        {
            List<EdgeAggregator> newGrounded = new List<EdgeAggregator>();

            // For hypergraph
            List<GroundedClause> antecedent = new List<GroundedClause>();
            antecedent.Add(original);

            // Determine the CongruentSegments : 4 Choose 2
            newGrounded.Add(new EdgeAggregator(antecedent, new GeometricCongruentSegments(rhombus.top, rhombus.bottom), annotation));
            newGrounded.Add(new EdgeAggregator(antecedent, new GeometricCongruentSegments(rhombus.top, rhombus.left), annotation));
            newGrounded.Add(new EdgeAggregator(antecedent, new GeometricCongruentSegments(rhombus.top, rhombus.right), annotation));
            newGrounded.Add(new EdgeAggregator(antecedent, new GeometricCongruentSegments(rhombus.bottom, rhombus.left), annotation));
            newGrounded.Add(new EdgeAggregator(antecedent, new GeometricCongruentSegments(rhombus.bottom, rhombus.right), annotation));
            newGrounded.Add(new EdgeAggregator(antecedent, new GeometricCongruentSegments(rhombus.left, rhombus.right), annotation));

            return newGrounded;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Parse a regular polygon. (Currently only equilateral triangles)
        /// </summary>
        /// <param name="rgon">The regular polygon to parse.</param>
        private void ParseRegularPolygon(RegularPolygon rgon)
        {
            // Acquire the implicit center of the regular polygon
            IPoint center = rgon.Dependencies.FindPoint(rgon.Center, 0);
            IPoint vertex = rgon.Dependencies.FindPoint(rgon.Vertex, 0);

            int numSides = rgon.NumberOfSides;
            //
            // Genereate vertex points knowing that the polygon is regular
            //
            IPoint[] pts = new IPoint[numSides];

            double radius = Math.Distance(vertex.Coordinates.X, center.Coordinates.X, vertex.Coordinates.Y, center.Coordinates.Y);
            double initAngle = Math.GetAngle(new System.Windows.Point(center.Coordinates.X, center.Coordinates.Y),
                                             new System.Windows.Point(vertex.Coordinates.X, vertex.Coordinates.Y));
            double increment = Math.DOUBLEPI / numSides;
            // Vertex point generation and parsing.
            for (int i = 0; i < numSides - 1; i++)
            {
                double angle = initAngle + (i + 1) * increment;
                double X = center.Coordinates.X + radius * System.Math.Cos(angle);
                double Y = center.Coordinates.Y + radius * System.Math.Sin(angle);
                System.Windows.Point newPt = new System.Windows.Point(X, Y);
                pts[i] = rgon.Dependencies.FindPoint(newPt, 0);
                if (pts[i] == null) pts[i] = Factory.CreateFreePoint(drawing, newPt);
                Parse(pts[i] as IFigure);
            }
            pts[numSides - 1] = vertex;
            Parse(pts[numSides - 1] as IFigure);

            //
            // Generate sides from vertices
            //
            List<GeometryTutorLib.ConcreteAST.Segment> tutorSegments = new List<GeometryTutorLib.ConcreteAST.Segment>();
            for (int i = 0; i < numSides; i++)
            {
                int j = (i + 1) % 3;
                tutorSegments.Add(new GeometryTutorLib.ConcreteAST.Segment(uiToEngineMap[pts[i]] as Point, uiToEngineMap[pts[j]] as Point));
            }
            definedSegments.AddRange(tutorSegments);

            GeometryTutorLib.ConcreteAST.Polygon newPoly = null;
            switch(numSides)
            {
                case 3:
                    newPoly = new EquilateralTriangle(tutorSegments);
                    polygons[GeometryTutorLib.ConcreteAST.Polygon.TRIANGLE_INDEX].Add(newPoly);

                    break;
                case 4:
                    Quadrilateral newQuad = Quadrilateral.GenerateQuadrilateral(tutorSegments);
                    if (newQuad != null)
                    {
                        newPoly = new Rhombus(newQuad);
                        polygons[GeometryTutorLib.ConcreteAST.Polygon.QUADRILATERAL_INDEX].Add(newPoly);
                    }
                    break;
                case 5:
                case 6:
                case 7:
                case 8:
                case 9:
                case 10:
                    break;

                default:
                    break;
            }

            if (newPoly != null) uiToEngineMap.Add(rgon, newPoly);
        }
Ejemplo n.º 9
0
        private static List<EdgeAggregator> InstantiateToSquare(Rhombus rhombus, RightAngle ra, GroundedClause originalRhom, GroundedClause originalRightAngle)
        {
            List<EdgeAggregator> newGrounded = new List<EdgeAggregator>();

            // Does this right angle apply to this quadrilateral?
            if (!rhombus.HasAngle(ra)) return newGrounded;

            //
            // Create the new Square object
            //
            Strengthened newSquare = new Strengthened(rhombus, new Square(rhombus));

            // For hypergraph
            List<GroundedClause> antecedent = new List<GroundedClause>();
            antecedent.Add(originalRhom);
            antecedent.Add(originalRightAngle);

            newGrounded.Add(new EdgeAggregator(antecedent, newSquare, annotation));

            return newGrounded;
        }