/** * Created by IntelliJ IDEA. * User: siddhartha * Date: Feb 1, 2006 * Time: 4:38:06 AM * To change this template use File | Settings | File Templates. */ //! @brief This class calculates various quantities of interest, given a set of data /// Average, max, magnitude of some given data. Also Delta-F. public class Calculate { public static double average(double[] values) { double total = 0, avg = 0; for(int i = 0; imax) max = values[i]; } return max; } public static double magnitude(double xComp, double yComp) { return Math.sqrt(Math.pow(xComp, 2) + Math.pow(yComp, 2)); } public static double delta(char what, AFMSimulator afmSim, int i) { double[][] roots = afmSim.getRoots(); double t_b = roots[i][0] - afmSim.getAFM().getTimeStep()/10; double t_a = roots[i][0] + afmSim.getAFM().getTimeStep()/10; if (what == 'F') { double F_before = Math.sqrt( Math.pow( afmSim.getAFM().gimmeFX(t_b, roots[i][5], roots[i][6], roots[i][8], roots[i][7], roots[i][9]), 2 ) + Math.pow( afmSim.getAFM().gimmeFY(t_b, roots[i][5], roots[i][6], roots[i][8], roots[i][7], roots[i][9]), 2 ) ); double F_after = Math.sqrt( Math.pow( afmSim.getAFM().gimmeFX(t_a, roots[i][0], roots[i][1], roots[i][3], roots[i][2], roots[i][5]), 2 ) + Math.pow( afmSim.getAFM().gimmeFY(t_a, roots[i][5], roots[i][6], roots[i][8], roots[i][7], roots[i][9]), 2 ) ); return (F_after - F_before); } else return 0; } }