Ejemplo n.º 1
0
        private double CirclePotentialInteraction(SimulationBox box, CircleWithPotential circle)
        {
            double dx = Math.Abs(circle.X - X);

            if (dx > box.XLength / 2)
            {
                dx = box.XLength - dx;
            }

            double dy = Math.Abs(circle.Y - Y);

            if (dy > box.YLength / 2)
            {
                dy = box.YLength - dy;
            }

            double r = Math.Sqrt(dx * dx + dy * dy);

            if (!(r > circle.Radius + Radius))
            {
                double slope     = (10 - 100) / (circle.Radius + Radius);
                double intercept = 100;

                return(slope * r + intercept);
            }

            double ratio  = (circle.Radius + Radius + MinimumPotentialDistance) / r;
            var    energy = PotentialStrength * (Math.Pow(ratio, 12) - 2 * Math.Pow(ratio, 6));

            return(energy);
        }
Ejemplo n.º 2
0
        public override SimulationObject Duplicate()
        {
            var newCircle = new CircleWithPotential(X, Y, Radius);

            newCircle.MinimumPotentialDistance = MinimumPotentialDistance;
            newCircle.PotentialStrength        = PotentialStrength;
            newCircle.Red      = Red;
            newCircle.Green    = Green;
            newCircle.Blue     = Blue;
            newCircle.MoveList = MoveList;
            return(newCircle);
        }