Menu

[Solved]Create Normalize Method Modifies Vector S Current Values Unit Length Normalize Function Ad Q37300968

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

a) 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

b)

The three-dimensional cross product of two vectors produces anew vector orthogonal to the two original vectors. Produce the codenecessary to create a class method which computes a cross productbetween its saved values and another Vec3 vectors. This methodshall take a single parameter and return a Vec3 object with theorthogonal values. Given two vectors a and b, the scalar componentsfor the cross product (s = s₀i + s₁j + s₂k = aXb) follow:

s₀ = a₁b₂ − a₂b₁ s₁ = a₂b₀ − a₀b₂ s₃ = a₀b₁ − a₁b₀

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 namespace std; class Vec3 f private: double values (3]; public: Vec3( double v0, double vl, double v2) values to] – vO; values[1] – v1; values (2] v2 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 namespace std; class Vec3 f private: double values (3]; public: Vec3( double v0, double vl, double v2) values to] – vO; values[1] – v1; values (2] v2

Expert Answer


Answer to a) Create a normalize method which modifies the vector’s current values to unit length. That is, the normalize functio… . . .

OR


Leave a Reply

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