Your getting vectors mixed up a bit here.
The STL vector is a container, not to be confused with the mathematical vector; an entity which has magnitude and direction.
If you had a vector named 'b', presumably you could just pass it into that function.
Have to say, I think there are better ways than this. A 3DVector class with x, y and z elements would be a lot nicer.
Last edited on
b is an array of 3 vector<double>. Is vector here std::vector? std::vector is not really optimal as a geometric vector.
I would name it something else.
And add some functions. CalculateMagnitude, Normalize. Stuff like that.
I think the function works though
I wouldn't be so sure. Like Athar says, looks like too many sqrt functions.
Whenever I work out the magnitude of a vector, it's the following formula:
|v| = sqrt((v.x * v.x) + (v.y * v.y) + (v.z * v.z))