Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

viakul / iax0583

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Members
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Commit 064a5106 authored 6 years ago by viakul's avatar viakul
Browse files
Options
  • Browse Files
  • Download
  • Email Patches
  • Plain Diff

Upload New File

parent ff760e54 master
Hide whitespace changes
Inline Side-by-side
Showing with 60 additions and 0 deletions
  • Lab5/angle.c
Lab5/angle.c 0 → 100644
View file @ 064a5106
#include <stdio.h>
#include <math.h>
int main()
{
int matrix[4][3]={{1,4,6},
{2,-3,1},
{3,5,0},
{3,1,-3}};
double length1;
double length2;
int dotProduct;
double angle;
double cosAngle;
int i;
int j;
int m;
int k;
i=0;
for(i=0;i<4;i++){
m=i+1;
while(m<4){
printf("The first vector is:\n");
for(j = 0; j < 3; j++){
printf("%d ", matrix[i][j]);
}
printf("\n");
printf("The second vector is:\n");
for(k = 0; k < 3; k++){
printf("%d ", matrix[m][k]);
}
printf("\n");
length1 = sqrt(matrix[i][0]*matrix[i][0]+matrix[i][1]*matrix[i][1]+matrix[i][2]*matrix[i][2]);
length2 = sqrt(matrix[m][0]*matrix[m][0]+matrix[m][1]*matrix[m][1]+matrix[m][2]*matrix[m][2]);
printf("length1 1 %f\n", length1);
printf("length1 2 %f\n", length2);
dotProduct=0;
for (j=0;j<3;j++){
dotProduct = dotProduct + matrix[i][j]*matrix[m][j];
}
cosAngle=dotProduct/(length1*length2);
angle=acos(cosAngle);
printf("angle %f \n", angle);
printf("\n");
printf("\n");
m++;
}
}
return 0;
}
This diff is collapsed. Click to expand it.
  • Write
  • Preview
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