Exemplo n.º 1
0
        public void Reflect()
        {
            Cartesian2DPoints figure         = new Cartesian2DPoints("(-1,2)(-2,1)(-1,-1)").Reflect(LineType.Y_axis);
            Cartesian2DPoints expectedFigure = new Cartesian2DPoints("(1,2)(2,1)(1,-1)");

            Assert.AreEqual(figure, expectedFigure);
        }
Exemplo n.º 2
0
        public void TranslateAsCartesian2dImplicitlyConvertedToExpression()
        {
            Expression transformedFigure = new Cartesian2DPoints("(2,5)(1,3)(4,2)").Translate("4|-1");
            Expression expectedFigure    = new Cartesian2DPoints("(6,4)(5,2)(8,1)");

            Assert.AreEqual(transformedFigure, expectedFigure);
        }
Exemplo n.º 3
0
        public void TranslateConcise()
        {
            Cartesian2DPoints transformedFigure = new Cartesian2DPoints("(2,5)(1,3)(4,2)").Translate("4|-1");
            Cartesian2DPoints expectedFigure    = new Cartesian2DPoints("(6,4)(5,2)(8,1)");

            Assert.AreEqual(transformedFigure, expectedFigure);
        }
Exemplo n.º 4
0
        public void TranslateAsCartesian2dAgainstExpression()
        {
            Cartesian2DPoints transformedFigure = new Cartesian2DPoints("(2,5)(1,3)(4,2)").Translate("4|-1");
            Expression        expectedFigure    = new Expression("(6,4)(5,2)(8,1)");

            Assert.AreEqual(transformedFigure, expectedFigure);
        }
Exemplo n.º 5
0
        public void CompositeTransformationTriangleAsExpressionsAgainstCartesion2D() //TODO evaluate/Create Triangle property
        {
            var figure   = new Expression("(-3.5,4)(-7,-3)(0,-3)").Translate("7|3").Reflect(LineType.X_axis);
            var expected = new Cartesian2DPoints("(3.5,-7)(0,0)(7,0)");

            Assert.AreEqual(figure, expected);
        }
Exemplo n.º 6
0
        public void CompositeTransformation()
        {
            //var figure = new Cartesian2DPoints(new List<Point>{new Point(-1,-8)});
            var figure = new Cartesian2DPoints("(-1,8)");
            Cartesian2DPoints transformedFigure = figure.Reflect(LineType.Y_axis); //(1,8)

            transformedFigure = transformedFigure.Translate("4|6");                //(5,14)
            string result = transformedFigure.ToString();

            Assert.AreEqual(result, "(5,14)");
        }
Exemplo n.º 7
0
        public void CompositeTransformationTriangle()
        {
            var figure = new Cartesian2DPoints("(-3.5,4)(-7,-3)(0,-3)");

            figure = figure.Translate("7|3");
            figure = figure.Reflect(LineType.X_axis);

            var expected = new Cartesian2DPoints("(3.5,-7)(0,0)(7,0)");
            var areEqual = figure.Equals(expected);

            Assert.IsTrue(areEqual);
        }
Exemplo n.º 8
0
 public static Cartesian2DPoints Translate(this Cartesian2DPoints figure, string displacementVectorFormat) // JereNumber|JereNumber
 {
     if (RegexPatterns.DisplacementVector.IsMatch(displacementVectorFormat))
     {
         var dvTemp = new DisplacementVector(displacementVectorFormat);
         var result = (Cartesian2DPoints)Transformation.Translate(figure.Points, dvTemp.TopHorizontal, dvTemp.BottomVertical);
         return(result);
     }
     else
     {
         throw new ArgumentException("Must use proper format");
     }
 }
Exemplo n.º 9
0
        public void Translate()
        {
            Cartesian2DPoints figure = new Cartesian2DPoints(new List <Point> {
                new Point(2, 5), new Point(1, 3), new Point(4, 2)
            });

            figure = figure.Translate(new DisplacementVector(4, -1));
            Cartesian2DPoints expectedFigure = new Cartesian2DPoints(new List <Point> {
                new Point(6, 4), new Point(5, 2), new Point(8, 1)
            });

            Assert.AreEqual(figure, expectedFigure);
        }
Exemplo n.º 10
0
        public void Dilate()
        {
            var figure = new Cartesian2DPoints(new List <Point> {
                new Point(-1, 2),
                new Point(-2, 1),
                new Point(-1, -1)
            });

            figure = figure.Dilate(4);
            var expectedFigure = new Cartesian2DPoints(new List <Point> {
                new Point(-4, 8),
                new Point(-8, 4),
                new Point(-4, -4)
            });

            Assert.AreEqual(figure, expectedFigure);
        }
Exemplo n.º 11
0
        public void Rotate()
        {
            var figure = new Cartesian2DPoints(new List <Point> {
                new Point(-1, 2),
                new Point(-2, 1),
                new Point(-1, -1)
            });

            figure = figure.Rotate(DegreeType.CW_90);

            var expectedFigure = new Cartesian2DPoints(new List <Point> {
                new Point(2, 1),
                new Point(1, 2),
                new Point(-1, 1)
            });

            Assert.AreEqual(figure, expectedFigure);
        }
Exemplo n.º 12
0
        public static Cartesian2DPoints Dilate(this Cartesian2DPoints figure, Expression multiplier)
        {
            var result = (Cartesian2DPoints)Transformation.Dilate(figure.Points, multiplier);

            return(result);
        }
Exemplo n.º 13
0
        public static Cartesian2DPoints Rotate(this Cartesian2DPoints figure, DegreeType degreeType)
        {
            var result = (Cartesian2DPoints)Transformation.Rotate(figure.Points, degreeType);

            return(result);
        }
Exemplo n.º 14
0
        public static Cartesian2DPoints Reflect(this Cartesian2DPoints figure, LineType lineType)
        {
            var result = (Cartesian2DPoints)Transformation.Reflect(figure.Points, lineType);

            return(result);
        }
Exemplo n.º 15
0
        public static Cartesian2DPoints Translate(this Cartesian2DPoints figure, DisplacementVector displacementVector)
        {
            var result = (Cartesian2DPoints)Transformation.Translate(figure.Points, displacementVector.TopHorizontal, displacementVector.BottomVertical);

            return(result);
        }
Exemplo n.º 16
0
        [DataTestMethod]  //FAILS
        public void TranslateExpressionComparedToStringFlippedAreEqualArguments()
        {
            Expression transformedFigure = new Cartesian2DPoints("(2,5)(1,3)(4,2)").Translate("4|-1");

            Assert.AreEqual("(6,4)(5,2)(8,1)", transformedFigure);
        }