public double Potential(Particle particle) { var xyDistance = Position - particle.Position; // charges with different signs create a negative potential return Charge * particle.Charge / Math.Sqrt(xyDistance.LengthSquared + Z * Z); }
public Vector2D Force(Particle particle) { var xyDistance = Position - particle.Position; if(xyDistance.IsZero) return Vector2D.ZeroVector; var xyProjectionCoefficient = xyDistance.Length / Math.Sqrt(xyDistance.LengthSquared + Z * Z); // charges with different signs attract each other return -Charge * particle.Charge * xyProjectionCoefficient / (xyDistance.LengthSquared + Z * Z) * xyDistance.Unity; }
public Pendulum(int attractorCount) { Attractors = new AttractorSet(); for (int i = 0; i < attractorCount; i++) { var angle = i * 2 * Math.PI / attractorCount; Attractors.Add(new Attractor { Position = new Vector2D(Math.Cos(angle), Math.Sin(angle)) }); } Particle = new Particle { Force = ForceOnParticle }; Friction = new FluidFriction(); }
public override Vector2D Force(Particle particle) { return -Coefficient * particle.Velocity.Length * particle.Velocity; }
public abstract Vector2D Force(Particle particle);
private Vector2D ForceOnParticle(Particle particle) { return Attractors.Force(particle) + Friction.Force(particle); }