/* University College London dept of physics course in C++ 3C59 | all rights reserved 1999 | | Example: Dot Product | | "Second use of ThreeVector class | Used to make 3-vector dot product even more simple" | | Author: P.Clarke */ #include #include #include "../util/ThreeVector_secondgo.h" // You dont need to write any functions any more. // All the work will be done by the methods of ThreeVector //.............. // Main program int main() { // Declare some 3-vectors ThreeVector vec1 ; ThreeVector vec2 ; // Set them to something vec1.initialise( 1.0, 1.5, 1.6 ) ; vec2.initialise( -0.3, 1.2, 1.0 ) ; // Take the dot product float prod ; prod = vec1.dotProduct( vec2 ) ; // Calculate the magnitude of each vector float mag1, mag2 ; mag1 = vec1.magnitude( ) ; mag2 = vec2.magnitude( ) ; // ..but we didnt need to bother with the last calls as we // can calculate the angle between the vectors directly float theta ; theta = vec1.angle( vec2 ) ; // Finally print it out std::cout << "TTTTTTTTTTTTTTTT 3C59 example TTTTTTTTTTTTTTTT" << std::endl ; std::cout << " dprd4: This is the really improved version " << std::endl ; std::cout << " The angle is " << theta << " radians " << std::endl ; std::cout << "LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL" << std::endl ; return 1 ; }