D00 von 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 #include #include #include #i
Posted: Fri May 20, 2022 11:24 am
= F叶归加印昭阳红弘8码8%切898a&Egg阳5%的阳江2四四四形刀沿四%888时时 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 printf("v1 + V2 = *); print_vector(sum(v1, v2)); printf("v1 - v2 - "); print_vector (diff(vi, v2)); printf("k* vi = "); print_vector (multiplyby_scalar (vi, k)); printf("vi. V2 = %.21f\n", dot_product(v1, v2)); printf("v1 x V2 = "); print_vector (cross_product(v1, v2)); printf("| vi| %.21f\n", nor (v1)); if(is_unitvector (v1)) printf("vi is a unit vector. In"); else printf("\1 is not unit vector. \n"); printf("unit( vi ) = "); print_vector (unit(v1)); printf("angle(v1, v2) = %.21f\n", angle(v1, v2)); printf("distance(v1, v2) = %.21f\n", distance(v1, v2)); if (are_linearly_independent (v1, v2, v3)) printf("Vectors are linearly independent. \n"); else printf("Vectors are not linearly independent. \n"); 76 77 78 79 80 81 82 83 84 85 if(are_orthogonal(v1, v2, v3)) printf("Vectors are orthogonal.\n"); else printf("Vectors are not orthogonal. \n"); if(are_orthonormal(v1, V2, V3)) printf("Vectors are orthonormal. \n"); else printf("Vectors are not orthonormal.\n");
86 87 88 89 printf("Projection of vi onto v2 is = "); print_vector (projection (v1, v2)); printf("Orthogonal projection of v1 onto v2 is = "); print_vector (orthogonal_projection (v1, v2)); 92 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 if (convert_2_orthogonal_basis(&vi, &v2, 8v3)){ printf("Orthogonalization of vectors:\n"); printf("v1 = "); print_vector (v1); printf("v2 = "); print_vector(v2); printf("v3 = "); print_vector(v3); } puts (vector2str(v1)); return 0; }
Complete the C program that makes many operations on 3D vector spaces by considering the following details. The program contains a structure which represents a 3D vector, the main function and many functions prototypes. You must write the functions whose prototypes have been given. You can change the main function to check the possible results. Do not change the other codes (the structure and function prototypes). A sample output is given below for the given main function: vi - (1.00, 2.00, 2.00) V2 = (-1.ee, e.ee, 2.00) V3 - (e.ee, e.ee, 1.ee) vi + V2 - (e.ee, 2.00, 4.00) v1 = v2 = (2.ee, 2.ee, 8.00) KV1 - (2.ee, 4.ee, 4.00) v1 . V2 - 3.00 vi x v2 - (4.00, -4.ee, 2.00) | v1 | - 3.ee vi is not unit vector. unit( vi ) = (0.33, 0.67, 0.67) angle(v1, v2) - 1.11 distance(v1, v2) = 2.83 Vectors are linearly independent. Vectors are not orthogonal. Vectors are not orthonormal. Projection of vi onto v2 is - (-0.6e, e.ee, 1.20) Orthogonal projection of v1 onto v2 is - (1.60, 2.ee, 2.80) Orthogonalization of vectors: vi - (1.ee, 2.ee, 2.00) V2 = (-1.33, -0.67, 1.33) V3 = (0.22, -2.22, 0.11) (1.00, 2.00, 2.00) Process exited after e.e1459 seconds with return value o Press any key to continue