コード例 #1
0
        public void TestConstMove()
        {
            var p = new ProjectileN.Projectile(mass: 1, position: new Vector(0, 0, 0), velocity: new Vector(1, 0, 0), acceleration: new Vector(0, 0, 0));

            p.Move(1);

            var correct = new ProjectileN.Projectile(mass: 1, position: new Vector(1, 0, 0), velocity: new Vector(1, 0, 0), acceleration: new Vector(0, 0, 0));

            Assert.AreEqual(correct.position, p.position);
        }
コード例 #2
0
        public void TestAll()
        {
            var p     = new ProjectileN.Projectile(mass: 1, velocity: new Vector(0, 1, 0), c_air: 1.0, position: new Vector(2, 0, 0), acceleration: new Vector(0, 0, 0));
            var world = new World(k_spring: 1, g_gravity: 9.8);

            var f_net   = world.CalculateForce(p, 0);
            var correct = new Vector(-2, -1, -9.8);

            Assert.AreEqual(correct, f_net);
        }
コード例 #3
0
        public void TestAirResistance()
        {
            var p     = new ProjectileN.Projectile(mass: 1, velocity: new Vector(1, 0, 0), c_air: 1.0, position: new Vector(0, 0, 0), acceleration: new Vector(0, 0, 0));
            var world = new World();

            var drag    = world.AirResistance(p);
            var correct = new Vector(-1, 0, 0);

            Assert.AreEqual(correct, drag);
        }
コード例 #4
0
        public void TestSpring()
        {
            var p     = new ProjectileN.Projectile(mass: 1, velocity: new Vector(0, 0, 0), c_air: 1.0, position: new Vector(0.2, 0, 0), acceleration: new Vector(0, 0, 0));
            var world = new World(k_spring: 1);

            var spring_force = world.SpringForce(p, new Vector(0, 0, 0), 0);
            var correct      = new Vector(-.2, 0, 0);

            Assert.AreEqual(correct, spring_force);
        }
コード例 #5
0
        public void TestGravity()
        {
            Vector zero  = new Vector(0, 0, 0);
            var    p     = new ProjectileN.Projectile(mass: 1, position: new Vector(0, 10, 0), velocity: zero, acceleration: zero);
            var    p2    = new ProjectileN.Projectile(mass: 1, immovable: true);
            var    world = new World();

            var grav    = world.Gravity(p, p2);
            var correct = new Vector(0, 0, -9.8);

            Assert.AreEqual(correct, grav);
        }