We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Create a class named Vector with four (integer) data members (x and y coordinates of two points).
Provide default and parameterized constructors.
Provide a set method which accepts four integers and sets the values of the data members.
Provide get() methods to return each of the data members.
Provide functions to calculate the magnitude and direction of the vector.
In main(), declare an object v1 of class vector, call the functions to compute the magnitude and direction of the vector and display these values in the main.
Declare another object v2 of vector and set its data members.
Compute the dot product between v1 and v2. ((v1) ⃗.(v2) ⃗=v1.x*v2.x+v1.y*v2.y)
Compute the angle between the two vectors. (Hint:(v1) ⃗.(v2) ⃗= |v1||v2|cosθ)
Compute the magnitude of the cross product of the two vectors. (Hint: |v1||v2|sinθ)
Classes and Objects
You are viewing a single comment's thread. Return to all comments →