1 package JSci.physics; 2 3 import JSci.maths.vectors.AbstractDoubleVector; 4 import JSci.maths.vectors.DoubleVector; 5 6 10 public class Drag { 11 private final double coefficient; 12 13 public Drag(double coeff) { 14 coefficient = coeff; 15 } 16 public Force createForce(AbstractClassicalParticle p) { 17 return new Force(p); 18 } 19 private class Force extends JSci.physics.Force { 20 private final AbstractClassicalParticle p; 21 public Force(AbstractClassicalParticle p) { 22 this.p = p; 23 } 24 public AbstractDoubleVector getVector(double t) { 25 AbstractDoubleVector pvel = p.getVelocity(); 26 final double vec[] = new double[pvel.dimension()]; 27 final double k = -coefficient*p.speed(); 28 for(int i=0; i<vec.length; i++) 29 vec[i] = k*pvel.getComponent(i); 30 return new DoubleVector(vec); 31 } 32 } 33 } 34 35 | Popular Tags |