/*
 * ForceField.java
 *
 * Created on 14 styczeń 2005, 00:58
 */

package JSciDraw.physics.fields;

import JSci.maths.*;
import JSci.physics.*;
import JSciDraw.interfaces.*;
import JSciDraw.physics.*;
import java.util.*;
/*
 *
 * @author  Przemek
 */
public class CoulombField extends CentralForceField{
    /** Creates a new instance of ForceField */
    public ClassicalParticleV2D center;
    private class CForce extends ProdForce 
    {
        private ClassicalParticleV2D p;
        public CForce(ClassicalParticleV2D p){
           super(p);
           this.p=p;
       }
       public AbstractDoubleVector getVector(double t) {
           AbstractDoubleVector wodz = p.getPosition().subtract(center.getPosition());
           double r = wodz.norm();
           wodz.normalize();
         return wodz.scalarMultiply(p.getCharge()*center.getCharge()/(r*r*4*Math.PI*JSci.physics.PhysicalConstants.PERMITTIVITY));
       }
       
    }
    public CoulombField(ClassicalParticleV2D a) {
      super(a);
      center=a;
    }
    public ProdForce getForce(ClassicalParticleV2D p){
        return new CForce(p);
    }
        
    
}
