Menu

[Solved]4 Using Following Code Fragment Vector Three Dimensions Complete Required Methods Space In Q37296732

4. Using the following code fragment for a vector with three dimensions, complete the required methods in each space #include

(d) (5 points) Create a normalize method which modifies the vectors current values to unit length. That is, the normalize fu

4. Using the following code fragment for a vector with three dimensions, complete the required methods in each space #include< iostream> # include<cmath> using namespace std; provided class Vec3 private: double values [3] public: Vec3( double vo, double v1, double v2 ) values [0] values [1] values [2] = v0 ; = v2 ; -v1; (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)2Vec3(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 uni. Hint: Pythagoras e) (6 points) The three-dimensional cross product of two vectors produces a new vector or thogonal to the two original vectors. Produce the code necessary to create a class method which computes a cross product between its saved values and another Vec3 vectors. This 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 soisj+ s2k aXb) follow: 80 = a1b2-a2b1 81 = a2b0-a0b2 Show transcribed image text 4. Using the following code fragment for a vector with three dimensions, complete the required methods in each space #include # include using namespace std; provided class Vec3 private: double values [3] public: Vec3( double vo, double v1, double v2 ) values [0] values [1] values [2] = v0 ; = v2 ; -v1; (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)2Vec3(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 uni. Hint: Pythagoras e) (6 points) The three-dimensional cross product of two vectors produces a new vector or thogonal to the two original vectors. Produce the code necessary to create a class method which computes a cross product between its saved values and another Vec3 vectors. This 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 soisj+ s2k aXb) follow: 80 = a1b2-a2b1 81 = a2b0-a0b2

Expert Answer


Answer to 4. Using the following code fragment for a vector with three dimensions, complete the required methods in each space #in… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *