Commit 952314c7 by phkarl

Upload New File

parent 6e8f8f8c
Showing with 51 additions and 0 deletions
#include <stdio.h>
#include <math.h>
int main(){
int matrix[4][3] = {
{1, 4, 6},
{2, -3, 1},
{3, 5, 0},
{3, 1, -3}
};
int j;
int n;
int q;
int p;
int dot;
int lenSq1;
int lenSq2;
double angle;
printf("vector1 vector2 angle in degree\n");
for(j = 0; j < 4; j = j+2){
for(n = 0; n < 4; n++){
if(n != j ){
int x1 = matrix[j][0];
int y1 = matrix[j][1];
int z1 = matrix[j][2];
int x2 = matrix[n][0];
int y2 = matrix[n][1];
int z2 = matrix[n][2];
dot = x1 * x2 + y1 * y2 + z1 * z2;
lenSq1 = x1 * x1 + y1 * y1 + z1 * z1;
lenSq2 = x2 * x2 + y2 * y2 + z2 * z2;
angle = acos(dot / sqrt(lenSq1 * lenSq2));
angle = angle * (180.0 / 3.14159265);
for(q = 0; q < 3; q++){
printf("%d ", matrix[j][q]);
}
printf(" ");
for(p = 0; p < 3; p++){
printf("%d ", matrix[n][p]);
}
printf(" ");
printf("%f\n", angle);
}
}
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment