double AB, AC, AD; AB = (pow(Bx - Ax, 2) + pow(By - Ay, 2) + pow(Bz - Az, 2)); AC = (pow(Cx - Ax, 2) + pow(Cy - Ay, 2) + pow(Cz - Az, 2)); AD = (pow(Dx - Ax, 2) + pow(Dy - Ay, 2) + pow(Cz - Az, 2)); cout << "These are the magnitudes of each vector from A;\n"; double FBx, FBy, FBz, FCx, FCy, FCz, FDx, FDy, FDz; cout << pow(AB, .5) << '\t' << pow(AC, .5) << '\t' << pow(AD, .5) << endl; FBx = FB * (Bx / AB); FBy = FB * (By / AB); FBz = FB * (Bz / AB); FCx = FC * (Cx / AC); FCy = FC * (Cy / AC); FCz = FC * (Cz / AC); FDx = FD * (Dx / AD); FDy = FD * (Dy / AD); FDz = FD * (Dz / AD); cout << FB << FBy << endl; double Fx, Fy, Fz; Fx = FBx + FCx + FDx; Fy = FBy + FCy + FDy; Fz = FBz + FCz + FDz; cout << "Sum of the vectors:\n"; cout << Fx << '\t' << Fy << '\t' << Fz << endl; double magVtotal; magVtotal = pow(Fx, 2) + pow(Fy, 2) + pow(Fz, 2); cout << "The total magnitude of these vectors:" << pow(magVtotal, .5) << endl; |