Commit b72c5d94 by tekalj

uploading lab6

parent 39e17309
No preview for this file type
...@@ -20,11 +20,11 @@ int main() { ...@@ -20,11 +20,11 @@ int main() {
sk = v[i][0] * v[j][0] + v[i][1] * v[j][1] + v[i][2] * v[j][2]; sk = v[i][0] * v[j][0] + v[i][1] * v[j][1] + v[i][2] * v[j][2];
lenght1 = sqrt(v[i][0] * v[i][0] + v[i][1] * v[i][1] + v[i][2] * v[i][2]); lenght1 = sqrt(v[i][0] * v[i][0] + v[i][1] * v[i][1] + v[i][2] * v[i][2]);
lenght2 = sqrt(v[j][0] * v[j][0] + v[j][1] * v[j][1] + v[j][2] * v[j][2]); lenght2 = sqrt(v[j][0] * v[j][0] + v[j][1] * v[j][1] + v[j][2] * v[j][2]);
lenght = lenght1 + lenght2; lenght = lenght1*lenght2;
angle = sk/lenght; angle = sk/lenght;
x = acos(angle); x = acos(angle);
printf("%lf, ", x); printf("%d, %d, %lf\n",i, j, x);
} }
......
File added
#include <stdio.h>
#include <math.h>
int dotProduct(int vector1[3], int vector2[3]);
double vectorMagnitude(int vector[3]);
int main(){
int i, j, sk;
double p, p2, n, nurk;
int vector[4][3] = {{1, 4, 6},
{2, -3, 1},
{3, 5, 0},
{3, 1, -3}};
for (i = 0; i <= 2; i++){
for (j = i+1; j <= 3; j++){
p = vectorMagnitude(vector[i]);
p2 = vectorMagnitude(vector[j]);
sk = dotProduct(vector[i], vector[j]);
n = sk/(p*p2);
nurk = acosf(n);
printf("%lf\n", nurk*57.295779513);
}
}
return 0;
}
int dotProduct(int vector1[3], int vector2[3]){
int dot = 0;
int i;
for(i = 0; i < 3; i++){
dot += vector1[i] * vector2[i];
}
return dot;
}
double vectorMagnitude(int vector[3]){
int sumOfSquares = 0;
int i;
for(i = 0; i < 3; i++){
sumOfSquares += vector[i]*vector[i];
}
double magnitude = sqrt(sumOfSquares);
return magnitude;
}
File added
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