public void TargetHasReached_SolverDoesNotIterate()
        {
            var targetPosition1 = new Vector2(-9.0f, 1.0f);
            var targetPosition2 = new Vector2(9.0f, 1.0f);

            chains[1].target = targetPosition1;
            chains[2].target = targetPosition2;

            var result = FABRIK2D.SolveChain(kIterations, ref chains);

            Assert.AreEqual(true, result);

            result = FABRIK2D.SolveChain(kIterations, ref chains);

            Assert.AreEqual(false, result);
        }
        public void TargetIsReachableForChain_EndPointReachesTarget()
        {
            var targetPosition1 = new Vector2(-9.0f, 1.0f);
            var targetPosition2 = new Vector2(9.0f, 1.0f);

            chains[1].target = targetPosition1;
            chains[2].target = targetPosition2;

            var result = FABRIK2D.SolveChain(kIterations, ref chains);

            Assert.AreEqual(true, result);
            Assert.That(targetPosition1, Is.EqualTo(chains[1].positions[chains[1].positions.Length - 1]).Using(vec2Compare));
            Assert.That(0.0f, Is.EqualTo((targetPosition1 - chains[1].positions[chains[1].positions.Length - 1]).magnitude).Using(floatCompare));
            Assert.That(targetPosition2, Is.EqualTo(chains[2].positions[chains[2].positions.Length - 1]).Using(vec2Compare));
            Assert.That(0.0f, Is.EqualTo((targetPosition2 - chains[2].positions[chains[2].positions.Length - 1]).magnitude).Using(floatCompare));
        }
        public void TargetIsLongerThanChain_EndPointIsAtClosestPointToTarget()
        {
            var targetPosition1 = new Vector2(0f, 12.0f);
            var targetPosition2 = new Vector2(0f, 12.0f);

            chains[1].target = targetPosition1;
            chains[2].target = targetPosition2;

            var result = FABRIK2D.SolveChain(kIterations, ref chains);

            Assert.AreEqual(true, result);
            Assert.That(targetPosition1, Is.Not.EqualTo(chains[1].positions[chains[1].positions.Length - 1]).Using(vec2Compare));
            Assert.That(2.0f, Is.EqualTo((targetPosition1 - chains[1].positions[chains[1].positions.Length - 1]).magnitude).Using(floatCompare));
            Assert.That(targetPosition2, Is.Not.EqualTo(chains[2].positions[chains[2].positions.Length - 1]).Using(vec2Compare));
            Assert.That(2.0f, Is.EqualTo((targetPosition2 - chains[2].positions[chains[2].positions.Length - 1]).magnitude).Using(floatCompare));
        }