Esempio n. 1
0
        public void CalcSquare(string poly, string expectedSquare)
        {
            var polygon = new Polygon(poly.Split(' ').Select(Vector.Parse).ToArray());
            var s       = polygon.GetSignedSquare();

            s.Should().Be(Rational.Parse(expectedSquare));
        }
Esempio n. 2
0
        public void BeParsable_EvenIfBig()
        {
            var v = Rational.Parse("1267650600228229401496703205377/1267650600228229401496703205376");

            v.Numerator.ToString().Should().Be("1267650600228229401496703205377");
            v.Denomerator.ToString().Should().Be("1267650600228229401496703205376");
        }
Esempio n. 3
0
        public void BeRotated(string point, string pivot, string x, string expectedPoint)
        {
            Vector p        = point;
            Vector pv       = pivot;
            var    expected = Vector.Parse(expectedPoint);

            p.Rotate(pv, Rational.Parse(x)).Should().Be(expected);
            expected.Rotate(pv, -Rational.Parse(x)).Should().Be(p);
        }
Esempio n. 4
0
        public static Vector Parse(string s)
        {
            var parts = s.Split(',');

            if (parts.Length != 2)
            {
                throw new FormatException(s);
            }
            return(new Vector(Rational.Parse(parts[0]), Rational.Parse(parts[1])));
        }