Lets say I have an arbitrary vector A. What is the most efficient way to reducing that vectors magnitude by arbitrary amount?
My current method is as follows:
Vector shortenLength(Vector A, float reductionLength) {
Vector B = A;
B.normalize();
B *= reductionLength;
return A - B;
}
Is there a more efficent way to do this? Possibly removing the square root required to normalize B…
So if I understand you correctly, you have a vector
A, and want another vector which points in the same direction asA, but is shorter byreductionLength, right?Does the
Vectorinterface have something like a "length" member function (returning the length of the vector)? Then I think the following should be more efficient: