Hi everyone. im new to programming (only few weeks).
And i was given this coursework to find out the rotation of a matrix(2d). so i know, mathematically i have to multiply the sine & cosine matrix with the matrix to be rotated.
so than i would generate a new matrix(which i have to display).
i tried it. the output wasnt what i wanted. so i edited it (loads of times)
please help. this is the code so far. i know its kinda rubbish, but i have edited it a lot, and now im not sure where ive wound up.
and the error props in line 11..which is where ive declare r[100][100]
Code:
#include <stdio.h>
#include <math.h>
#define DEG 0.0174532925199432958;
main()
{
float degrees,theta,b[100][100],Pi=3.14;
float a[100][100];
int i,j,k;
float r[100][100]={{cos(theta),(-sin(theta))},{sin(theta),cos(theta)}};
printf(" 2d matrix rotation program\n");
printf("Please enter the angle in degrees you want the matrix to be rotated\n");
scanf("%d",°rees);
theta=degrees*DEG;
for(i=0;i<2;i++){
printf("Enter the data for row no. %2d\n",i+1);
for(j=0;j<2;j++){
scanf("%f",&a[i][j]);
}
}
for(i=0;i<2;i++){
for(j=0;j<2;j++){
b[i][j]=0;
for(k=0;k<2;k++){
b[i][j]+=a[i][k]*(r[k][j]);
}
}
}
printf("The rotated matrix is:\n");
for(i=0;i<2;i++){
for(j=0;j<2;j++){
printf("%4.2f",b[i][j]);
}
printf("\n");
}
return (0);
}