Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5266 eugene455 1
const float sctable[91]={0.000,0.017,0.035,0.052,0.069,0.087,0.104,0.121,0.139,0.156,0.173,
2
			       0.190,0.207,0.225,0.242,0.259,0.275,0.292,0.309,0.325,0.342,
3
			       0.358,0.374,0.390,0.406,0.422,0.438,0.454,0.469,0.485,0.500,
4
			       0.515,0.530,0.545,0.560,0.573,0.588,0.602,0.616,0.629,0.643,
5
			       0.656,0.669,0.682,0.695,0.707,0.719,0.731,0.743,0.754,0.766,
6
			       0.777,0.788,0.798,0.809,0.819,0.829,0.838,0.848,0.857,0.866,
7
			       0.875,0.883,0.891,0.899,0.906,0.913,0.920,0.927,0.934,0.939,
8
			       0.945,0.951,0.956,0.961,0.965,0.970,0.974,0.978,0.982,0.985,
9
			       0.987,0.990,0.992,0.994,0.996,0.997,0.998,0.999,0.999,1.000};
10
 
11
float sin (int angle) {
12
	float res=1;
13
	angle%=360;
14
	if (angle>180) res=-1;
15
	if (angle>=0 && angle<=90) return (res*sctable[angle]);
16
	if (angle>90 && angle<=180) return (res*sctable[180-angle]);
17
	if (angle>180 && angle<=270) return (res*sctable[angle-180]);
18
	if (angle>270) return (res*sctable[360-angle]);
19
	return res;
20
}
21
 
22
float cos (int angle) {
23
	float res=1;
24
	angle%=360;
25
	if (angle>90 && angle<270) res=-1;
26
	if (angle>=0 && angle<=90) return (res*sctable[90-angle]);
27
	if (angle>90 && angle<=180) return (res*sctable[angle-90]);
28
	if (angle>180 && angle<=270) return (res*sctable[90-(angle-180)]);
29
	if (angle>270) return (res*sctable[90-(360-angle)]);
30
	return res;
31
}
32
 
33
int FloatToInt (float a) {
34
	int sign=1;
35
	int result=0;
36
	if (a<1 && a>(-1)) return 0;
37
	if (a<0) {
38
		sign=-1;
39
		a*=(-1);
40
	}
41
	while (a>=1) {
42
		a--;
43
		result++;
44
	}
45
	return (result*sign);
46
}
47
 
48
int min (int a, int b) {
49
	if (a<=b) return a;
50
	return b;
51
}
52
 
53
int max (int a, int b) {
54
	if (a>=b) return a;
55
	return b;
56
}
57
 
58
void IntToStr (int Value, char Str[]) {
59
	char Stack[100]="";
60
	int StackLen=0;
61
	if (Value==0) {
62
		Str[0]='0';
63
		Str[1]='\0';
64
		return;
65
	}
66
	while (Value!=0) {
67
		Stack[StackLen]=Value%10+48;
68
		Value/=10;
69
		StackLen++;
70
	}
71
	int i=0;
72
	for (i=0; i
73
		Str[i]=Stack[StackLen-i-1];
74
	}
75
	Str[i]='\0';
76
}
77
 
78
int Abs (int a) {
79
	if (a<0) return (-1)*a;
80
	return a;
81
}
82