Пример #1
0
        public void ShouldInterpolateByAngle(
            float startValue, float endValue, float interpolateValue, int expectedSteps
            )
        {
            var lerp = new LerpAngle(startValue);

            lerp.SetEndValue(endValue);

            Assert.That(
                lerp.EvalAngle(0f), Is.EqualTo(lerp.StartValue).Within(1f),
                "Fail to validate start value"
                );

            for (int i = 0; i < expectedSteps - 1; i++)
            {
                var value = lerp.EvalAngle(interpolateValue);

                Assert.That(
                    value,
                    Is.Not.EqualTo(lerp.EndValue).Within(.1f),
                    $"Was equal on {i} interaction"
                    );
            }

            Assert.That(
                lerp.EvalAngle(interpolateValue), Is.EqualTo(lerp.EndValue).Within(1f),
                "Fail to validate end value"
                );
        }
Пример #2
0
        public void ShouldInterpolateOriginalAngleWhenCheckMinPathIsDisabled()
        {
            var startValue        = -135f;
            var endValue          = 135f;
            var interpolateAmount = 1f;
            var expectedSteps     = 270;

            var lerp = new LerpAngle(startValue)
            {
                CheckMinPath = false
            };

            lerp.SetEndValue(135f);

            Assert.That(
                lerp.EvalAngle(0f), Is.EqualTo(startValue).Within(1f),
                "Fail to validate start value"
                );

            for (int i = 0; i < expectedSteps - 1; i++)
            {
                var value = lerp.EvalAngle(interpolateAmount);

                Assert.That(
                    value,
                    Is.Not.EqualTo(endValue).Within(.1f),
                    $"Was equal on {i} interaction"
                    );
            }

            Assert.That(
                lerp.EvalAngle(interpolateAmount), Is.EqualTo(endValue).Within(1f),
                "Fail to validate end value"
                );
        }
Пример #3
0
        public void ShouldRetainStateOfInterpolationWhenChangeEndValue()
        {
            var startValue        = 0f;
            var middleValue       = 10f;
            var endValue          = 20f;
            var interpolateAmount = 1f;

            var lerp = new LerpAngle(startValue)
            {
                RetainState = true
            };

            lerp.SetEndValue(middleValue);

            Assert.That(
                lerp.EvalAngle(0f), Is.EqualTo(startValue).Within(1f),
                "Fail to validate start value"
                );

            for (int i = 0; i < 5 - 1; i++)
            {
                var value = lerp.EvalAngle(interpolateAmount);

                Assert.That(
                    value,
                    Is.Not.EqualTo(5f).Within(.1f),
                    $"Was equal on {i} interaction"
                    );
            }

            lerp.SetEndValue(20f);

            Assert.That(
                lerp.EvalAngle(interpolateAmount), Is.EqualTo(5f).Within(.1f),
                "Fail to validate middle pathway value"
                );

            for (int i = 0; i < 15 - 1; i++)
            {
                var value = lerp.EvalAngle(interpolateAmount);

                Assert.That(
                    value,
                    Is.Not.EqualTo(endValue).Within(.1f),
                    $"Was equal on {i} interaction"
                    );
            }

            Assert.That(
                lerp.EvalAngle(interpolateAmount), Is.EqualTo(endValue).Within(1f),
                "Fail to validate end value"
                );
        }