예제 #1
0
        /* refill a linear transition with new state information */
        public static void ResetLinearTransition(
            ref LinearTransRec TransRec,
            double Start,
            double Destination,
            int TicksToReach)
        {
            double LocalTicksToReach = TicksToReach;

            TransRec.RightValue          = Destination;
            TransRec.InverseDifferential = (Start - Destination) / LocalTicksToReach;
            TransRec.Countdown           = LocalTicksToReach;
        }
예제 #2
0
        /* execute one cycle and return the value */
        public static double LinearTransitionUpdate(ref LinearTransRec TransRec)
        {
            double LocalCountdown = TransRec.Countdown - 1;
            double ReturnValue    = TransRec.RightValue + TransRec.InverseDifferential * LocalCountdown;

            TransRec.Countdown = LocalCountdown;

#if DEBUG
            if (Math.Floor(TransRec.Countdown) != TransRec.Countdown)
            {
                // Countdown not integer
                Debug.Assert(false);
                throw new InvalidOperationException();
            }
#endif

            return(ReturnValue);
        }