/*
 * 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  Barbara
 */
public class EMField extends ForceField{
    /** Creates a new instance of ForceField */
    private class EMForce extends ProdForce 
    {
        public EMForce(ClassicalParticleV2D p){
           super(p);
       }
       public AbstractDoubleVector getVector(double t) {
           double x=p.getVelocity().getComponent(0);
           double y=p.getVelocity().getComponent(1);
           return (vectors[0].add(new Double2Vector(params[0]*y,-params[0]*x))).scalarMultiply(p.getCharge());
       }
       
    }

    public EMField(AbstractDoubleVector E, double b) {
          vectors = new AbstractDoubleVector[1];
          vectors[0]=E;
          params = new double[1];
          params[0]=b;
    }
    public ProdForce getForce(ClassicalParticleV2D p){
        return new EMForce(p);
    }
   
}
