示例#1
0
        public ConstantVelocityProcess()
        {
            currentState = new ConstantVelocity2DModel
            {
                Position = new PointF(50, 1),
                Velocity = new PointF(0.3f, 0.3f)
            };

            initialState = currentState;
        }
示例#2
0
        public ConstantVelocity2DModel GetNoisyState(double accelerationNoise)
        {
            var processNoiseMat = ConstantVelocity2DModel.GetProcessNoise(accelerationNoise);
            var noise           = normalDistribution.Generate(ConstantVelocity2DModel.Dimension).Multiply(processNoiseMat);

            return(new ConstantVelocity2DModel
            {
                Position = new PointF
                {
                    X = currentState.Position.X + (float)noise[0],
                    Y = currentState.Position.Y + (float)noise[2]
                },

                Velocity = new PointF
                {
                    X = currentState.Velocity.X + (float)noise[1],
                    Y = currentState.Velocity.Y + (float)noise[3]
                }
            });
        }
示例#3
0
        public void GoToNextState(out bool doneFullCycle)
        {
            Func <PointF, bool> isBorder = (point) =>
            {
                return(point.X <= 0 || point.X >= WorkingArea.Width ||
                       point.Y <= 0 || point.Y >= WorkingArea.Height);
            };

            doneFullCycle = false;
            var prevPos = currentState.Position;
            var speed   = currentState.Velocity;

            if (isBorder(currentState.Position))
            {
                var temp = speed.X;
                speed.X = -speed.Y;
                speed.Y = temp;

                if (speed.Equals(initialState.Velocity))
                {
                    doneFullCycle = true;
                }
            }

            var nextState = new ConstantVelocity2DModel
            {
                Position = new PointF
                {
                    X = prevPos.X + speed.X * TimeInterval,
                    Y = prevPos.Y + speed.Y * TimeInterval
                },

                Velocity = speed
            };

            currentState = nextState;
        }