protected void MoveParticle(RealVector velocity, RealVector position)
        {
            BoundsChecker.Apply(velocity, CurrentVelocityBounds);
            for (int i = 0; i < velocity.Length; i++)
            {
                position[i] = RealVector[i] + velocity[i];
            }
            for (int i = 0; i < position.Length; i++)
            {
                double min = Bounds[i % Bounds.Rows, 0];
                double max = Bounds[i % Bounds.Rows, 1];
                if (position[i] < min)
                {
                    int    reflectionCount = (int)Math.Truncate((min - position[i]) / (max - min)) + 1;
                    double reflection      = (min - position[i]) % (max - min);
                    if (IsOdd(reflectionCount))
                    {
                        position[i] = min + reflection;
                        velocity[i] = -velocity[i];
                    }
                    else
                    {
                        position[i] = max - reflection;
                    }
                }
                if (position[i] > max)
                {
                    int    reflectionCount = (int)Math.Truncate((position[i] - max) / (max - min)) + 1;
                    double reflection      = (position[i] - max) % (max - min);
                    if (IsOdd(reflectionCount))
                    {
                        position[i] = max - reflection;
                        velocity[i] = -velocity[i];
                    }
                    else
                    {
                        position[i] = min + reflection;
                    }
                }
            }

            RealVector = position;
            Velocity   = velocity;
        }
 protected BoundsChecker(BoundsChecker original, Cloner cloner) : base(original, cloner) { }
Exemple #3
0
 protected BoundsChecker(BoundsChecker original, Cloner cloner) : base(original, cloner)
 {
 }