CODE:
1 #include<stdio.h>
2 #include<math.h>
3 #define PI 3.14159265
4 double a[2][2],b[2],c[2],x;
5 int i,j;
6 /*initializare matrice rotatie*/
7 void matrice_rotatie(double a[2][2],double x)
8 {a[0][0]=a[1][1]=cos(x*2*PI/360);
9 a[0][1]=-sin(x);
10 a[1][0]=sin(x);
11 }
12 /*rotatie*/
13 void rotatie(double b[2],double c[2],double a[2][2])
14 {
15 for(i=0;i<2;i++)
16 for(j=0;j<2;j++)
17 c[i]+=a[i][j]*b[i];
18 }
19 /*afisare_matrice*/
20 void afis_matrice(double a[2][2]){
21 for (i = 0; i < 2; i++) {
22 for (j = 0; j < 2; j++)
23 printf("%.2lf ", a[i][j]);
24 printf("
");
25 }
26 }
27 int main(){
28 printf("Coordonatele punctului:");scanf("%lf %lf",&b[0],&b[1]);
29 printf("Unghiul de rotatie:");scanf("%lf",&x);
30 matrice_rotatie(a,x);
31 rotatie(b,c,a);
32 printf("coordonatele noi sunt:%.2lf si %.2lf
",c[0],c[1]);
33 return 0;
34 }
0 komentar:
Posting Komentar