
/**
 * Force - DESCRIPTION
 * <p/>
 * An extension to the Processing project - http://Proce55ing.net
 * <p/>
 * Copyright (c) 2004 Simon Greenwold
 * Created: Feb 11, 2004
 * <p/>
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * <p/>
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * <p/>
 * You should have received a copy of the GNU Lesser General
 * Public License along with the Processing project; if not,
 * write to the Free Software Foundation, Inc., 59 Temple Place,
 * Suite 330, Boston, MA  02111-1307  USA
 */

public abstract class Force implements MPConstants {
  boolean active;
  public boolean visible = true;
  
  public double Jx[][];  // Jacobian wrt. x (position)
  public double Jv[][];  // Jacobian wrt. v (velocity)
  public double B[][];   // = - h * Jx - h^2 * Jv  (cache result used in conj. gad.)
  public double F[];

  Force() {
    active = true;
    Jx = new double[3][3];
    Jv = new double[3][3];
    B = new double[3][3];
    F = new double[3];
  }

  void init(PSystem pSystem) {};

  abstract void applyForce();
  abstract void applyForce(Particle p);
  
  public void zero(double mat[][]) 
  {
  	mat[0][0] = 0.0; mat[0][1] = 0.0; mat[0][2] = 0.0;
  	mat[1][0] = 0.0; mat[1][1] = 0.0; mat[1][2] = 0.0;
  	mat[2][0] = 0.0; mat[2][1] = 0.0; mat[2][2] = 0.0;
  }
  
  public void identity(double mat[][]) 
  {
  	mat[0][0] = 1.0; mat[0][1] = 0.0; mat[0][2] = 0.0;
  	mat[1][0] = 0.0; mat[1][1] = 1.0; mat[1][2] = 0.0;
  	mat[2][0] = 0.0; mat[2][1] = 0.0; mat[2][2] = 1.0;
  }
  
  public abstract void resetCalcs();
  public abstract void calculateForce(double F0[]);
  public abstract void calculateJacobians(double h);
  
  void draw() {

  }
}
