Example #1
0
        public void DragIsProportionalToSpeed(Vector2 vel0, Vector2 vel1)
        {
            var forceCalculator = new VehicleForces(constants.Object);

            var force0 = forceCalculator.GetDragForce(vel0);
            var force1 = forceCalculator.GetDragForce(vel1);

            Assert.True(force0.Length() < force1.Length());
        }
Example #2
0
        public void DragIsZeroAtZeroVelocity()
        {
            var forceCalculator = new VehicleForces(constants.Object);
            var vel             = Vector2.Zero;

            var force = forceCalculator.GetDragForce(vel);

            Assert.True(force.Length() < float.Epsilon);
        }
Example #3
0
        public void DragPointsInTheOppositeDirectionOfTheVelocityVector()
        {
            var forceCalculator = new VehicleForces(constants.Object);
            var vel             = new Vector2(0, 28);

            var force = forceCalculator.GetDragForce(vel);

            // NOTE(danielm): dot product of two units vectors is -1 if the
            // angle between them is 180deg.
            var dot  = Vector2.Dot(Vector2.Normalize(force), Vector2.Normalize(vel));
            var diff = Math.Abs(-1 - dot);

            Assert.True(diff < float.Epsilon);
        }