예제 #1
0
파일: Camera.cs 프로젝트: LamidD/SpaceSim-1
        public void Update(double dt)
        {
            if (_isInterpolating)
            {
                if (_interpolationTime > 1)
                {
                    _isInterpolating = false;
                }

                // Interpolate using a logistic function
                // https://en.wikipedia.org/wiki/Logistic_function
                double sigmoidX = (_interpolationTime - 0.5) * 6;

                double sigmoidY = (1.0 / (1 + Math.Exp(-3.0 * sigmoidX)));

                // Lerp between the two targets
                _position = DVector2.Lerp(_lastTarget.Position, _target.Position, sigmoidY);

                _interpolationTime += dt;

                Rotation = MathHelper.LerpAngle(Rotation, _targetRotation, sigmoidY);
            }
            else
            {
                _position = _target.Position;
                Rotation  = _targetRotation;
            }

            ComputeBounds();
        }
예제 #2
0
파일: MathOps.cs 프로젝트: vimaec/ara3d-dev
 [MethodImpl(MethodImplOptions.AggressiveInlining)] public static DVector2 Average(this DVector2 v1, DVector2 v2) => v1.Lerp(v2, 0.5f);