public void MatrixAndTranslate() { TransformationParser tp = new TransformationParser("matrix(2,0,0,2,0,0) translate(3,-4.0)"); double[] tr = tp.GetTransformation(); var p = new Point(1, 2, tr); Assert.AreEqual(5, p.X); Assert.AreEqual(0, p.Y); }
public void Rotate() { TransformationParser tp = new TransformationParser("rotate(90)"); double[] tr = tp.GetTransformation(); var p = new Point(1, 0, tr); Assert.AreEqual(0, Math.Round(p.X, 8)); Assert.AreEqual(1, Math.Round(p.Y, 8)); }
public void Translate() { TransformationParser tp = new TransformationParser("translate(15, -34.8)"); double[] tr = tp.GetTransformation(); var p = new Point(1, 2, tr); Assert.AreEqual(16, p.X); Assert.AreEqual(-32.8, p.Y); }
public void Matrix() { TransformationParser tp = new TransformationParser("matrix(1,0,0,2,-3, 3)"); double[] tr = tp.GetTransformation(); var p = new Point(1, 2, tr); Assert.AreEqual(-2, p.X); Assert.AreEqual(7, p.Y); }
public void SkewY() { TransformationParser tp = new TransformationParser("skewY(-30)"); double[] tr = tp.GetTransformation(); var p = new Point(1, 1, tr); Assert.AreEqual(1, Math.Round(p.X, 8)); Assert.AreEqual(Math.Round(1 - 1 / Math.Sqrt(3.0), 8), Math.Round(p.Y, 8)); }
public void Scale2() { TransformationParser tp = new TransformationParser("scale(0.2)"); double[] tr = tp.GetTransformation(); var p = new Point(-5, 10, tr); Assert.AreEqual(-1, Math.Round(p.X, 8)); Assert.AreEqual(2, Math.Round(p.Y, 8)); }
public void Scale1() { TransformationParser tp = new TransformationParser("scale(3)"); double[] tr = tp.GetTransformation(); var p = new Point(1, -2, tr); Assert.AreEqual(3, Math.Round(p.X, 8)); Assert.AreEqual(-6, Math.Round(p.Y, 8)); }
public void NullIsParsedAsNoTransformation() { TransformationParser tp = new TransformationParser(null); double[] tr = tp.GetTransformation(); Assert.AreEqual(1, tr[0]); Assert.AreEqual(1, tr[3]); Assert.AreEqual(0, tr[1]); Assert.AreEqual(0, tr[2]); Assert.AreEqual(0, tr[4]); Assert.AreEqual(0, tr[5]); }
public void EmptyStringIsParsedAsNoTransformation() { TransformationParser tp = new TransformationParser(string.Empty); double[] tr = tp.GetTransformation(); Assert.AreEqual(1, tr[0]); Assert.AreEqual(1, tr[3]); Assert.AreEqual(0, tr[1]); Assert.AreEqual(0, tr[2]); Assert.AreEqual(0, tr[4]); Assert.AreEqual(0, tr[5]); }