Example #1
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));
        }
Example #2
0
        public static Trapezoid ConstructDefaultTrapezoid()
        {
            int smallBase = Figure.DefaultSideLength();
            int largeBase = Figure.DefaultSideLength();

            int height = Figure.DefaultSideLength();
            int offset = Figure.SmallIntegerValue();

            // Acquire a non-equal side.
            while (smallBase >= largeBase)
            {
                smallBase = Figure.DefaultSideLength();
                largeBase = Figure.DefaultSideLength();
            }

            Point topLeft     = PointFactory.GeneratePoint(offset, height);
            Point topRight    = PointFactory.GeneratePoint(offset + smallBase, height);
            Point bottomRight = PointFactory.GeneratePoint(largeBase, 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 Trapezoid(left, right, top, bottom));
        }
Example #3
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));
        }
Example #4
0
        //
        // 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));
        }
Example #5
0
        public static IsoscelesTriangle ConstructDefaultIsoscelesTriangle()
        {
            int baseLength = Figure.DefaultSideLength();
            int height     = Figure.DefaultSideLength();

            Point top         = PointFactory.GeneratePoint(baseLength / 2.0, height);
            Point bottomRight = PointFactory.GeneratePoint(baseLength, 0);

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

            return(new IsoscelesTriangle(left, right, bottom));
        }
Example #6
0
        public static RightTriangle ConstructDefaultRightTriangle()
        {
            int length = Figure.DefaultSideLength();
            int width  = Figure.DefaultSideLength();

            Point topLeft     = PointFactory.GeneratePoint(0, width);
            Point bottomRight = PointFactory.GeneratePoint(length, 0);

            Segment left       = new Segment(origin, topLeft);
            Segment hypotenuse = new Segment(topLeft, bottomRight);
            Segment bottom     = new Segment(bottomRight, origin);

            return(new RightTriangle(left, bottom, hypotenuse));
        }
Example #7
0
        public static Square ConstructDefaultSquare()
        {
            int length = Figure.DefaultSideLength();

            Point topLeft     = PointFactory.GeneratePoint(0, length);
            Point topRight    = PointFactory.GeneratePoint(length, length);
            Point bottomRight = PointFactory.GeneratePoint(length, 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 Square(left, right, top, bottom));
        }
        public static EquilateralTriangle ConstructDefaultEquilateralTriangle()
        {
            int sideLength = Figure.DefaultSideLength();

            Point top = Figure.GetPointByLengthAndAngleInStandardPosition(sideLength, 60);

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

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

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

            return(new EquilateralTriangle(left, right, bottom));
        }
Example #9
0
        public static Parallelogram ConstructDefaultParallelogram()
        {
            int baseLength = Figure.DefaultSideLength();
            int height     = Figure.DefaultSideLength();
            int offset     = Figure.SmallIntegerValue();

            Point topLeft     = PointFactory.GeneratePoint(offset, height);
            Point topRight    = PointFactory.GeneratePoint(offset + baseLength, height);
            Point bottomRight = PointFactory.GeneratePoint(baseLength, 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 Parallelogram(left, right, top, bottom));
        }
Example #10
0
        public static Kite ConstructDefaultKite()
        {
            int height = Figure.DefaultSideLength() / 2;
            int width1 = Figure.DefaultSideLength() / 2;
            int width2 = Figure.DefaultSideLength() / 2;

            Point top    = PointFactory.GeneratePoint(width1, height);
            Point right  = PointFactory.GeneratePoint(width1 + width2, 0);
            Point bottom = PointFactory.GeneratePoint(width1, -height);

            Segment leftTop     = new Segment(origin, top);
            Segment rightTop    = new Segment(top, right);
            Segment rightBottom = new Segment(right, bottom);
            Segment leftBottom  = new Segment(bottom, origin);

            return(new Kite(leftTop, rightBottom, rightTop, leftBottom));
        }
Example #11
0
        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));
        }
Example #12
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));
        }
Example #13
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));
        }
Example #14
0
        public static Quadrilateral ConstructDefaultRectangle()
        {
            int length = Figure.DefaultSideLength();
            int width  = Figure.DefaultSideLength();

            // Ensure we don't have a square.
            while (width == length)
            {
                length = Figure.DefaultSideLength();
                width  = Figure.DefaultSideLength();
            }

            Point topLeft     = PointFactory.GeneratePoint(0, width);
            Point topRight    = PointFactory.GeneratePoint(length, width);
            Point bottomRight = PointFactory.GeneratePoint(length, 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 Rectangle(left, right, top, bottom));
        }
Example #15
0
        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));
        }
Example #16
0
        public static Circle ConstructDefaultCircle()
        {
            int radius = Figure.DefaultSideLength() / 2;

            return(new Circle(origin, radius));
        }