Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public override bool Equals(Object obj)
        {
            EquilateralTriangle triangle = obj as EquilateralTriangle;

            if (triangle == null)
            {
                return(false);
            }
            return(base.Equals(obj));
        }
        //
        // Generate the three pairs of congruent segments.
        //
        private static List<EdgeAggregator> InstantiateFromDefinition(EquilateralTriangle tri, GroundedClause original)
        {
            List<EdgeAggregator> newGrounded = new List<EdgeAggregator>();

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

            //
            // Create the 3 sets of congruent segments.
            //
            for (int s = 0; s < tri.orderedSides.Count; s++)
            {
                GeometricCongruentSegments gcs = new GeometricCongruentSegments(tri.orderedSides[s], tri.orderedSides[(s+1) % tri.orderedSides.Count]);

                newGrounded.Add(new EdgeAggregator(antecedent, gcs, annotation));
            }

            //
            // Create the 3 congruent angles.
            //
            for (int a = 0; a < tri.angles.Count; a++)
            {
                GeometricCongruentAngles gcas = new GeometricCongruentAngles(tri.angles[a], tri.angles[(a + 1) % tri.angles.Count]);

                newGrounded.Add(new EdgeAggregator(antecedent, gcas, annotation));
            }

            //
            // Create the 3 equations for the measure of each angle being 60 degrees.
            //
            for (int a = 0; a < tri.angles.Count; a++)
            {
                GeometricAngleEquation gae = new GeometricAngleEquation(tri.angles[a], new NumericValue(60));

                newGrounded.Add(new EdgeAggregator(antecedent, gae, annotation));
            }

            return newGrounded;
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Figure out which triangles we can choose from before the window is shown.
        /// </summary>
        protected override void OnShow()
        {
            List<GroundedClause> givens = new List<GroundedClause>();
            //Populate list with applicable givens
            foreach (GroundedClause gc in currentGivens)
            {
                EquilateralTriangle et = gc as EquilateralTriangle;
                if (et != null)
                {
                    givens.Add(et);
                }
            }

            List<Triangle> equiTriangles = new List<Triangle>();
            //Populate list with possible choices
            foreach (Triangle t in parser.backendParser.implied.polygons[GeometryTutorLib.ConcreteAST.Polygon.TRIANGLE_INDEX])
            {
                if (isEquilateral(t))
                {
                    EquilateralTriangle et = new EquilateralTriangle(t);
                    if (!StructurallyContains(givens, et))
                    {
                        equiTriangles.Add(et);
                    }
                }
            }

            options.ItemsSource = null; //Makes sure the box is graphically updated.
            options.ItemsSource = equiTriangles;
        }