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

package JSciDraw.physics;

import JSci.maths.*;
import JSci.physics.*;
import JSciDraw.interfaces.*;
import JSciDraw.physics.*;
import java.util.*;
/*
 *
 * @author  Przemek
 */
public abstract class ForceField {
    protected double[] params;
    protected AbstractDoubleVector[] vectors; //implements constant gravity, coulomb or magnetic fields
    
    public abstract class ProdForce extends JSci.physics.Force
    {
       protected ClassicalParticleV2D p;
       public ProdForce(ClassicalParticleV2D p){
           this.p=p;
       }
       abstract public AbstractDoubleVector getVector(double t); //pole zmienne w czasie
    }
    
    /** Creates a new instance of ForceField */
    public ForceField() {
    }
    abstract public ProdForce getForce(ClassicalParticleV2D p);
    public void applyField(ArrayList a){
        Iterator i=a.iterator();
        while (i.hasNext()) {
          Object tmp = i.next();
           if (tmp instanceof ClassicalParticleV2D){
              ClassicalParticleV2D part =(ClassicalParticleV2D)tmp;
              part.addExtForce(getForce(part));
                if (part.moveableObjects.size()>0){
                   Iterator j=part.moveableObjects.iterator();
                     while (j.hasNext())
                         ((MoveableObject)j.next()).applyForceField(this);
                   }
               }
        }
        
    }
   }
   

