Using Following Code Fragment Vector Three Dimensions Complete Required Methods Space Prov Q37103815

Using the following code fragment for a vector with threedimensions, complete the required methods in each spaceprovided:

// Code fragment
#include
#include
using namespace std;

class Vec3{
private:
double values[3];

public:
Vec3( double v0, double v1, double v2){
values[0] = v0; values[1] = v1; values[2] = v2;
}
}// End of code fragment

Create a normalize method which modifies the vector’s currentvalues to unit length. That is, the normalize function adjusts theexisting values in the Vec3 object such that the length from theorigin at 0,0,0 to the point defined in Vec3 is one unit. (Hint:Pythagoras)
—————————————————————————————————————
I’ve completed this but for some reason when i return my vector, itholds the same values it initially had.

Vec3

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.