3-d vectors This example introduces a simple class representing vectors in 3-dimensional space and a collection of functions that operate on these vectors. Files ===== Vector_3d.hpp Contains the declaration and definition of the Vector_3d class, together with the declarations of all functions that operate on Vector_3d objects. Vector_3d.cpp Contains the definitions of the functions declared in Vector_3d.hpp. main.cpp Contains examples demonstrating how to create Vector_3d objects and call the functions that operate on them. The Vector_3d class =================== A Vector_3d object stores three double-precision floating-point components: x_ y_ z_ For example, Vector_3d u{ 3.2, -4.5, 2.1 }; creates a 3-dimensional vector with the three indicated components. Functions are provided for operations including: - inner products, - norms, - vector addition and subtraction, - scalar multiplication and division, - additive inverses, - projections, - cross products, - equality testing, - normalization, and - conversion to a string. Some functions return a new Vector_3d object without changing their arguments. Other functions, such as normalize(...), add_to(...), sub_from(...), mul_by(...), and div_by(...), modify the Vector_3d object passed to them. Purpose ======= This example demonstrates how a simple class can group related data into one object while separate functions provide operations on those objects. Later, many of these functions could instead be implemented as member functions or operators. For now, keeping the data and the functions separate makes the behavior of references, const parameters, function overloading, and separate compilation easier to see. Compiling ========= Compile both main.cpp and Vector_3d.cpp. For example: g++ -std=c++17 -Wall -Wextra -pedantic main.cpp Vector_3d.cpp The resulting executable contains the function definitions from both source files.