package mishin870;

public class MathUtils{
private static int alpha[]={0,10,20,30,40,50,60,70,80,90};
private static int sin_t[]={0,174,342,500,643,766,866,940,985,1000};

public MathUtils(){
}

public static int sin(int t){
	int sign=1;
	t=t%360;
	if(t<0){
		t=-t;
		sign=-1;
	}
	if(t<=90){return sign*sinus(t);}
	else if(t<=180){return sign*sinus(180-t);}
	else if(t<=270){return -sign*sinus(t-180);}
	else{return -sign*sinus(360-t);}
}

public static int cos(int t){
	t=t%360;
	if (t<0) {t=-t;}
	if (t<=90){return sinus(90-t);}
	else if (t<=180){return -sinus(t-90);}
	else if (t<=270){return -sinus(270-t);}
	else {return sinus(t-270);}
}

public static int module(int m){
	if(m<0){m=-m;}
	return m;
}

public static int max(int a,int b){
	if(a==b){return a;}
	if(a>b){
		return a;
	} else {
		return b;
	}
}

public static int min(int a,int b){
	if(a==b){return a;}
	if(a<b){
		return a;
	} else {
		return b;
	}
}

private static int sinus(int t){
	int k;
	k=(int) (t/10);     
	if (t%10==0){
		return sin_t[k];
	} else {
		return (int) ((sin_t[k+1]-sin_t[k])*(t%10)/10+sin_t[k]);
	}
}

}