Пример #1
0
        public void TargetIsLongerThanChain_EndPointIsAtClosestPointToTarget()
        {
            var targetPosition = new Vector2(0.0f, 12.0f);

            var result = FABRIK2D.Solve(targetPosition, kIterations, kTolerance, lengths, ref positions);

            Assert.AreEqual(true, result);
            Assert.That(targetPosition, Is.Not.EqualTo(positions[positions.Length - 1]).Using(vec2Compare));
            Assert.That(2.0f, Is.EqualTo((targetPosition - positions[positions.Length - 1]).magnitude).Using(floatCompare));
        }
Пример #2
0
        public void TargetIsReachableForChain_EndPointReachesTarget()
        {
            var targetPosition = new Vector2(9.0f, 1.0f);

            var result = FABRIK2D.Solve(targetPosition, kIterations, kTolerance, lengths, ref positions);

            Assert.AreEqual(true, result);
            Assert.That(targetPosition, Is.EqualTo(positions[positions.Length - 1]).Using(vec2Compare));
            Assert.That(0.0f, Is.EqualTo((targetPosition - positions[positions.Length - 1]).magnitude).Using(floatCompare));
        }
Пример #3
0
        public void TargetHasReached_SolverDoesNotIterate()
        {
            var targetPosition = new Vector2(9.0f, 1.0f);

            var result = FABRIK2D.Solve(targetPosition, kIterations, kTolerance, lengths, ref positions);

            Assert.AreEqual(true, result);

            result = FABRIK2D.Solve(targetPosition, kIterations, kTolerance, lengths, ref positions);

            Assert.AreEqual(false, result);
        }