Here you can find the source of sinr(float radians)
public static float sinr(float radians)
import android.util.FloatMath; public class Main{ /**//from ww w.j a v a 2 s .c o m * Convert degrees to Radians. */ public static final float TO_RADIANS = 0.0174532925f; /** * Convert Radians to Degrees. */ public static final float TO_DEGREES = 57.2957795f; /** * 360 degrees of SINE */ private static float[] SINE = null; /** * 360 degrees of COSINE */ private static float[] COSINE = null; /** * 360 degrees of TAN */ private static float[] TANGENT = null; /** * Return the value of sin(radians) */ public static float sinr(float radians) { //do we need to initialise the arrays? if (SINE == null) initialise(); //get the sine value wanted return SINE[(int) constrainAngle(radians * TO_DEGREES)]; } /** * Initialise the SINE, COSINE and TANGENT arrays */ private static void initialise() { //initialise arrays SINE = new float[360]; COSINE = new float[360]; TANGENT = new float[360]; //fill them for (int i = 0; i < 360; i++) { SINE[i] = android.util.FloatMath.sin(i * TO_RADIANS); COSINE[i] = android.util.FloatMath.cos(i * TO_RADIANS); TANGENT[i] = (float) Math.tan(i * TO_RADIANS); } } /** * Constrain a given degree to between 0-359 */ public static float constrainAngle(float degree) { while (degree < 0.0f || degree >= 360.0f) { if (degree < 0.0f) degree = 360.0f + degree; else if (degree >= 360.0f) degree -= 360.0f; } return degree; } /** * Return the value of sin(degree) */ public static float sin(float degree) { //do we need to initialise the arrays? if (SINE == null) initialise(); //get the sine value wanted int deg = (int) constrainAngle(degree); return SINE[deg]; } /** * Return the value of cos(degree) */ public static float cos(float degree) { //do we need to initialise the arrays? if (COSINE == null) initialise(); //get the cosine value wanted int deg = (int) constrainAngle(degree); return COSINE[deg]; } /** * Return the value of tan(degree) */ public static float tan(float degree) { //do we need to initialise the arrays? if (TANGENT == null) initialise(); //get the tangent value wanted return TANGENT[(int) constrainAngle(degree)]; } }