Пример #1
0
        private void EvaluateMinPath()
        {
            if (!startValue.IsBetween(-360f, 360f) || !endValue.IsBetween(-360f, 360f))
            {
                return;
            }

            var mappedStartValue = startValue >= 0f ? startValue - 360f : 360f + startValue;
            var mappedEndValue   = endValue >= 0f ? endValue - 360f : 360f + endValue;

            var originalDistance = MathX.Distance(startValue, endValue);
            var mappedDistance   = MathX.Distance(startValue, mappedEndValue);

            if (mappedDistance < originalDistance)
            {
                endValue = mappedEndValue;
            }

            var mappedStartDistance = MathX.Distance(mappedStartValue, endValue);

            if (mappedStartDistance < originalDistance)
            {
                startValue = mappedStartValue;
            }
        }
Пример #2
0
        public LerpAngle SetEndValue(float newEndValue)
        {
            startValue = endValue;

            if (RetainState)
            {
                startValue = currentValue;
            }

            endValue = newEndValue;
            currentInterpolationAmount = 0f;

            if (CheckMinPath)
            {
                EvaluateMinPath();
            }

            range = MathX.Distance(startValue, endValue);

            return(this);
        }
Пример #3
0
 public static bool NearlyEqual(Vector3 a, Vector3 b, float delta)
 {
     return(MathX.NearlyEqual(a.x, b.x, delta) &&
            MathX.NearlyEqual(a.y, b.y, delta) &&
            MathX.NearlyEqual(a.z, b.z, delta));
 }