[Solved] 4 Using Following Code Fragment Vector Three Dimensions Complete Required Methods Space Pr Q37281621


C++ programming
4. Using the following code fragment for a vector with three dimensions, complete the required methods in each space provided: #include<iostream> # include<cmath> using nasespace std class Vec3 ( private1 double values [3): public: Vec3( double vo, double vi, double v2) v1; values [2) v2 values [O]-v; values [1] (a) (3 points) Define the copy constructor: (b) (3 points) Create a two parameter mutator method: (c) (3 points) Overload the operator such that when the Vec3 is multiplied by a float it returns a scaled Vec3 object (e.g. Vec3(1,2,3) 2 Vec3 (2,4,6)): (d) (5 points) Create a normalize method which modifies the vector’s current values to unit length. That is, the normalize function adjusts the existing values in the Vec3 object such that the length from the origin at 0,0,0 to the point defined in Vec3 is one unit. Hint Pythagoras (e) (6 points) The three-dimensional cross product of two vectors produces a new vector or ass method thogonal to the two original vectors. Produce the code necessary to create a cl which computes a cross product between its saved values and another Vec3 vectors method shall take a single parameter and return a Vec3 object with the orthogonal values Given two vectors a and b, the scalar components for the cross product (s = soi + s11 + 82k aXb) follow: . This 83 = a0b1-aibo Show transcribed image text 4. Using the following code fragment for a vector with three dimensions, complete the required methods in each space provided: #include # include using nasespace std class Vec3 ( private1 double values [3): public: Vec3( double vo, double vi, double v2) v1; values [2) v2 values [O]-v; values [1] (a) (3 points) Define the copy constructor: (b) (3 points) Create a two parameter mutator method: (c) (3 points) Overload the operator such that when the Vec3 is multiplied by a float it returns a scaled Vec3 object (e.g. Vec3(1,2,3) 2 Vec3 (2,4,6)):
(d) (5 points) Create a normalize method which modifies the vector’s current values to unit length. That is, the normalize function adjusts the existing values in the Vec3 object such that the length from the origin at 0,0,0 to the point defined in Vec3 is one unit. Hint Pythagoras (e) (6 points) The three-dimensional cross product of two vectors produces a new vector or ass method thogonal to the two original vectors. Produce the code necessary to create a cl which computes a cross product between its saved values and another Vec3 vectors method shall take a single parameter and return a Vec3 object with the orthogonal values Given two vectors a and b, the scalar components for the cross product (s = soi + s11 + 82k aXb) follow: . This 83 = a0b1-aibo
Expert Answer
Answer to 4. Using the following code fragment for a vector with three dimensions, complete the required methods in each space pro… . . .
OR

