Exemple #1
0
        public void CanSubtractTwoPoints()
        {
            var p1 = Tuple.NewPoint(3, 2, 1);
            var p2 = Tuple.NewPoint(5, 6, 7);

            Assert.Equal(Tuple.NewVector(-2, -4, -6), p1 - p2);
        }
Exemple #2
0
        public void CanSubtractAVectorFromAPoint()
        {
            var p = Tuple.NewPoint(3, 2, 1);
            var v = Tuple.NewVector(5, 6, 7);

            Assert.Equal(Tuple.NewPoint(-2, -4, -6), p - v);
        }
Exemple #3
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Projectile Demo");

            var p        = new Projectile(Tuple.NewPoint(0, 1, 0), Tuple.NewVector(1, 1, 0).Normalized);
            var w        = new World(Tuple.NewVector(0, -0.1, 0), Tuple.NewVector(-0.01, 0, 0));
            var numTicks = 0;

            Console.WriteLine($"Y: {p.Position.Y}, Ticks: {numTicks}");
            while (p.Position.Y > 0)
            {
                p = Tick(w, p);
                numTicks++;
                Console.WriteLine($"Y: {p.Position.Y}, Ticks: {numTicks}");
            }

            Console.WriteLine($"It took {numTicks} ticks to hit the ground.");

            Console.Read();
        }
Exemple #4
0
        public void TupleFactoryCanCreateAPoint()
        {
            var p = Tuple.NewPoint(4, -4, 3);

            Assert.Equal(new Tuple4(4, -4, 3, 1), p);
        }