示例#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));
        }
示例#2
0
        ////
        //// Force this segment into standard position; only 1st and second quadrants allowed.
        ////
        //public Segment Standardize()
        //{
        //    Point vector = Point.MakeVector(this.Point1, this.Point2);

        //    // If this segment is in the 3rd or 4th quadrant, force into the second by taking the opposite.
        //    if (vector.Y < 0) vector = Point.GetOppositeVector(vector);

        //    return new Segment(origin, vector);
        //}

        public Segment ConstructSegmentByAngle(Point tail, int angle, int length)
        {
            // Make a vector in standard position
            Point vector = Point.MakeVector(tail, this.OtherPoint(tail));

            // Calculate the angle from standard position.
            double stdPosAngle = Point.GetDegreeStandardAngleWithCenter(origin, vector);

            // Get the exact point we want.
            Point rotatedPoint = Figure.GetPointByLengthAndAngleInStandardPosition(length, stdPosAngle - angle);

            return(new Segment(tail, rotatedPoint));
        }
示例#3
0
        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));
        }
示例#4
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));
        }