Ejemplo n.º 1
0
        public static IsoscelesTrapezoid ConstructDefaultIsoscelesTrapezoid()
        {
            int base1 = Figure.DefaultSideLength();
            int side  = Figure.DefaultSideLength();

            // Ensure a smaller side then base for a 'normal' look.
            while (base1 <= side)
            {
                base1 = Figure.DefaultSideLength();
                side  = Figure.DefaultSideLength();
            }

            int   baseAngle = Figure.DefaultFirstQuadrantNonRightAngle();
            Point topLeft   = Figure.GetPointByLengthAndAngleInStandardPosition(side, baseAngle);

            topLeft = PointFactory.GeneratePoint(topLeft.X, topLeft.Y);

            Point topRight = Figure.GetPointByLengthAndAngleInThirdQuadrant(side, baseAngle);

            topRight = PointFactory.GeneratePoint(base1 + topRight.X, topRight.Y);

            Point bottomRight = PointFactory.GeneratePoint(base1, 0);

            Segment left   = new Segment(origin, topLeft);
            Segment top    = new Segment(topLeft, topRight);
            Segment right  = new Segment(topRight, bottomRight);
            Segment bottom = new Segment(bottomRight, origin);

            return(new IsoscelesTrapezoid(left, right, top, bottom));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        public static Rhombus ConstructDefaultRhombus()
        {
            int sideLength = Figure.DefaultSideLength();
            int baseAngle  = Figure.DefaultFirstQuadrantNonRightAngle();

            Point  topLeft = Figure.GetPointByLengthAndAngleInStandardPosition(sideLength, baseAngle);
            double offsetX = topLeft.X;
            double offsetY = topLeft.Y;

            topLeft = PointFactory.GeneratePoint(topLeft.X, topLeft.Y);
            Point topRight    = PointFactory.GeneratePoint(offsetX + sideLength, offsetY);
            Point bottomRight = PointFactory.GeneratePoint(sideLength, 0);

            Segment left   = new Segment(origin, topLeft);
            Segment top    = new Segment(topLeft, topRight);
            Segment right  = new Segment(topRight, bottomRight);
            Segment bottom = new Segment(bottomRight, origin);

            return(new Rhombus(left, right, top, bottom));
        }
Ejemplo n.º 4
0
        //
        // 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));
        }