package engineering;


public class Gear {

	/**
	 * @param moment
	 * @param z1
	 * @return minimal (theoretical) modulus
	 */
	public double modulusMin(double moment, int z1){
		double yF = 2.2;
		double yEps = 1;
		double x = 1;
		double b = 25;
		double tau = 400;
		double sF = 1.5;
		double tauZul = tau / sF;
		return modulusMin(moment, z1, yF, yEps, x, b, tauZul, sF);
	}
	
	/**
	 * @param moment
	 * @param z1
	 * @param yF Tooth form factor; DE: Zahnformfaktor
	 * @param yEps DE: Lastanteilfaktor
	 * @param x DE: tirnlastverteilungsfaktor
	 * @param b DE: Zahnbreitenverhältnis
	 * @param tau
	 * @param sF
	 * @return minimal (theoretical) modulus
	 */
	public double modulusMin(double moment, int z1,
			double yF, double yEps, double x, double b,
			double tau, double sF){
		double tauZul = tau / sF;   // todo
		double modulusMin = Math.cbrt(2*moment*yF*yEps*x*1000/z1/b/tauZul);
		return modulusMin;
	}
	
	/**
	 * DE: Modulreihe 1 nach DIN 781-1 1977-05
	 * @param m modulus (theoretical)
	 * @return standardized modulus
	 */
	public static double modulreihe1(double m){
		     if(m <=  0.20){ m = 0.2;}
		else if(m <=  0.25){ m = 0.25;}
		else if(m <=  1.00){ m = Math.ceil(m/0.1)*0.1;}
		else if(m <=  6.00){
			 if(m <=  1.50){ m = 1.5;}
			 if(2.0 < m && m <= 2.5){ m = 2.5;}
			 else            m = Math.ceil(m);
		}
		else if(m <= 12.00){ m = Math.ceil(m/2)*2;}
		else if(m <= 16.00){ m = 16;}
		return m;
	}
}
